Patch "sched/cputime: Fix NO_HZ_FULL getrusage() monotonicity regression" has been added to the 4.7-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
sched/cputime: Fix NO_HZ_FULL getrusage() monotonicity regression
to the 4.7-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
sched-cputime-fix-no_hz_full-getrusage-monotonicity-regression.patch
and it can be found in the queue-4.7 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
173be9a14f7b2e901cf77c18b1aafd4d672e9d9eMon Sep 17 00:00:00 2001
From: Peter Zijlstra <[email protected]>
Date: Mon, 15 Aug 2016 18:38:42 +0200
Subject: sched/cputime: Fix NO_HZ_FULL getrusage() monotonicity regression
From: Peter Zijlstra <[email protected]>
commit 173be9a14f7b2e901cf77c18b1aafd4d672e9d9e upstream.
Mike reports:
Roughly 10% of the time, ltp testcase getrusage04 fails:
getrusage04 0 TINFO : Expected timers granularity is 4000 us getrusage04 0 TINFO : Using 1 as multiply factor for max [us]time increment (1000+4000us)! getrusage04 0 TINFO : utime: 0us; stime: 179us getrusage04 0 TINFO : utime: 3751us; stime: 0us getrusage04 1 TFAIL : getrusage04.c:133: stime increased > 5000us:
And tracked it down to the case where the task simply doesn't get _any_ [us]time ticks.
Update the code to assume all rtime is utime when we lack information, thus ensuring a task that elides the tick gets time accounted.
--- kernel/sched/cputime.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
kernel/sched/cputime.c +10 -5
@@ -603,19 +603,25 @@ static void cputime_adjust(struct task_c stime = curr->stime; utime = curr->utime; -if (utime ==0 ) { - stime = rtime; +/* +* If either stime or both stime and utime are 0, assume all runtime is +* userspace. Once a task gets some ticks, the monotonicy code at +* 'update' will ensure things converge to the observed ratio. +*/ +if (stime ==0 ) { + utime = rtime; goto update; } -if (stime ==0 ) { - utime = rtime; +if (utime ==0 ) { + stime = rtime; goto update; } stime =scale_stime ((__force u64 )stime, (__force u64 )rtime, (__force u64)(stime + utime)); +update:/* * Make sure stime doesn't go backwards; this preserves monotonicity * for utime because rtime is monotonic.
@@ -638,7 +644,6 @@ static void cputime_adjust(struct task_c stime = rtime - utime; } -update: prev->stime = stime; prev->utime = utime; out:
Patches currently in stable-queue which might be from [email protected] are
queue-4.7/x86-mm-disable-preemption-during-cr3-read-write.patch queue-4.7/uprobes-fix-the-memcg-accounting.patch queue-4.7/uprobes-x86-fix-rip-relative-handling-of-evex-encoded-instructions.patch queue-4.7/sched-cputime-fix-no_hz_full-getrusage-monotonicity-regression.patch queue-4.7/x86-platform-uv-skip-uv-runtime-services-mapping-in-the-efi_runtime_disabled-case.patch queue-4.7/perf-core-fix-event_function_local.patch queue-4.7/perf-symbols-fix-annotation-of-objects-with-debuginfo-files.patch queue-4.7/efi-capsule-allocate-whole-capsule-into-virtual-memory.patch