Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

Oleg Nesterov
2014-08-14T14:26:36Z

On 08/13, Rik van Riel wrote:
>
> @@ -862,11 +862,9 @@ void do_sys_times(struct tms *tms)
> {
> cputime_t tgutime, tgstime, cutime, cstime;
>
> - spin_lock_irq(&current->sighand->siglock);
> thread_group_cputime_adjusted(current, &tgutime, &tgstime);
> cutime = current->signal->cutime;
> cstime = current->signal->cstime;
> - spin_unlock_irq(&current->sighand->siglock);

Ah, wait, there is another problem afaics...

thread_group_cputime_adjusted()->cputime_adjust() plays with
signal->prev_cputime and thus it needs siglock or stats_lock to ensure
it can't race with itself. Not sure it is safe to simply take the lock
in cputime_adjust(), this should be checked.

OTOH, do_task_stat() already calls task_cputime_adjusted() lockless and
this looks wrong or I missed something. So perhaps we need a lock in or
around cputime_adjust() anyway.

Oleg.