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

From: Oleg Nesterov
Date: Thu Aug 14 2014 - 10:26:39 EST


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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/