diff options
| author | Oleg Nesterov <[email protected]> | 2023-08-23 17:08:06 +0000 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2023-08-24 23:25:15 +0000 |
| commit | dce8f8ed1de1d9d6d27c5ccd202ce4ec163b100c (patch) | |
| tree | 93e6156402383138221d53cb0937d28cefa97cf0 /fs/proc/base.c | |
| parent | drivers/char/mem.c: shrink character device's devlist[] array (diff) | |
| download | kernel-dce8f8ed1de1d9d6d27c5ccd202ce4ec163b100c.tar.gz kernel-dce8f8ed1de1d9d6d27c5ccd202ce4ec163b100c.zip | |
document while_each_thread(), change first_tid() to use for_each_thread()
Add the comment to explain that while_each_thread(g,t) is not rcu-safe
unless g is stable (e.g. current). Even if g is a group leader and thus
can't exit before t, t or another sub-thread can exec and remove g from
the thread_group list.
The only lockless user of while_each_thread() is first_tid() and it is
fine in that it can't loop forever, yet for_each_thread() looks better and
I am going to change while_each_thread/next_thread.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'fs/proc/base.c')
| -rw-r--r-- | fs/proc/base.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 05452c3b9872..483a3edebdd1 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -3813,11 +3813,10 @@ static struct task_struct *first_tid(struct pid *pid, int tid, loff_t f_pos, /* If we haven't found our starting place yet start * with the leader and walk nr threads forward. */ - pos = task = task->group_leader; - do { + for_each_thread(task, pos) { if (!nr--) goto found; - } while_each_thread(task, pos); + }; fail: pos = NULL; goto out; |
