• Rik van Riel's avatar
    sched, time: Atomically increment stime & utime · eb1b4af0
    Rik van Riel authored
    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
    progresses monotonically.
    Signed-off-by: default avatarRik van Riel <riel@redhat.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: umgwanakikbuti@gmail.com
    Cc: fweisbec@gmail.com
    Cc: akpm@linux-foundation.org
    Cc: srao@redhat.com
    Cc: lwoodman@redhat.com
    Cc: atheurer@redhat.com
    Cc: oleg@redhat.com
    Link: http://lkml.kernel.org/r/1408133138-22048-4-git-send-email-riel@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    eb1b4af0
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
block Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt/kvm Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...
REPORTING-BUGS Loading commit data...