From patchwork Tue Feb 13 20:32:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 128292 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp32349ljc; Tue, 13 Feb 2018 12:33:05 -0800 (PST) X-Google-Smtp-Source: AH8x227cFjxXJyas409d1m7JRKwvklIG4MrOWI9//Qq1Itto/a9uIGwfwVIEjJ+B0aUCKhBfSbnO X-Received: by 10.98.110.202 with SMTP id j193mr2407635pfc.19.1518553985824; Tue, 13 Feb 2018 12:33:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518553985; cv=none; d=google.com; s=arc-20160816; b=etufRXnNVUg1/tspzdhlCCvRdhEm/SrQ4EmHf1Qg9tj3LTO135liYu5iKcaWBL8LxK pjoAFJXV7u1g7WKXRPFySltzY/orDOOLdtpHgw8KwDSQjO3J+Z+gD3DWdsuoU9cg1y7X 8gGriak4pgry1aUH5ZVoPv2AMg7KE4X0kKKNs5hhc14fq2QTNTW5TFMqyfOabYOmaViX vrTGrpJj+RWrNORzc0vi1lJeBVPTiLds0QPfH++TQEnnGWZYUaFIYvte3NluvI1p+LWN nKc4kR4BdM3+pdl+5c+oU1pQu8hwuoZbGel/xOStaSV383wzE8ROzniolG+v4QWWaBu9 G/bw== 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=aqfOKIUd8Y1UwyLRij4d9JL0cKxu3qmny5GvLSDwxsk=; b=vojJGtYLr5Tzb0NNI09FxjxbiF6JWzN8dZGS6iz6mdsl9HwZTaoL/n65ZMIK8VMz1U cHxXz/nNMHjFZJ5srIa2vJC9C0/2696whrv5gpbi+12m1DCt2zFBms+UliqCuPvItr4p IBr0BgfrbJxJk9URNDj/CDcobFxPE5FYlc9aWaO5TpQEcxi4n+fzyIP7N8gEPfvLfBt2 qcJ2V7TK+W8AM34KABfCFxlkhlqT/726/zDv5Emfh2uargRpl2zubZcBYT9D8zpHNNAJ RvTJrc91bbq/UaVExWarpVVlfYfZn/GsHTcoAMvLd6gsJcyiUKnI6oPBH81qsWbRQKYo 7yjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IM6PVvBL; 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 d19si2185203pfk.194.2018.02.13.12.33.05; Tue, 13 Feb 2018 12:33:05 -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=IM6PVvBL; 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 S965831AbeBMUdA (ORCPT + 28 others); Tue, 13 Feb 2018 15:33:00 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:42031 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965789AbeBMUcy (ORCPT ); Tue, 13 Feb 2018 15:32:54 -0500 Received: by mail-pg0-f68.google.com with SMTP id y8so666150pgr.9 for ; Tue, 13 Feb 2018 12:32:54 -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=aqfOKIUd8Y1UwyLRij4d9JL0cKxu3qmny5GvLSDwxsk=; b=IM6PVvBLeFKzmTSnH0hsMPEmeFYJ0QV/o1Q7Q3q+5C3TkrfcamuQ8B5akP9QDC4lt8 yRJVz+xLv27O8nYAai8SyvEv8/5MAXJl8y5/gjRVZlTcZNrFW7+xLE68GfQs1QN5kpgF VSnTsJBwe1Fhb6yr+ELcLcyFW7AHol4dilZdI= 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=aqfOKIUd8Y1UwyLRij4d9JL0cKxu3qmny5GvLSDwxsk=; b=bb/A/RNDPKJkT3UlkFF9VdIbzeXth/PiGmjvX+9shp7rE7SxdvjkwvrTzJn9fFmgom u/TF0/crza4HpqdSzcKspqSnxOW2d6Okuo+tFZhUUQFK/QcijbkkzsCQdRxxcdY+++uJ PjaO5y2JCIcMZUEgNxXhKhi5vZBlOa9Kjj2wLjwQv8sJSnwaztGvsB2SyLzSlFPK6Lov DwCUBakb0ez8sqXHCIrNNAEV0BZeS3FH23RA3E09kjCyYp6KqtRKuhGglfPai4YG1aRK 3M3KOl/x3t7yPyBE+drxl0zJKKx3IHjQL6RA6/wXqWRlcfkqbX1xOqMN6ADFQY6z85l0 S/PQ== X-Gm-Message-State: APf1xPCaPdOEjNsQCews9UnExsnp29RQ4y6ii6J5TVFLp9P5vhiNtUNW Ppeo1r+D5HXroFbQqkodwyn/Vg== X-Received: by 10.99.123.79 with SMTP id k15mr1954390pgn.173.1518553973609; Tue, 13 Feb 2018 12:32:53 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o135sm35540873pfg.45.2018.02.13.12.32.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 12:32:52 -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, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 02/10] sched/topology: Adding function partition_sched_domains_locked() Date: Tue, 13 Feb 2018 13:32:39 -0700 Message-Id: <1518553967-20656-3-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518553967-20656-1-git-send-email-mathieu.poirier@linaro.org> References: <1518553967-20656-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. No change of functionality is introduced by this patch. Signed-off-by: Mathieu Poirier --- include/linux/sched/topology.h | 10 ++++++++++ kernel/sched/topology.c | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 26347741ba50..57997caf61b6 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -162,6 +162,10 @@ 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 +211,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 7c744c7425ec..eee721da40fb 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1855,16 +1855,16 @@ 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; lockdep_assert_cpus_held(); - 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(); @@ -1929,7 +1929,17 @@ 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) +{ + lockdep_assert_cpus_held(); + mutex_lock(&sched_domains_mutex); + partition_sched_domains_locked(ndoms_new, doms_new, dattr_new); mutex_unlock(&sched_domains_mutex); }