summaryrefslogtreecommitdiff
path: root/include/linux/sched/signal.h
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2023-08-23 19:08:06 +0200
committerAndrew Morton <akpm@linux-foundation.org>2023-08-24 16:25:15 -0700
commitdce8f8ed1de1d9d6d27c5ccd202ce4ec163b100c (patch)
tree93e6156402383138221d53cb0937d28cefa97cf0 /include/linux/sched/signal.h
parented1af26cd24811c3ddb5e7a276e3c6362c989bba (diff)
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/20230823170806.GA11724@redhat.com Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux/sched/signal.h')
-rw-r--r--include/linux/sched/signal.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 0deebe2ab07d..0014d3adaf84 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -648,6 +648,10 @@ extern void flush_itimer_signals(void);
extern bool current_is_single_threaded(void);
+/*
+ * Without tasklist/siglock it is only rcu-safe if g can't exit/exec,
+ * otherwise next_thread(t) will never reach g after list_del_rcu(g).
+ */
#define while_each_thread(g, t) \
while ((t = next_thread(t)) != g)