]> www.infradead.org Git - users/jedix/linux-maple.git/commit
sched/cputime: Fix steal_account_process_tick() to always return jiffies
authorChris Friesen <cbf123@mail.usask.ca>
Sun, 6 Mar 2016 05:18:48 +0000 (23:18 -0600)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:46:19 +0000 (15:46 -0700)
commit567a5f737d49fe14518eb27a9d414aabfea90dfd
tree03973de5768b335f740b684ebcb49fa2aaac9821
parent3de304c51dc96bb335df2372559163b7070493dc
sched/cputime: Fix steal_account_process_tick() to always return jiffies

Orabug: stable_rc4

[ Upstream commit f9c904b7613b8b4c85b10cd6b33ad41b2843fa9d ]

The callers of steal_account_process_tick() expect it to return
whether a jiffy should be considered stolen or not.

Currently the return value of steal_account_process_tick() is in
units of cputime, which vary between either jiffies or nsecs
depending on CONFIG_VIRT_CPU_ACCOUNTING_GEN.

If cputime has nsecs granularity and there is a tiny amount of
stolen time (a few nsecs, say) then we will consider the entire
tick stolen and will not account the tick on user/system/idle,
causing /proc/stats to show invalid data.

The fix is to change steal_account_process_tick() to accumulate
the stolen time and only account it once it's worth a jiffy.

(Thanks to Frederic Weisbecker for suggestions to fix a bug in my
first version of the patch.)

Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: <stable@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/56DBBDB8.40305@mail.usask.ca
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 23745ba7ffac8cffbe648812fe7dc485d6df9404)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
kernel/sched/cputime.c