From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Juri Lelli <juri.lelli@redhat.com>,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Cc: "Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"Waiman Long" <longman@redhat.com>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Qais Yousef" <qyousef@layalina.io>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Swapnil Sapkal" <swapnil.sapkal@amd.com>,
"Phil Auld" <pauld@redhat.com>,
luca.abeni@santannapisa.it, tommaso.cucinotta@santannapisa.it,
"Jon Hunter" <jonathanh@nvidia.com>
Subject: Re: [PATCH v2 2/8] sched/topology: Wrappers for sched_domains_mutex
Date: Fri, 7 Mar 2025 12:04:29 +0530 [thread overview]
Message-ID: <6894861a-4a40-4c6d-8f48-997b999f5778@linux.ibm.com> (raw)
In-Reply-To: <20250306141016.268313-3-juri.lelli@redhat.com>
Hi Juri.
On 3/6/25 19:40, Juri Lelli wrote:
> Create wrappers for sched_domains_mutex so that it can transparently be
> used on both CONFIG_SMP and !CONFIG_SMP, as some function will need to
> do.
>
> Reported-by: Jon Hunter <jonathanh@nvidia.com>
> Fixes: 53916d5fd3c0 ("sched/deadline: Check bandwidth overflow earlier for hotplug")
> Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
> ---
> v1 -> v2: Remove wrappers for the !SMP case as all users are not defined
> either in that case
> ---
> include/linux/sched.h | 2 ++
> kernel/cgroup/cpuset.c | 4 ++--
> kernel/sched/core.c | 4 ++--
> kernel/sched/debug.c | 8 ++++----
> kernel/sched/topology.c | 12 ++++++++++--
> 5 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 9632e3318e0d..d5f8c161d852 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -383,6 +383,8 @@ enum uclamp_id {
> extern struct root_domain def_root_domain;
> extern struct mutex sched_domains_mutex;
> #endif
> +extern void sched_domains_mutex_lock(void);
> +extern void sched_domains_mutex_unlock(void);
>
> struct sched_param {
> int sched_priority;
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 0f910c828973..f87526edb2a4 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -994,10 +994,10 @@ static void
> partition_and_rebuild_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
> struct sched_domain_attr *dattr_new)
> {
> - mutex_lock(&sched_domains_mutex);
> + sched_domains_mutex_lock();
> partition_sched_domains_locked(ndoms_new, doms_new, dattr_new);
> dl_rebuild_rd_accounting();
> - mutex_unlock(&sched_domains_mutex);
> + sched_domains_mutex_unlock();
> }
>
> /*
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 67189907214d..58593f4d09a1 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8424,9 +8424,9 @@ void __init sched_init_smp(void)
> * CPU masks are stable and all blatant races in the below code cannot
> * happen.
> */
> - mutex_lock(&sched_domains_mutex);
> + sched_domains_mutex_lock();
> sched_init_domains(cpu_active_mask);
> - mutex_unlock(&sched_domains_mutex);
> + sched_domains_mutex_unlock();
>
> /* Move init over to a non-isolated CPU */
> if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_TYPE_DOMAIN)) < 0)
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index ef047add7f9e..a0893a483d35 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -292,7 +292,7 @@ static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
> bool orig;
>
> cpus_read_lock();
> - mutex_lock(&sched_domains_mutex);
> + sched_domains_mutex_lock();
>
> orig = sched_debug_verbose;
> result = debugfs_write_file_bool(filp, ubuf, cnt, ppos);
> @@ -304,7 +304,7 @@ static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
> sd_dentry = NULL;
> }
>
> - mutex_unlock(&sched_domains_mutex);
> + sched_domains_mutex_unlock();
> cpus_read_unlock();
>
> return result;
> @@ -515,9 +515,9 @@ static __init int sched_init_debug(void)
> debugfs_create_u32("migration_cost_ns", 0644, debugfs_sched, &sysctl_sched_migration_cost);
> debugfs_create_u32("nr_migrate", 0644, debugfs_sched, &sysctl_sched_nr_migrate);
>
> - mutex_lock(&sched_domains_mutex);
> + sched_domains_mutex_lock();
> update_sched_domain_debugfs();
> - mutex_unlock(&sched_domains_mutex);
> + sched_domains_mutex_unlock();
> #endif
>
> #ifdef CONFIG_NUMA_BALANCING
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index c49aea8c1025..296ff2acfd32 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -6,6 +6,14 @@
> #include <linux/bsearch.h>
>
> DEFINE_MUTEX(sched_domains_mutex);
> +void sched_domains_mutex_lock(void)
> +{
> + mutex_lock(&sched_domains_mutex);
> +}
> +void sched_domains_mutex_unlock(void)
> +{
> + mutex_unlock(&sched_domains_mutex);
> +}
>
> /* Protected by sched_domains_mutex: */
> static cpumask_var_t sched_domains_tmpmask;
> @@ -2791,7 +2799,7 @@ void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[],
> void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
> struct sched_domain_attr *dattr_new)
> {
> - mutex_lock(&sched_domains_mutex);
> + sched_domains_mutex_lock();
> partition_sched_domains_locked(ndoms_new, doms_new, dattr_new);
> - mutex_unlock(&sched_domains_mutex);
> + sched_domains_mutex_unlock();
> }
Maybe sched_domains_mutex can be static since its only used in topology.c ?
Other than the above
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
next prev parent reply other threads:[~2025-03-07 6:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 14:10 [PATCH v2 0/8] Fix SCHED_DEADLINE bandwidth accounting during suspend Juri Lelli
2025-03-06 14:10 ` [PATCH v2 1/8] sched/deadline: Ignore special tasks when rebuilding domains Juri Lelli
2025-03-06 14:10 ` [PATCH v2 2/8] sched/topology: Wrappers for sched_domains_mutex Juri Lelli
2025-03-07 6:34 ` Shrikanth Hegde [this message]
2025-03-07 8:53 ` Juri Lelli
2025-03-07 9:02 ` Shrikanth Hegde
2025-03-07 15:11 ` Waiman Long
2025-03-07 15:15 ` Juri Lelli
2025-03-07 15:19 ` Waiman Long
2025-03-07 15:59 ` Juri Lelli
2025-03-07 16:34 ` Waiman Long
2025-03-06 14:10 ` [PATCH v2 3/8] sched/deadline: Generalize unique visiting of root domains Juri Lelli
2025-03-07 5:36 ` Shrikanth Hegde
2025-03-07 8:55 ` Juri Lelli
2025-03-06 14:10 ` [PATCH v2 4/8] sched/deadline: Rebuild root domain accounting after every update Juri Lelli
2025-03-07 6:33 ` Shrikanth Hegde
2025-03-07 9:33 ` Juri Lelli
2025-03-07 7:32 ` Shrikanth Hegde
2025-03-07 8:59 ` Juri Lelli
2025-03-06 14:10 ` [PATCH v2 5/8] sched/topology: Remove redundant dl_clear_root_domain call Juri Lelli
2025-03-06 14:10 ` [PATCH v2 6/8] cgroup/cpuset: Remove partition_and_rebuild_sched_domains Juri Lelli
2025-03-07 7:40 ` Shrikanth Hegde
2025-03-07 15:14 ` Waiman Long
2025-03-07 15:16 ` Waiman Long
2025-03-06 14:10 ` [PATCH v2 7/8] sched/topology: Stop exposing partition_sched_domains_locked Juri Lelli
2025-03-06 14:10 ` [PATCH v2 8/8] include/{topology,cpuset}: Move dl_rebuild_rd_accounting to cpuset.h Juri Lelli
2025-03-07 15:17 ` Waiman Long
2025-03-07 11:40 ` [PATCH v2 0/8] Fix SCHED_DEADLINE bandwidth accounting during suspend Jon Hunter
2025-03-07 15:16 ` Juri Lelli
2025-03-07 19:00 ` Waiman Long
2025-03-10 8:55 ` Juri Lelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6894861a-4a40-4c6d-8f48-997b999f5778@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=bigeasy@linutronix.de \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=jonathanh@nvidia.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=luca.abeni@santannapisa.it \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=pauld@redhat.com \
--cc=peterz@infradead.org \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--cc=swapnil.sapkal@amd.com \
--cc=tj@kernel.org \
--cc=tommaso.cucinotta@santannapisa.it \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox