Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp280993pxk; Thu, 24 Sep 2020 05:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXM2V4dJvEsfCxCfyOuQbVuBdv7PsIIefITQ84vPvrRrNLwJYC17/sHAQh8F+s0JDfdY7f X-Received: by 2002:aa7:d4d0:: with SMTP id t16mr829140edr.83.1600951433308; Thu, 24 Sep 2020 05:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600951433; cv=none; d=google.com; s=arc-20160816; b=qyH0+Sm66xutlA+HK6lCHTlg9PZjv3htK7qINhiYCNKCzrGxIgU1aib4ODGOSMJvgu u5+PQOQzhy2lcb4YO8N6SWr9nuB4os87g1inbso/Prp7Zg70cSWkOWPDGboskyXKbps1 04YcWqYIxcBBPZI49jacpLTp/7Z+zhjr1f81KtADv1tCC3SaZHXEKDotnLdMtsSMYOM0 WV0HsxcB53J2Es9Srt8Q3/QhjABLros99PrlBdxo5otBTQgXWmIJQXDH+1jcvzOvfGOm euTjVbFZnmEKzGNIFUFbooLrR60OqV5eIi54cIi1w4+QhQGhbDrlHIUirfSauRc2DfW5 OqQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=ZZHD2MhJq/msPzu+wTE9UIdWHN8k3LVka0hdEPf2KvU=; b=tBsOvp7+ON4NR7OZ3wwcg8X7RSdD9HQDgcQrH8Z3OT8M7ohqp3NCPA8SiYY2MoG0gW MLUuR5pemWywxZtEWb7ULI+rB+UTuZv+pdWSnSP+Ujop0K3FML28xyPRmUPLbYyWu0S6 wmnGoxZRJ0Cz0X64KUPtKbPxseBIXELJ6+C0bmUBesArWBQ5xUapbQUxbRsrEXfM5KVG rngKLKYFKFoiHtC9m50O8BB+XGj3JzUjIc6tUOdI4KY0GWn/NNLOPyIsI8dIvyZvex1M tnqu4U84keGSQgVhwHmR80rvWDmc1UUzSx2c01nr1HIA/aVkXrlVxgkvLY19SKkDB+ud RToQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si1877491ejb.646.2020.09.24.05.43.29; Thu, 24 Sep 2020 05:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727744AbgIXMkO (ORCPT + 99 others); Thu, 24 Sep 2020 08:40:14 -0400 Received: from foss.arm.com ([217.140.110.172]:45040 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727570AbgIXMkO (ORCPT ); Thu, 24 Sep 2020 08:40:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CC896113E; Thu, 24 Sep 2020 05:40:13 -0700 (PDT) Received: from e108754-lin.cambridge.arm.com (unknown [10.1.199.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0C0253F73B; Thu, 24 Sep 2020 05:40:11 -0700 (PDT) From: Ionela Voinescu To: mingo@redhat.com, peterz@infradead.org, vincent.guittot@linaro.org, catalin.marinas@arm.com, will@kernel.org, rjw@rjwysocki.net, viresh.kumar@linaro.org Cc: dietmar.eggemann@arm.com, qperret@google.com, valentin.schneider@arm.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ionela.voinescu@arm.com Subject: [PATCH 1/3] sched/topology,schedutil: wrap sched domains rebuild Date: Thu, 24 Sep 2020 13:39:35 +0100 Message-Id: <20200924123937.20938-2-ionela.voinescu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200924123937.20938-1-ionela.voinescu@arm.com> References: <20200924123937.20938-1-ionela.voinescu@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the rebuild_sched_domains_energy() function to wrap the functionality that rebuilds the scheduling domains if any of the Energy Aware Scheduling (EAS) initialisation conditions change. This functionality is used when schedutil is added or removed or when EAS is enabled or disabled through the sched_energy_aware sysctl. Therefore, create a single function that is used in both these cases and that can be later reused. Signed-off-by: Ionela Voinescu Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Rafael J. Wysocki Cc: Viresh Kumar --- include/linux/sched/topology.h | 1 + kernel/sched/cpufreq_schedutil.c | 9 +-------- kernel/sched/topology.c | 19 ++++++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 9ef7bf686a9f..f122115d6c54 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -158,6 +158,7 @@ static inline struct cpumask *sched_domain_span(struct sched_domain *sd) return to_cpumask(sd->span); } +extern void rebuild_sched_domains_energy(void); extern void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], struct sched_domain_attr *dattr_new); diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index e39008242cf4..0337a9b025e1 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -912,16 +912,9 @@ struct cpufreq_governor *cpufreq_default_governor(void) cpufreq_governor_init(schedutil_gov); #ifdef CONFIG_ENERGY_MODEL -extern bool sched_energy_update; -extern struct mutex sched_energy_mutex; - static void rebuild_sd_workfn(struct work_struct *work) { - mutex_lock(&sched_energy_mutex); - sched_energy_update = true; - rebuild_sched_domains(); - sched_energy_update = false; - mutex_unlock(&sched_energy_mutex); + rebuild_sched_domains_energy(); } static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 55c453d140e9..4073f693e2b5 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -211,6 +211,15 @@ unsigned int sysctl_sched_energy_aware = 1; DEFINE_MUTEX(sched_energy_mutex); bool sched_energy_update; +void rebuild_sched_domains_energy(void) +{ + mutex_lock(&sched_energy_mutex); + sched_energy_update = true; + rebuild_sched_domains(); + sched_energy_update = false; + mutex_unlock(&sched_energy_mutex); +} + #ifdef CONFIG_PROC_SYSCTL int sched_energy_aware_handler(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) @@ -223,13 +232,8 @@ int sched_energy_aware_handler(struct ctl_table *table, int write, ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); if (!ret && write) { state = static_branch_unlikely(&sched_energy_present); - if (state != sysctl_sched_energy_aware) { - mutex_lock(&sched_energy_mutex); - sched_energy_update = 1; - rebuild_sched_domains(); - sched_energy_update = 0; - mutex_unlock(&sched_energy_mutex); - } + if (state != sysctl_sched_energy_aware) + rebuild_sched_domains_energy(); } return ret; @@ -433,6 +437,7 @@ static bool build_perf_domains(const struct cpumask *cpu_map) } #else static void free_pd(struct perf_domain *pd) { } +void rebuild_sched_domains_energy(void) { } #endif /* CONFIG_ENERGY_MODEL && CONFIG_CPU_FREQ_GOV_SCHEDUTIL*/ static void free_rootdomain(struct rcu_head *rcu) -- 2.17.1