Skip to contentSkip to conversation

change-next_thread-to-use-__next_thread-group_leader.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Oct 4, 2023

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: change next_thread() to use __next_thread() ?: group_leader
has been removed from the -mm tree. Its filename was
change-next_thread-to-use-__next_thread-group_leader.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Oleg Nesterov <[email protected]>
Subject: change next_thread() to use __next_thread() ?: group_leader
Date: Thu, 24 Aug 2023 16:32:01 +0200

This relies on fact that group leader is always the 1st entry in the signal->thread_head list.

With or without this change, if the lockless next_thread(last_thread) races with exec it can return the old or the new leader.

We are almost ready to kill task->thread_group, after this change its only user is thread_group_empty().

---

 include/linux/sched/signal.h |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/linux/sched/signal.h renamed from include/linux/sched/signal.h~change-next_thread-to-use-__next_thread-group_leader +2 -3
@@ -726,10 +726,9 @@ static inline struct task_struct *__next
 					thread_node);
 }
 
-static inline struct task_struct *next_thread(const struct task_struct *p)
+static inline struct task_struct *next_thread(struct task_struct *p)
 {
-	return list_entry_rcu(p->thread_group.next,
-			      struct task_struct, thread_group);
+	return __next_thread(p) ?: p->group_leader;
 }
 
 static inline int thread_group_empty(struct task_struct *p)

_

Patches currently in -mm which might be from [email protected] are