From patchwork Thu Feb 1 16:51:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 126555 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1877994ljc; Thu, 1 Feb 2018 08:51:22 -0800 (PST) X-Google-Smtp-Source: AH8x227R9Y+u+3VdE0mM5LHU8pQS9mCizz7Z1LIIjjaRWUvYuULaEwSUXE/Z7Ai4GVgs20fjBlLJ X-Received: by 2002:a17:902:69c5:: with SMTP id m5-v6mr31814060pln.347.1517503881981; Thu, 01 Feb 2018 08:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517503881; cv=none; d=google.com; s=arc-20160816; b=zzDCH/Q8P8zrlxp2G86b/ULHqzyoOJICgp9iDckRP/i69fOIBfKlOEZH/JOhEwqQxg asWC74Ufhzq9JdXizgqNxtlDkqCdmKFs4m/ftdudJ8q9UcNHatODHkUXUJJgeOQITH96 u9pVdNGI/d1vJLl/XuVv6hASU7NenGP9IztNM2XaaflGlPFtlVWt0SkW3UeDZj/nButh O51VvjPm63aJstpHaym5jySrsdTijrR9uOlsUAWtzPQyPm6qe4amBARNVsAj83SIiLqr mrhNboJdIqcSdl6jjKF9WkkFeADE7eniljKiWwdVT2yf9xoWSfeQSRRGQNzJcMWD6ilc BusQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=mYYC+yffuETXI7b8rW2UZcOnw5oDCib6paviSuYzsC4=; b=ZiupwrSzacQtJCaVFK5eUd/9yXxh+FwfPWg880KtSvTcG07oYm95+czQ6RNaX04Nzz zLlzCnxdkzGZLj+WGwJT+vz3s79pvQdAmGlHNwS/Val9GMUIfl8FVjejbV2WRUpL5QnY Hc1aVNg3Cml1+WzKzhVNnhrRUnuevLrD6DZArA1p6uz8Pbtt3ktaQd38zRk4MZ/1chaP OzcAE0l/nKHi7IzWAS7oz3raGAWN7fS8rFOXF+eG3JAREnUFY6fGkDoO5G5kP2Nm3irE EhmT931zrozimCMs+hyR+3tur4OSuk2qfc6vespKZcmGsPU/JD78/bf5aSJXt4Hfz72J ylwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gfP6dVVn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 95-v6si4565934ple.831.2018.02.01.08.51.21; Thu, 01 Feb 2018 08:51:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gfP6dVVn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbeBAQvU (ORCPT + 28 others); Thu, 1 Feb 2018 11:51:20 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:44191 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696AbeBAQvO (ORCPT ); Thu, 1 Feb 2018 11:51:14 -0500 Received: by mail-io0-f194.google.com with SMTP id z6so19872731iob.11 for ; Thu, 01 Feb 2018 08:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mYYC+yffuETXI7b8rW2UZcOnw5oDCib6paviSuYzsC4=; b=gfP6dVVnmRrzPl50T/G+U9WxBE7nd7NAzH6GLsBhjPvfcFTBFgszkviYBNUknk/cml 2nanXHEs+Hcak1hThzs/uRcCqljQi1SnukNMrrmi39ScVqsBDpNyT2TdqfnpCmRa8N1A hGpD6hvwMPdvqxQUZuIpAZduS7OQHb+NcRs68= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mYYC+yffuETXI7b8rW2UZcOnw5oDCib6paviSuYzsC4=; b=WTZN05WpF0LpbS46a1e6X25pZ+sjpSU4xgCk6rhQ5I317lgahJIb2JyZhR1y3Gki8m XP3mZuJxMm2XHbCklcJjwfwzl2Gdp3vGrAlmqmuA5glGS58kN4nXoFI4IElZDpU0M/iP YCRnp1xDLKRj9ybK+l0XK6N0529dUKm1DscCeKE9cWVeleNiNCNp63kPOzBZarGaEFT7 4jbrsUewr6wQTdzPethiGJg+Cy/P3+7YuWOq7ap/ig2qFnJ+W+verBkuY8ELxN0D0YQj pgozaLVhjKMpoQvofb/qWUXjsC3WutfjZ80NCwGvK/k7QrKHorrflXQOo5NzuJGyB/kc WnZg== X-Gm-Message-State: AKwxytdRTXz5YiCgb2OT2adYSNtvS/CtoAUuwW/n1rxvAP3x3t5xIMEA jFxbtwUyxopJw1wUIpsfRyENOQ== X-Received: by 10.107.168.25 with SMTP id r25mr38123189ioe.16.1517503873918; Thu, 01 Feb 2018 08:51:13 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id e83sm9270773iof.71.2018.02.01.08.51.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Feb 2018 08:51:13 -0800 (PST) From: Mathieu Poirier To: peterz@infradead.org Cc: lizefan@huawei.com, mingo@redhat.com, rostedt@goodmis.org, claudio@evidence.eu.com, bristot@redhat.com, tommaso.cucinotta@santannapisa.it, juri.lelli@redhat.com, luca.abeni@santannapisa.it, linux-kernel@vger.kernel.org Subject: [PATCH V2 1/7] sched/topology: Adding function partition_sched_domains_locked() Date: Thu, 1 Feb 2018 09:51:03 -0700 Message-Id: <1517503869-3179-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517503869-3179-1-git-send-email-mathieu.poirier@linaro.org> References: <1517503869-3179-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introducing function partition_sched_domains_locked() by taking the mutex locking code out of the original function. That way the work done by partition_sched_domains_locked() can be reused without dropping the mutex lock. This patch doesn't change the functionality provided by the original code. Signed-off-by: Mathieu Poirier --- include/linux/sched/topology.h | 9 +++++++++ kernel/sched/topology.c | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index cf257c2e728d..118141c3216a 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -162,6 +162,9 @@ static inline struct cpumask *sched_domain_span(struct sched_domain *sd) return to_cpumask(sd->span); } +extern void partition_sched_domains_locked(int ndoms_new, + cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new); extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], struct sched_domain_attr *dattr_new); @@ -207,6 +210,12 @@ extern void set_sched_topology(struct sched_domain_topology_level *tl); struct sched_domain_attr; static inline void +partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new) +{ +} + +static inline void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], struct sched_domain_attr *dattr_new) { diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 41bf2a531ee5..892e1f9c78f0 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1842,15 +1842,15 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur, * ndoms_new == 0 is a special case for destroying existing domains, * and it will not create the default domain. * - * Call with hotplug lock held + * Call with hotplug lock and sched_domains_mutex held */ -void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], - struct sched_domain_attr *dattr_new) +void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new) { int i, j, n; int new_topology; - mutex_lock(&sched_domains_mutex); + lockdep_assert_held(&sched_domains_mutex); /* Always unregister in case we don't destroy any domains: */ unregister_sched_domain_sysctl(); @@ -1915,7 +1915,16 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], ndoms_cur = ndoms_new; register_sched_domain_sysctl(); +} +/* + * Call with hotplug lock held + */ +void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], + struct sched_domain_attr *dattr_new) +{ + mutex_lock(&sched_domains_mutex); + partition_sched_domains_locked(ndoms_new, doms_new, dattr_new); mutex_unlock(&sched_domains_mutex); }