Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90ed9cbe authored by Rik van Riel's avatar Rik van Riel Committed by Ingo Molnar
Browse files

exit: Always reap resource stats in __exit_signal()



Oleg pointed out that wait_task_zombie adds a task's usage statistics
to the parent's signal struct, but the task's own signal struct should
also propagate the statistics at exit time.

This allows thread_group_cputime(reaped_zombie) to get the statistics
after __unhash_process() has made the task invisible to for_each_thread,
but before the thread has actually been rcu freed, making sure no
non-monotonic results are returned inside that window.

Suggested-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarRik van Riel <riel@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Guillaume Morin <guillaume@morinfr.org>
Cc: Ionut Alexa <ionut.m.alexa@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Michal Schmidt <mschmidt@redhat.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: umgwanakikbuti@gmail.com
Cc: fweisbec@gmail.com
Cc: srao@redhat.com
Cc: lwoodman@redhat.com
Cc: atheurer@redhat.com
Link: http://lkml.kernel.org/r/1408133138-22048-2-git-send-email-riel@redhat.com


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e2627dce
Loading
Loading
Loading
Loading
+21 −22
Original line number Diff line number Diff line
@@ -115,15 +115,16 @@ static void __exit_signal(struct task_struct *tsk)

		if (tsk == sig->curr_target)
			sig->curr_target = next_thread(tsk);
	}

	/*
		 * Accumulate here the counters for all threads but the
		 * group leader as they die, so they can be added into
		 * the process-wide totals when those are taken.
		 * The group leader stays around as a zombie as long
		 * as there are other threads.  When it gets reaped,
		 * the exit.c code will add its counts into these totals.
		 * We won't ever get here for the group leader, since it
		 * will have been the last reference on the signal_struct.
	 * Accumulate here the counters for all threads but the group leader
	 * as they die, so they can be added into the process-wide totals
	 * when those are taken.  The group leader stays around as a zombie as
	 * long as there are other threads.  When it gets reaped, the exit.c
	 * code will add its counts into these totals.  We won't ever get here
	 * for the group leader, since it will have been the last reference on
	 * the signal_struct.
	 */
	task_cputime(tsk, &utime, &stime);
	sig->utime += utime;
@@ -137,8 +138,6 @@ static void __exit_signal(struct task_struct *tsk)
	sig->oublock += task_io_get_oublock(tsk);
	task_io_accounting_add(&sig->ioac, &tsk->ioac);
	sig->sum_sched_runtime += tsk->se.sum_exec_runtime;
	}

	sig->nr_threads--;
	__unhash_process(tsk, group_dead);