* [PATCH 0/2] kill task_struct->thread_group
@ 2023-08-26 11:12 Oleg Nesterov
2023-08-26 11:14 ` [PATCH 1/2] change thread_group_empty() to use task_struct->thread_node Oleg Nesterov
2023-08-26 11:14 ` [PATCH 2/2] kill task_struct->thread_group Oleg Nesterov
0 siblings, 2 replies; 3+ messages in thread
From: Oleg Nesterov @ 2023-08-26 11:12 UTC (permalink / raw)
To: Andrew Morton; +Cc: Eric W. Biederman, Linus Torvalds, linux-kernel
On top of
[PATCH 0/2] introduce __next_thread(), change next_thread()
https://lore.kernel.org/all/20230824143112.GA31208@redhat.com/
Next: audit the while_each_thread() users.
Oleg.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] change thread_group_empty() to use task_struct->thread_node
2023-08-26 11:12 [PATCH 0/2] kill task_struct->thread_group Oleg Nesterov
@ 2023-08-26 11:14 ` Oleg Nesterov
2023-08-26 11:14 ` [PATCH 2/2] kill task_struct->thread_group Oleg Nesterov
1 sibling, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2023-08-26 11:14 UTC (permalink / raw)
To: Andrew Morton; +Cc: Eric W. Biederman, Linus Torvalds, linux-kernel
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.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
include/linux/sched/signal.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index cffc882d367f..d7fa3ca2fa53 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -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) \
--
2.25.1.362.g51ebf55
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] kill task_struct->thread_group
2023-08-26 11:12 [PATCH 0/2] kill task_struct->thread_group Oleg Nesterov
2023-08-26 11:14 ` [PATCH 1/2] change thread_group_empty() to use task_struct->thread_node Oleg Nesterov
@ 2023-08-26 11:14 ` Oleg Nesterov
1 sibling, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2023-08-26 11:14 UTC (permalink / raw)
To: Andrew Morton; +Cc: Eric W. Biederman, Linus Torvalds, linux-kernel
The last user was removed by the previous patch.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
include/linux/sched.h | 1 -
init/init_task.c | 1 -
kernel/exit.c | 1 -
kernel/fork.c | 3 ---
4 files changed, 6 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 609bde814cb0..2b012d446cad 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -997,7 +997,6 @@ struct task_struct {
/* PID/PID hash table linkage. */
struct pid *thread_pid;
struct hlist_node pid_links[PIDTYPE_MAX];
- struct list_head thread_group;
struct list_head thread_node;
struct completion *vfork_done;
diff --git a/init/init_task.c b/init/init_task.c
index ff6c4b9bfe6b..c0de0200fd56 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -132,7 +132,6 @@ struct task_struct init_task
.pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock),
.timer_slack_ns = 50000, /* 50 usec default slack */
.thread_pid = &init_struct_pid,
- .thread_group = LIST_HEAD_INIT(init_task.thread_group),
.thread_node = LIST_HEAD_INIT(init_signals.thread_head),
#ifdef CONFIG_AUDIT
.loginuid = INVALID_UID,
diff --git a/kernel/exit.c b/kernel/exit.c
index edb50b4c9972..f3ba4b97a7d9 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -133,7 +133,6 @@ static void __unhash_process(struct task_struct *p, bool group_dead)
list_del_init(&p->sibling);
__this_cpu_dec(process_counts);
}
- list_del_rcu(&p->thread_group);
list_del_rcu(&p->thread_node);
}
diff --git a/kernel/fork.c b/kernel/fork.c
index d2e12b6d2b18..3cd6913a90ef 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2579,7 +2579,6 @@ __latent_entropy struct task_struct *copy_process(
p->dirty_paused_when = 0;
p->pdeath_signal = 0;
- INIT_LIST_HEAD(&p->thread_group);
p->task_works = NULL;
clear_posix_cputimers_work(p);
@@ -2707,8 +2706,6 @@ __latent_entropy struct task_struct *copy_process(
atomic_inc(¤t->signal->live);
refcount_inc(¤t->signal->sigcnt);
task_join_group_stop(p);
- list_add_tail_rcu(&p->thread_group,
- &p->group_leader->thread_group);
list_add_tail_rcu(&p->thread_node,
&p->signal->thread_head);
}
--
2.25.1.362.g51ebf55
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-26 11:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-26 11:12 [PATCH 0/2] kill task_struct->thread_group Oleg Nesterov
2023-08-26 11:14 ` [PATCH 1/2] change thread_group_empty() to use task_struct->thread_node Oleg Nesterov
2023-08-26 11:14 ` [PATCH 2/2] kill task_struct->thread_group Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox