All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Glauber Costa <glommer@parallels.com>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH] sched/cputime: Fix steal time accounting vs. cpu hotplug
Date: Fri, 04 Mar 2016 10:15:01 -0500	[thread overview]
Message-ID: <1457104501.6288.6.camel@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1603041539490.3686@nanos>

[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]

On Fri, 2016-03-04 at 15:59 +0100, Thomas Gleixner wrote:
> On cpu hotplug the steal time accounting can keep a stale rq-
> >prev_steal_time
> value over cpu down and up. So after the cpu comes up again the delta
> calculation in steal_account_process_tick() wreckages itself due to
> the
> unsigned math:
> 
>          u64 steal = paravirt_steal_clock(smp_processor_id());
>          
>          steal -= this_rq()->prev_steal_time;
> 
> So if steal is smaller than rq->prev_steal_time we end up with an
> insane large
> value which then gets added to rq->prev_steal_time, resulting in a
> permanent
> wreckage of the accounting. As a consequence the per cpu stats in
> /proc/stat
> become stale.
> 
> Nice trick to tell the world how idle the system is (100%) while the
> cpu is
> 100% busy running tasks. Though we prefer realistic numbers.
> 
> None of the accounting values which use a previous value to account
> for
> fractions is reset at cpu hotplug time. update_rq_clock_task() has a
> sanity
> check for prev_irq_time and prev_steal_time_rq, but that sanity check
> solely
> deals with clock warps and limits the /proc/stat visible wreckage.
> The
> prev_time values are still wrong.
> 
> Solution is simple: Reset rq->prev_*_time when the cpu is plugged in
> again.
> 
> Fixes: commit e6e6685accfa "KVM guest: Steal time accounting"
> Fixes: commit 095c0aa83e52 "sched: adjust scheduler cpu power for
> stolen time"
> Fixes: commit aa483808516c "sched: Remove irq time from available CPU
> power"
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org

Acked-by: Rik van Riel <riel@redhat.com>

-- 
All Rights Reversed.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-03-04 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04 14:59 [PATCH] sched/cputime: Fix steal time accounting vs. cpu hotplug Thomas Gleixner
2016-03-04 15:15 ` Rik van Riel [this message]
2016-03-05 11:27 ` [tip:sched/urgent] sched/cputime: Fix steal time accounting vs. CPU hotplug tip-bot for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457104501.6288.6.camel@redhat.com \
    --to=riel@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=glommer@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.