Received: by 10.223.176.5 with SMTP id f5csp2977810wra; Thu, 1 Feb 2018 08:54:32 -0800 (PST) X-Google-Smtp-Source: AH8x224rvN4tAhSU7j2wZW+wlpd0WJfzmxdU/AW2/pBu1h7yXUibc/HuRHUlxlYmodidzAGCdg3W X-Received: by 2002:a17:902:7581:: with SMTP id j1-v6mr11110953pll.86.1517504071945; Thu, 01 Feb 2018 08:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517504071; cv=none; d=google.com; s=arc-20160816; b=gm2blWmAusKDi49xtwkCExdCkjw+Ni9YowFSEQkIa2XpSM1HGjWg22X3djMs/6zbZy mh5w6mq+ab6h2QMFTiGQI4QOhd/tjFAUVf4wsc6PbDbNll9uAR5UcVQfvdg6iUPfXmDu 7ypJ8Vk4CoKNurIEHLz5sEo3rn9SU9C6h/MdAdZ+fJ6leUrEUxlhJYDSXR9hVNN8Sz+d WflOj+Q9QOVePvn01+4vEY8scjg00zw2ZCUb5CvoLCTt6Gd9rJFxFEe/34r71y5/f0ah pE9OTKaY+DsfFl0IMWcsw9mg8yLMkBV+WIRFZX6IaXBB1trlAs4QkxV/hMemYJ3LuuzK MbtA== 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 5-v6si2659plt.284.2018.02.01.08.54.17; Thu, 01 Feb 2018 08:54:31 -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 S1752784AbeBAQvT (ORCPT + 99 others); Thu, 1 Feb 2018 11:51:19 -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(-) 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); } -- 2.7.4