From patchwork Thu Jan 17 08:47:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 155804 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1699839jaa; Thu, 17 Jan 2019 00:48:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7dnUR1YLF2/hqPg+r1PJw4ve8rVOrEUZ+vJtFp9xG5dHQlW0H1RMQMsbVU2vySODZOd1RP X-Received: by 2002:a62:7dcb:: with SMTP id y194mr14158191pfc.113.1547714882269; Thu, 17 Jan 2019 00:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547714882; cv=none; d=google.com; s=arc-20160816; b=acwdT1otPkF6pJTkB6pegwnCIde3pqJWlaHe6o8gLUsOpV8orpzz8h5A7YI2qIdyQF gmj/jkjFh5vqoZpVVuJIfHSB5ebwp0vGjega8DZ3ctEDPuYfsaJ6rbprL9chJBlA8szN P+v7trrIT/lpiYwZrE/arwBNGncgJ9fGSXK4CUrHnrjhBVsYBNUcZmNxZwlKozz+TTYG fcCSwgX5nYd4/QeLgHZVGf768A8drxWvb8BmvhL2mkEnvwFdb+WAuX327spucs+ehLQq 4HHTlAmrluWpCJnh9ltTYVTLc6K0SyPAQuihRS64h3HK4IUKhAaYFjzd++Pme7mHwP7w 8gKg== 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; bh=aOQfSRK6Cu00XkimRyJoEETFz42MVog205vqP9ZMoCo=; b=H3vRz0jOLZNKZEK2IeaxwUbG6St7RMijb79ibmTvR8TvIGeNynF7HRumyfPufNNeeF 0k1qkO8lYz021rXkoaUtjq66TISghoGBmVf8EEG86oRz90uuXag9YY0HSdJ2LUq1BDBn ThzERsISPgSlNv3wiEgvkGvXKxQo8ubV0zVkG2LgW1HD4TnN93ZpnBkQ8FMwGTySFbju 1pWQcd+i9dla3YULw16umMHw3R/3LJkBclQdY5ngByEckYQjuApGUUUtA3e6+r2OY/yt ixoZ/++XYldqBjgPsN/oNwPrw9Mi4HHgu0LpalHpJEKX70eKiVkDDBsdjJdRUIBwUamk pnDw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si990099pgc.369.2019.01.17.00.48.02; Thu, 17 Jan 2019 00:48:02 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730783AbfAQIsA (ORCPT + 12 others); Thu, 17 Jan 2019 03:48:00 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:32828 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfAQIr5 (ORCPT ); Thu, 17 Jan 2019 03:47:57 -0500 Received: by mail-wr1-f68.google.com with SMTP id c14so10063086wrr.0 for ; Thu, 17 Jan 2019 00:47:56 -0800 (PST) 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=aOQfSRK6Cu00XkimRyJoEETFz42MVog205vqP9ZMoCo=; b=j++Zb85NJtYEANAmbti21Y+bYkU7YyLixgxE0Apf2gHd9EQzW3LIIOxotb13jLmI6N xYVDyLCh2VTLwjZ5JWwJ/tRKOSiEWYlfqgdZZKtoqUJCBKfmMMMMCE+3+JALToLlzlm2 6zk7rcM3U40S91MJSITj8TjAl9ajexA59K9Sc2J0ojZIpYCNh/8xXhzgo7rpHzYNbP7J 4k4Kcqn2DlsGpUKmsDoDvB4XS5Vyv1QVDcaHvxdaiUZby8KOzrq9rnoccZMx5tCR87CF T7jtGc2cy7jBUP+FyzSLEEfYWnPdL7pGyWcqC/cCY/EWD1pEVfz6Hqz/vg5Kz8vawVZu wyFQ== X-Gm-Message-State: AJcUukcTbXC4n2f+eYPa2vHzkhV6a/Ao9zS3rhP8tyz+u8oPIoSmHBbZ TRMfxyJFiJS7ddbloMg1NvBCKA== X-Received: by 2002:a5d:61c4:: with SMTP id q4mr10532377wrv.308.1547714875758; Thu, 17 Jan 2019 00:47:55 -0800 (PST) Received: from localhost.localdomain.home ([151.15.254.62]) by smtp.gmail.com with ESMTPSA id 199sm41984992wmh.21.2019.01.17.00.47.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Jan 2019 00:47:55 -0800 (PST) From: Juri Lelli To: peterz@infradead.org, mingo@redhat.com, rostedt@goodmis.org, tj@kernel.org Cc: linux-kernel@vger.kernel.org, luca.abeni@santannapisa.it, claudio@evidence.eu.com, tommaso.cucinotta@santannapisa.it, bristot@redhat.com, mathieu.poirier@linaro.org, lizefan@huawei.com, cgroups@vger.kernel.org Subject: [PATCH v6 1/5] sched/topology: Adding function partition_sched_domains_locked() Date: Thu, 17 Jan 2019 09:47:35 +0100 Message-Id: <20190117084739.17078-2-juri.lelli@redhat.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190117084739.17078-1-juri.lelli@redhat.com> References: <20190117084739.17078-1-juri.lelli@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier 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 Acked-by: Tejun Heo --- include/linux/sched/topology.h | 10 ++++++++++ kernel/sched/topology.c | 17 +++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) -- 2.17.2 diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 6b9976180c1e..d69e7d56253a 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); @@ -206,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 8d7f15ba5916..dd94000cb378 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1929,15 +1929,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(); @@ -2002,6 +2002,15 @@ 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); }