cputime: Fix jiffies based cputime assumption on steal accounting
authorFrederic Weisbecker <fweisbec@gmail.com>
Wed, 5 Mar 2014 16:02:22 +0000 (17:02 +0100)
committerFrederic Weisbecker <fweisbec@gmail.com>
Thu, 13 Mar 2014 14:56:44 +0000 (15:56 +0100)
commitdee08a72deefac251267ed2717717596aa8b6818
tree33334d1764905dbbac0d795f2086b03d91ebe8da
parentd8a9ce3f8ad2b546b9ebaf65de809da0793f11c5
cputime: Fix jiffies based cputime assumption on steal accounting

The steal guest time accounting code assumes that cputime_t is based on
jiffies. So when CONFIG_NO_HZ_FULL=y, which implies that cputime_t
is based on nsecs, steal_account_process_tick() passes the delta in
jiffies to account_steal_time() which then accounts it as if it's a
value in nsecs.

As a result, accounting 1 second of steal time (with HZ=100 that would
be 100 jiffies) is spuriously accounted as 100 nsecs.

As such /proc/stat may report 0 values of steal time even when two
guests have run concurrently for a few seconds on the same host and
same CPU.

In order to fix this, lets convert the nsecs based steal delta to
cputime instead of jiffies by using the right conversion API.

Given that the steal time is stored in cputime_t and this type can have
a smaller granularity than nsecs, we only account the rounded converted
value and leave the remaining nsecs for the next deltas.

Reported-by: Huiqingding <huding@redhat.com>
Reported-by: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
kernel/sched/cputime.c