[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <30dd9cb7-8471-400e-b293-a1a52921a5f3@wanadoo.fr>
Date: Sat, 9 Aug 2025 17:56:49 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: chenridong@...weicloud.com
Cc: bsegall@...gle.com, cgroups@...r.kernel.org, chenridong@...wei.com,
dietmar.eggemann@....com, hannes@...xchg.org, juri.lelli@...hat.com,
linux-kernel@...r.kernel.org, longman@...hat.com, lujialin4@...wei.com,
mgorman@...e.de, mingo@...hat.com, mkoutny@...e.com, peterz@...radead.org,
rostedt@...dmis.org, tj@...nel.org, vincent.guittot@...aro.org,
vschneid@...hat.com
Subject: Re: [PATCH -next 2/4] cpuset: add helpers for cpuset related locks
Le 08/08/2025 à 11:25, Chen Ridong a écrit :
> From: Chen Ridong <chenridong-hv44wF8Li93QT0dZR+AlfA@...lic.gmane.org>
>
> Add guard_cpus_read_and_cpuset and guard_cpuset helpers for cpuset, which
> will be user for subsequent patched to make code concise;
>
> Signed-off-by: Chen Ridong <chenridong-hv44wF8Li93QT0dZR+AlfA@...lic.gmane.org>
> ---
> include/linux/cpuset.h | 1 +
> kernel/cgroup/cpuset-internal.h | 2 ++
> kernel/cgroup/cpuset.c | 11 +++++++++++
> 3 files changed, 14 insertions(+)
>
> diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
> index 2ddb256187b5..6153de28acf0 100644
> --- a/include/linux/cpuset.h
> +++ b/include/linux/cpuset.h
> @@ -74,6 +74,7 @@ extern void inc_dl_tasks_cs(struct task_struct *task);
> extern void dec_dl_tasks_cs(struct task_struct *task);
> extern void cpuset_lock(void);
> extern void cpuset_unlock(void);
> +extern void guard_cpuset(void);
> extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
> extern bool cpuset_cpus_allowed_fallback(struct task_struct *p);
> extern bool cpuset_cpu_is_isolated(int cpu);
> diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h
> index 75b3aef39231..084e19fe33d5 100644
> --- a/kernel/cgroup/cpuset-internal.h
> +++ b/kernel/cgroup/cpuset-internal.h
> @@ -277,6 +277,8 @@ ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
> char *buf, size_t nbytes, loff_t off);
> int cpuset_common_seq_show(struct seq_file *sf, void *v);
>
> +void guard_cpus_read_and_cpuset(void);
> +
> /*
> * cpuset-v1.c
> */
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index cf7cd2255265..f6cdb5cdffe8 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -260,6 +260,17 @@ void cpuset_unlock(void)
> mutex_unlock(&cpuset_mutex);
> }
>
> +void guard_cpuset(void)
> +{
> + guard(mutex)(&cpuset_mutex);
> +}
> +
> +void guard_cpus_read_and_cpuset(void)
> +{
> + guard(cpus_read_lock)();
> + guard(mutex)(&cpuset_mutex);
> +}
> +
Not sure that it works like that.
I think that these 2 functions are just no-op because whatever is
"garded", it will be release when the function exits.
So, if correct, all this serie does is removing some existing
synchronisation mechanism.
Do I miss something obvious?
CJ
> static DEFINE_SPINLOCK(callback_lock);
>
> void cpuset_callback_lock_irq(void)
Powered by blists - more mailing lists