linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] decrease tsk->signal->live before profile_task_exit
@ 2020-05-28  4:09 liuchao
  2020-05-29 18:01 ` Eric W. Biederman
  0 siblings, 1 reply; 3+ messages in thread
From: liuchao @ 2020-05-28  4:09 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel, hushiyuan, hewenliang4, 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.

Signed-off-by: liuchao <liuchao173@huawei.com>
---
 kernel/exit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index ce2a75bc0ade..1693764bc356 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -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
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC] decrease tsk->signal->live before profile_task_exit
  2020-05-28  4:09 [RFC] decrease tsk->signal->live before profile_task_exit liuchao
@ 2020-05-29 18:01 ` Eric W. Biederman
  0 siblings, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2020-05-29 18:01 UTC (permalink / raw)
  To: liuchao; +Cc: mingo, tglx, linux-kernel, hushiyuan, hewenliang4

liuchao <liuchao173@huawei.com> writes:

> 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


> Signed-off-by: liuchao <liuchao173@huawei.com>
> ---
>  kernel/exit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index ce2a75bc0ade..1693764bc356 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] decrease tsk->signal->live before profile_task_exit
@ 2020-06-09  2:30 liuchao (CR)
  0 siblings, 0 replies; 3+ messages in thread
From: liuchao (CR) @ 2020-06-09  2:30 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: mingo, tglx, linux-kernel, Hushiyuan, hewenliang (C)

Eric W. Biederman <mailto:ebiederm@xmission.com> writes:

> liuchao <liuchao173@huawei.com> writes:
> 
> > 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.

I think so too.

Move the decrement of tsk->signal->live after the sanity checks, then
profile_task_exit and kcov_task_exit make more sense.

> 
> Eric
> 
> 
> > Signed-off-by: liuchao <liuchao173@huawei.com>
> > ---
> >  kernel/exit.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/exit.c b/kernel/exit.c index
> > ce2a75bc0ade..1693764bc356 100644
> > --- a/kernel/exit.c
> > +++ b/kernel/exit.c
> > @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-09  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28  4:09 [RFC] decrease tsk->signal->live before profile_task_exit liuchao
2020-05-29 18:01 ` Eric W. Biederman
2020-06-09  2:30 liuchao (CR)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).