Re: [PATCH] steal_account_process_tick() should return jiffies

From: Thomas Gleixner
Date: Sat Mar 05 2016 - 05:28:41 EST


Chris,

On Fri, 4 Mar 2016, Chris Friesen wrote:

First of all the subject line should contain a subsystem prefix,
i.e. "sched/cputime:"

> The callers of steal_account_process_tick() expect it to return whether
> the last jiffy was 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.

Sure, but what is the actual problem? The return value is boolean and tells
whether there was stolen time accounted or not.

> The fix is to change steal_account_process_tick() to always return
> jiffies. If CONFIG_VIRT_CPU_ACCOUNTING_GEN is not enabled then this
> is a no-op.

What does that fix?

> As far as I can tell this bug has been present since commit dee08a72.

Which bug?

> Signed-off-by: Chris Friesen <chris.friesen@xxxxxxxxxxxxx>
> ---
>
> kernel/sched/cputime.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index b2ab2ff..e724496 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -276,7 +276,7 @@ static __always_inline bool steal_account_process_tick(void)
> this_rq()->prev_steal_time += cputime_to_nsecs(steal_ct);
>
> account_steal_time(steal_ct);
> - return steal_ct;
> + return cputime_to_jiffies(steal_ct);

So if steal time is close to a jiffie, then cputime_to_jiffies will return 0
and you account a full jiffie to user/system/whatever.

Without a proper explanation of the problem and the resulting "bug" I really
cannot figure out why we want that change.

Thanks,

tglx