* [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers
@ 2024-07-26 1:05 Chen Ridong
2024-07-26 10:32 ` Kamalesh Babulal
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Chen Ridong @ 2024-07-26 1:05 UTC (permalink / raw)
To: tj, lizefan.x, hannes, longman, adityakali, sergeh, mkoutny
Cc: cgroups, linux-kernel
There are several functions to decrease attach_in_progress, and they
will wake up cpuset_attach_wq when attach_in_progress is zero. So,
add a helper to make it concise.
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
kernel/cgroup/cpuset.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index d4322619e59a..fa0c2fc5d383 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -490,6 +490,26 @@ static inline void check_insane_mems_config(nodemask_t *nodes)
}
}
+/*
+ * decrease cs->attach_in_progress.
+ * wake_up cpuset_attach_wq if cs->attach_in_progress==0.
+ */
+static inline void dec_attach_in_progress_locked(struct cpuset *cs)
+{
+ lockdep_assert_held(&cpuset_mutex);
+
+ cs->attach_in_progress--;
+ if (!cs->attach_in_progress)
+ wake_up(&cpuset_attach_wq);
+}
+
+static inline void dec_attach_in_progress(struct cpuset *cs)
+{
+ mutex_lock(&cpuset_mutex);
+ dec_attach_in_progress_locked(cs);
+ mutex_unlock(&cpuset_mutex);
+}
+
/*
* Cgroup v2 behavior is used on the "cpus" and "mems" control files when
* on default hierarchy or when the cpuset_v2_mode flag is set by mounting
@@ -3421,9 +3441,7 @@ static void cpuset_cancel_attach(struct cgroup_taskset *tset)
cs = css_cs(css);
mutex_lock(&cpuset_mutex);
- cs->attach_in_progress--;
- if (!cs->attach_in_progress)
- wake_up(&cpuset_attach_wq);
+ dec_attach_in_progress_locked(cs);
if (cs->nr_migrate_dl_tasks) {
int cpu = cpumask_any(cs->effective_cpus);
@@ -3538,9 +3556,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)
reset_migrate_dl_data(cs);
}
- cs->attach_in_progress--;
- if (!cs->attach_in_progress)
- wake_up(&cpuset_attach_wq);
+ dec_attach_in_progress_locked(cs);
mutex_unlock(&cpuset_mutex);
}
@@ -4283,11 +4299,7 @@ static void cpuset_cancel_fork(struct task_struct *task, struct css_set *cset)
if (same_cs)
return;
- mutex_lock(&cpuset_mutex);
- cs->attach_in_progress--;
- if (!cs->attach_in_progress)
- wake_up(&cpuset_attach_wq);
- mutex_unlock(&cpuset_mutex);
+ dec_attach_in_progress(cs);
}
/*
@@ -4319,10 +4331,7 @@ static void cpuset_fork(struct task_struct *task)
guarantee_online_mems(cs, &cpuset_attach_nodemask_to);
cpuset_attach_task(cs, task);
- cs->attach_in_progress--;
- if (!cs->attach_in_progress)
- wake_up(&cpuset_attach_wq);
-
+ dec_attach_in_progress_locked(cs);
mutex_unlock(&cpuset_mutex);
}
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers
2024-07-26 1:05 [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers Chen Ridong
@ 2024-07-26 10:32 ` Kamalesh Babulal
2024-07-26 19:58 ` Waiman Long
2024-07-30 22:41 ` Tejun Heo
2 siblings, 0 replies; 4+ messages in thread
From: Kamalesh Babulal @ 2024-07-26 10:32 UTC (permalink / raw)
To: Chen Ridong, tj, lizefan.x, hannes, longman, adityakali, sergeh, mkoutny
Cc: cgroups, linux-kernel
On 7/26/24 6:35 AM, Chen Ridong wrote:
> There are several functions to decrease attach_in_progress, and they
> will wake up cpuset_attach_wq when attach_in_progress is zero. So,
> add a helper to make it concise.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
Looks good to me.
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers
2024-07-26 1:05 [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers Chen Ridong
2024-07-26 10:32 ` Kamalesh Babulal
@ 2024-07-26 19:58 ` Waiman Long
2024-07-30 22:41 ` Tejun Heo
2 siblings, 0 replies; 4+ messages in thread
From: Waiman Long @ 2024-07-26 19:58 UTC (permalink / raw)
To: Chen Ridong, tj, lizefan.x, hannes, adityakali, sergeh, mkoutny
Cc: cgroups, linux-kernel
On 7/25/24 21:05, Chen Ridong wrote:
> There are several functions to decrease attach_in_progress, and they
> will wake up cpuset_attach_wq when attach_in_progress is zero. So,
> add a helper to make it concise.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 39 ++++++++++++++++++++++++---------------
> 1 file changed, 24 insertions(+), 15 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index d4322619e59a..fa0c2fc5d383 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -490,6 +490,26 @@ static inline void check_insane_mems_config(nodemask_t *nodes)
> }
> }
>
> +/*
> + * decrease cs->attach_in_progress.
> + * wake_up cpuset_attach_wq if cs->attach_in_progress==0.
> + */
> +static inline void dec_attach_in_progress_locked(struct cpuset *cs)
> +{
> + lockdep_assert_held(&cpuset_mutex);
> +
> + cs->attach_in_progress--;
> + if (!cs->attach_in_progress)
> + wake_up(&cpuset_attach_wq);
> +}
> +
> +static inline void dec_attach_in_progress(struct cpuset *cs)
> +{
> + mutex_lock(&cpuset_mutex);
> + dec_attach_in_progress_locked(cs);
> + mutex_unlock(&cpuset_mutex);
> +}
> +
> /*
> * Cgroup v2 behavior is used on the "cpus" and "mems" control files when
> * on default hierarchy or when the cpuset_v2_mode flag is set by mounting
> @@ -3421,9 +3441,7 @@ static void cpuset_cancel_attach(struct cgroup_taskset *tset)
> cs = css_cs(css);
>
> mutex_lock(&cpuset_mutex);
> - cs->attach_in_progress--;
> - if (!cs->attach_in_progress)
> - wake_up(&cpuset_attach_wq);
> + dec_attach_in_progress_locked(cs);
>
> if (cs->nr_migrate_dl_tasks) {
> int cpu = cpumask_any(cs->effective_cpus);
> @@ -3538,9 +3556,7 @@ static void cpuset_attach(struct cgroup_taskset *tset)
> reset_migrate_dl_data(cs);
> }
>
> - cs->attach_in_progress--;
> - if (!cs->attach_in_progress)
> - wake_up(&cpuset_attach_wq);
> + dec_attach_in_progress_locked(cs);
>
> mutex_unlock(&cpuset_mutex);
> }
> @@ -4283,11 +4299,7 @@ static void cpuset_cancel_fork(struct task_struct *task, struct css_set *cset)
> if (same_cs)
> return;
>
> - mutex_lock(&cpuset_mutex);
> - cs->attach_in_progress--;
> - if (!cs->attach_in_progress)
> - wake_up(&cpuset_attach_wq);
> - mutex_unlock(&cpuset_mutex);
> + dec_attach_in_progress(cs);
> }
>
> /*
> @@ -4319,10 +4331,7 @@ static void cpuset_fork(struct task_struct *task)
> guarantee_online_mems(cs, &cpuset_attach_nodemask_to);
> cpuset_attach_task(cs, task);
>
> - cs->attach_in_progress--;
> - if (!cs->attach_in_progress)
> - wake_up(&cpuset_attach_wq);
> -
> + dec_attach_in_progress_locked(cs);
> mutex_unlock(&cpuset_mutex);
> }
>
Reviewed-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers
2024-07-26 1:05 [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers Chen Ridong
2024-07-26 10:32 ` Kamalesh Babulal
2024-07-26 19:58 ` Waiman Long
@ 2024-07-30 22:41 ` Tejun Heo
2 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2024-07-30 22:41 UTC (permalink / raw)
To: Chen Ridong
Cc: lizefan.x, hannes, longman, adityakali, sergeh, mkoutny, cgroups,
linux-kernel
On Fri, Jul 26, 2024 at 01:05:02AM +0000, Chen Ridong wrote:
> There are several functions to decrease attach_in_progress, and they
> will wake up cpuset_attach_wq when attach_in_progress is zero. So,
> add a helper to make it concise.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
Applied to cgroup/for-6.12.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-30 22:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-26 1:05 [PATCH v2 -next] cgroup/cpuset: add decrease attach_in_progress helpers Chen Ridong
2024-07-26 10:32 ` Kamalesh Babulal
2024-07-26 19:58 ` Waiman Long
2024-07-30 22:41 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®