Messages in this thread Patch in this message | | | Date | Tue, 10 Nov 2009 11:44:56 +0100 | From | Stanislaw Gruszka <> | Subject | Re: utime/stime decreasing on thread exit |
| |
On Mon, Nov 09, 2009 at 08:23:55PM +0100, Oleg Nesterov wrote: > On 11/09, Peter Zijlstra wrote: > > > > On Mon, 2009-11-09 at 18:20 +0100, Oleg Nesterov wrote: > > > > > Stanislaw has already sent the patch, but I don't know what happened > > > with this patch: > > > > > > [PATCH 1/2] posix-cpu-timers: avoid do_sys_times() races with __exit_signal() > > > http://marc.info/?l=linux-kernel&m=124505545131145
I did not resubmit it enough times :) But I didn't thought it worth to, since performance can be degraded.
> > That patch has the siglock in the function calling > > thread_group_cputime(), the 22 code had it near the loop proper, which > > to me seems a more sensible thing, since there could be more callers, > > no? > > Well, we can't take ->siglock in thread_group_cputime(), sometimes it > is called under ->siglock. do_task_stat(), get_cpu_itimer() at least. > > IIRC, Stanislaw verified other callers have no problems with this helper.
Actually I didn't. Try to do now.
Most calls are done with sighand or tasklist lock taken, except
Cscope tag: thread_group_cputime # line filename / context / line 1 1353 fs/binfmt_elf.c <<fill_prstatus>> thread_group_cputime(p, &cputime); 2 1403 fs/binfmt_elf_fdpic.c <<fill_prstatus>> thread_group_cputime(p, &cputime); 10 129 mm/oom_kill.c <<badness>> thread_group_cputime(p, &task_time);
I do not think in case 1 and 2 lock is needed since it seems to be core dump with all threads dead. Not sure about 10 - oom killer.
One other exception is: fastpath_timer_check() -> thread_group_cputimer() -> thread_group_cputime()
We can solve this like that:
--- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c @@ -1375,13 +1375,8 @@ static inline int fastpath_timer_check(struct task_struct *tsk) } sig = tsk->signal; - if (!task_cputime_zero(&sig->cputime_expires)) { - struct task_cputime group_sample; - - thread_group_cputimer(tsk, &group_sample); - if (task_cputime_expired(&group_sample, &sig->cputime_expires)) - return 1; - } + if (!task_cputime_zero(&sig->cputime_expires)) + return 1; return sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY; } Or stay with task_cputime_expired() but only if cputimer is currently running.
Cheers Stanislaw
| |