sched, time: Atomically increment stime & utime
The functions task_cputime_adjusted and thread_group_cputime_adjusted()
can be called locklessly, as well as concurrently on many different CPUs.
This can occasionally lead to the utime and stime reported by times(), and
other syscalls like it, going backward. The cause for this appears to be
multiple threads racing in cputime_adjust(), both with values for utime or
stime that is larger than the original, but each with a different value.
Sometimes the larger value gets saved first, only to be immediately
overwritten with a smaller value by another thread.
Using atomic exchange prevents that problem, and ensures time
Signed-off-by: Rik van Riel <firstname.lastname@example.org>
Signed-off-by: Peter Zijlstra (Intel) <email@example.com>
Cc: Linus Torvalds <firstname.lastname@example.org>
Signed-off-by: Ingo Molnar <email@example.com>
1 file changed