change thread_group_empty() to use task_struct->thread_node
authorOleg Nesterov <oleg@redhat.com>
Sat, 26 Aug 2023 11:14:06 +0000 (13:14 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Oct 2023 17:41:56 +0000 (10:41 -0700)
Patch series "kill task_struct->thread_group".

This patch (of 2):

It could use list_is_singular() but this way it is cheaper.  Plus the
thread_group_leader() check makes it clear that thread_group_empty() can
only return true if p is a group leader.  This was not immediately obvious
before this patch.

task_struct->thread_group no longer has users, it can die.

Link: https://lkml.kernel.org/r/20230826111200.GA22982@redhat.com
Link: https://lkml.kernel.org/r/20230826111406.GA23238@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/sched/signal.h

index cffc882d367f5c39329602fd8a3d666605ae1b32..d7fa3ca2fa5326ebd6cf2322b49256ba35fbdc5e 100644 (file)
@@ -733,7 +733,8 @@ static inline struct task_struct *next_thread(struct task_struct *p)
 
 static inline int thread_group_empty(struct task_struct *p)
 {
-       return list_empty(&p->thread_group);
+       return thread_group_leader(p) &&
+              list_is_last(&p->thread_node, &p->signal->thread_head);
 }
 
 #define delay_group_leader(p) \