mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next v2] cgroup: Update out-of-date comment in cgroup_migrate()
@ 2023-05-24  6:54 Xiu Jianfeng
  2023-05-24 22:23 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Xiu Jianfeng @ 2023-05-24  6:54 UTC (permalink / raw)
  To: tj, lizefan.x, hannes; +Cc: cgroups, linux-kernel

Commit 674b745e22b3 ("cgroup: remove rcu_read_lock()/rcu_read_unlock()
in critical section of spin_lock_irq()") has removed the rcu_read_lock,
which makes the comment out-of-date, so update it.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
v2: don't remove the comment, just update it.
---
 kernel/cgroup/cgroup.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index d8ba2c67910d..f10cef511ffa 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2872,9 +2872,11 @@ int cgroup_migrate(struct task_struct *leader, bool threadgroup,
 	struct task_struct *task;
 
 	/*
-	 * Prevent freeing of tasks while we take a snapshot. Tasks that are
-	 * already PF_EXITING could be freed from underneath us unless we
-	 * take an rcu_read_lock.
+	 * We should take an rcu_read_lock to prevent freeing of tasks while
+	 * taking a snapshot, because tasks that are already PF_EXITING could
+	 * be freed when traversing all threads of leader. However rcu_read_lock
+	 * which disable preempt is implied by the spin_lock_irq, so no explicit
+	 * rcu call here.
 	 */
 	spin_lock_irq(&css_set_lock);
 	task = leader;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH -next v2] cgroup: Update out-of-date comment in cgroup_migrate()
  2023-05-24  6:54 [PATCH -next v2] cgroup: Update out-of-date comment in cgroup_migrate() Xiu Jianfeng
@ 2023-05-24 22:23 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2023-05-24 22:23 UTC (permalink / raw)
  To: Xiu Jianfeng; +Cc: lizefan.x, hannes, cgroups, linux-kernel

Hello,

I further edited the comment and applied the patch to cgroup/for-6.5

Thanks.

From 659db0789c2e66c5d6a52d57008e3a7401a3ffff Mon Sep 17 00:00:00 2001
From: Xiu Jianfeng <xiujianfeng@huaweicloud.com>
Date: Wed, 24 May 2023 14:54:31 +0800
Subject: [PATCH] cgroup: Update out-of-date comment in cgroup_migrate()

Commit 674b745e22b3 ("cgroup: remove rcu_read_lock()/rcu_read_unlock()
in critical section of spin_lock_irq()") has removed the rcu_read_lock,
which makes the comment out-of-date, so update it.

tj: Updated the comment a bit.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/cgroup/cgroup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 9d809191a54f..f329f49529a2 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2872,9 +2872,9 @@ int cgroup_migrate(struct task_struct *leader, bool threadgroup,
 	struct task_struct *task;
 
 	/*
-	 * Prevent freeing of tasks while we take a snapshot. Tasks that are
-	 * already PF_EXITING could be freed from underneath us unless we
-	 * take an rcu_read_lock.
+	 * The following thread iteration should be inside an RCU critical
+	 * section to prevent tasks from being freed while taking the snapshot.
+	 * spin_lock_irq() implies RCU critical section here.
 	 */
 	spin_lock_irq(&css_set_lock);
 	task = leader;
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-24 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24  6:54 [PATCH -next v2] cgroup: Update out-of-date comment in cgroup_migrate() Xiu Jianfeng
2023-05-24 22:23 ` 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®