Re: [PATCH] cgroup: Remove redundant rcu_read_lock() in spin_lock_irq() section
From: Chen Ridong
Date: Fri Aug 15 2025 - 06:31:01 EST
On 2025/8/15 17:14, lirongqing wrote:
> From: Li RongQing <lirongqing@xxxxxxxxx>
>
> Since spin_lock_irq() already disables preemption and task_css_set()
> is protected by css_set_lock, the rcu_read_lock() calls are unnecessary
> within the critical section. Remove them to simplify the code.
>
> Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx>
> ---
> kernel/cgroup/cgroup.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 312c6a8..db9e00a 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -2944,14 +2944,12 @@ int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
>
> /* look up all src csets */
> spin_lock_irq(&css_set_lock);
> - rcu_read_lock();
> task = leader;
> do {
> cgroup_migrate_add_src(task_css_set(task), dst_cgrp, &mgctx);
> if (!threadgroup)
> break;
> } while_each_thread(leader, task);
> - rcu_read_unlock();
> spin_unlock_irq(&css_set_lock);
>
> /* prepare dst csets and commit */
LGTM
--
Best regards,
Ridong