Skip to contentSkip to conversation

decrease tsk->signal->live before profile_task_exit

RFC In review liuchao 2 participants 2 messages May 28, 2020 – May 29, 2020

lore
Share & tools
lore

liuchao

author
#0 lore raw

RFC 1/1 decrease tsk->signal->live before profile_task_exit

I want to dermine which thread is the last one to enter do_exit in profile_task_exit. But when a lot of threads exit, tsk->signal->live is not correct since it decrease after profile_task_exit.

---
 kernel/exit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/exit.c +1 -1
index ce2a75bc0ade..1693764bc356 100644
@@ -708,6 +708,7 @@ void __noreturn do_exit(long code)
 	struct task_struct *tsk = current;
 	int group_dead;
 
+	group_dead = atomic_dec_and_test(&tsk->signal->live);
 	profile_task_exit(tsk);
 	kcov_task_exit(tsk);
 
@@ -755,7 +756,6 @@ void __noreturn do_exit(long code)
 	if (tsk->mm)
 		sync_mm_rss(tsk->mm);
 	acct_update_integrals(tsk);
-	group_dead = atomic_dec_and_test(&tsk->signal->live);
 	if (group_dead) {
 		/*
 		 * If the last thread of global init has exited, panic
Signature · 1 line
2.19.1
#1 lore raw
Quoted 4 lines · liuchao

I want to dermine which thread is the last one to enter do_exit in profile_task_exit. But when a lot of threads exit, tsk->signal->live is not correct since it decrease after profile_task_exit.

I don't think that would be wise.

Any additional code before the sanity checks at the start of do_exit seems like a bad idea.

We could probably move the decrement of tsk->signal->live a little earlier, but not that much earlier in the function.

Does profile_task_exit even make sense that early in the code? If the code is doing much of anything that is a completely inappopriate placement of profile_task_exit.

Eric

Quoted 25 lines
---
 kernel/exit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/exit.c +1 -1
index ce2a75bc0ade..1693764bc356 100644
@@ -708,6 +708,7 @@ void __noreturn do_exit(long code)
 	struct task_struct *tsk = current;
 	int group_dead;
 
+	group_dead = atomic_dec_and_test(&tsk->signal->live);
 	profile_task_exit(tsk);
 	kcov_task_exit(tsk);
 
@@ -755,7 +756,6 @@ void __noreturn do_exit(long code)
 	if (tsk->mm)
 		sync_mm_rss(tsk->mm);
 	acct_update_integrals(tsk);
-	group_dead = atomic_dec_and_test(&tsk->signal->live);
 	if (group_dead) {
 		/*
 		 * If the last thread of global init has exited, panic