From: Rik van Riel <riel@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Wanpeng Li <wanpeng.li@hotmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Radim Krcmar <rkrcmar@redhat.com>, Mike Galbraith <efault@gmx.de>
Subject: Re: [PATCH 1/5] sched,time: Count actually elapsed irq & softirq time
Date: Wed, 10 Aug 2016 01:07:41 -0400 [thread overview]
Message-ID: <1470805661.13905.95.camel@redhat.com> (raw)
In-Reply-To: <CANRm+CzXSCNGoVbuOB0Ruj2nmfHNRfcO3eB-91Z-fnBOnn-gbQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3911 bytes --]
On Wed, 2016-08-10 at 07:39 +0800, Wanpeng Li wrote:
> 2016-08-10 7:25 GMT+08:00 Wanpeng Li <kernellwp@gmail.com>:
> > 2016-08-09 22:06 GMT+08:00 Rik van Riel <riel@redhat.com>:
> > > On Tue, 2016-08-09 at 11:59 +0800, Wanpeng Li wrote:
> > > > Hi Rik,
> > > > 2016-07-13 22:50 GMT+08:00 Frederic Weisbecker <fweisbec@gmail.
> > > > com>:
> > > > > From: Rik van Riel <riel@redhat.com>
> > > > >
> > > > > Currently, if there was any irq or softirq time during
> > > > > 'ticks'
> > > > > jiffies, the entire period will be accounted as irq or
> > > > > softirq
> > > > > time.
> > > > >
> > > > > This is inaccurate if only a subset of the time was actually
> > > > > spent
> > > > > handling irqs, and could conceivably mis-count all of the
> > > > > ticks
> > > > > during
> > > > > a period as irq time, when there was some irq and some
> > > > > softirq
> > > > > time.
> > > > >
> > > > > This can actually happen when irqtime_account_process_tick is
> > > > > called
> > > > > from account_idle_ticks, which can pass a larger number of
> > > > > ticks
> > > > > down
> > > > > all at once.
> > > > >
> > > > > Fix this by changing irqtime_account_hi_update,
> > > > > irqtime_account_si_update,
> > > > > and steal_account_process_ticks to work with cputime_t time
> > > > > units,
> > > > > and
> > > > > return the amount of time spent in each mode.
> > > >
> > > > Do we need to minus st cputime from idle cputime in
> > > > account_idle_ticks() when noirqtime is true? I try to add this
> > > > logic
> > > > w/ noirqtime and idle=poll boot parameter for a full dynticks
> > > > guest,
> > > > however, there is no difference, where I miss?
> > >
> > > Yes, you are right. The code in account_idle_ticks()
> > > could use the same treatment.
> > >
> > > I am not sure why it would not work, though...
> >
> > Actually I observed a regression caused by this patch. I use a i5
>
> The regression is caused by your commit "sched,time: Count actually
> elapsed irq & softirq time".
Wanpeng and I discussed this issue, and discovered
that this bug is triggered by my patch, specifically
this bit:
- if (steal_account_process_tick(ULONG_MAX))
+ other = account_other_time(cputime);
+ if (other >= cputime)
return;
Replacing "cputime" with "ULONG_MAX" as the argument
to account_other_time makes the bug disappear.
However, this is not the cause of the bug.
The cause of the bug appears to be that the values
used to figure out how much steal time has passed
are never initialized.
steal = paravirt_steal_clock(smp_processor_id());
steal -= this_rq()->prev_steal_time;
The first of the two may be initialized by the host
(I did not verify that), but the second one does not
have any explicit initializers anywhere in the kernel
tree.
This can lead to an arbitrarily large difference between
paravirt_steal_clock(smp_processor_id()) and
this_rq()->prev_steal_time, which results in nothing but
steal time getting accounted for a potentially a very
long amount of time.
Previously we carried this patch to initialize the
various rq->prev_* values at CPU hotplug time:
https://patchwork.codeaurora.org/patch/27699/
Which got reverted by Paolo here:
https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=sche
d/core&id=3d89e5478bf550a50c99e93adf659369798263b0
Which leads me to this question:
Paulo, how would you like us to fix this bug?
It seems like the host and guest steal time CAN get out
of sync, sometimes by a ridiculous amount, and we need
some way to get the excessive difference out of the way,
without it getting accounted as steal time (not immediately,
and not over the next 17 hours, or months).
--
All Rights Reversed.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-08-10 21:26 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 14:50 [GIT PULL] cputime fixes and cleanups Frederic Weisbecker
2016-07-13 14:50 ` [PATCH 1/5] sched,time: Count actually elapsed irq & softirq time Frederic Weisbecker
2016-07-14 10:37 ` [tip:timers/nohz] sched/cputime: " tip-bot for Rik van Riel
2016-08-09 3:59 ` [PATCH 1/5] sched,time: " Wanpeng Li
2016-08-09 14:06 ` Rik van Riel
2016-08-09 23:07 ` Wanpeng Li
2016-08-10 7:51 ` Wanpeng Li
2016-08-09 23:25 ` Wanpeng Li
2016-08-09 23:31 ` Wanpeng Li
2016-08-09 23:35 ` Wanpeng Li
2016-08-09 23:39 ` Wanpeng Li
2016-08-10 5:07 ` Rik van Riel [this message]
2016-08-10 6:33 ` Wanpeng Li
2016-08-10 16:52 ` [PATCH] time,virt: resync steal time when guest & host lose sync Rik van Riel
2016-08-11 10:11 ` Wanpeng Li
2016-08-12 2:44 ` Rik van Riel
2016-08-12 7:09 ` Wanpeng Li
2016-08-12 15:58 ` Rik van Riel
2016-08-13 15:36 ` Frederic Weisbecker
2016-08-15 8:53 ` Wanpeng Li
2016-08-15 11:38 ` Wanpeng Li
2016-08-15 15:00 ` Rik van Riel
2016-08-15 22:19 ` Wanpeng Li
2016-08-16 1:31 ` Wanpeng Li
2016-08-16 2:11 ` Rik van Riel
2016-08-16 6:54 ` Wanpeng Li
2016-08-16 14:01 ` Rik van Riel
2016-08-16 23:08 ` Wanpeng Li
2016-08-12 16:33 ` Paolo Bonzini
2016-08-12 17:23 ` Rik van Riel
2016-08-13 7:18 ` Paolo Bonzini
2016-08-13 8:42 ` Ingo Molnar
2016-08-14 1:50 ` Rik van Riel
2016-08-18 8:23 ` Wanpeng Li
2016-07-13 14:50 ` [PATCH 2/5] nohz,cputime: Replace VTIME_GEN irq time code with IRQ_TIME_ACCOUNTING code Frederic Weisbecker
2016-07-14 10:37 ` [tip:timers/nohz] sched/cputime: " tip-bot for Rik van Riel
2016-07-13 14:50 ` [PATCH 3/5] sched: Complete cleanup of old vtime gen irqtime accounting Frederic Weisbecker
2016-07-14 10:38 ` [tip:timers/nohz] sched/cputime: Clean up the old vtime gen irqtime accounting completely tip-bot for Frederic Weisbecker
2016-07-13 14:50 ` [PATCH 4/5] sched: Reorganize vtime native irqtime accounting headers Frederic Weisbecker
2016-07-14 10:38 ` [tip:timers/nohz] sched/cputime: " tip-bot for Frederic Weisbecker
2016-07-13 14:50 ` [PATCH 5/5] time: Drop local_irq_save/restore from irqtime_account_irq Frederic Weisbecker
2016-07-14 10:38 ` [tip:timers/nohz] sched/cputime: Drop local_irq_save/restore from irqtime_account_irq() tip-bot for Rik van Riel
-- strict thread matches above, loose matches on Subject: below --
2016-06-23 2:25 [PATCH v2 0/5] sched,time: fix irq time accounting with nohz_idle riel
2016-06-23 2:25 ` [PATCH 1/5] sched,time: count actually elapsed irq & softirq time riel
2016-06-27 12:25 ` Frederic Weisbecker
2016-06-27 12:50 ` Rik van Riel
2016-06-28 20:56 ` Frederic Weisbecker
2016-06-16 16:06 [PATCH 0/5] sched,time: fix irq time accounting with nohz_idle riel
2016-06-16 16:06 ` [PATCH 1/5] sched,time: count actually elapsed irq & softirq time riel
2016-06-16 16:22 ` kbuild test robot
2016-06-21 21:21 ` Peter Zijlstra
2016-06-21 22:20 ` Rik van Riel
2016-06-22 10:40 ` Paolo Bonzini
2016-06-22 10:52 ` Peter Zijlstra
2016-06-08 2:29 [PATCH RFC 0/5] sched,time: make irq time accounting work for nohz_idle riel
2016-06-08 2:30 ` [PATCH 1/5] sched,time: count actually elapsed irq & softirq time riel
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=1470805661.13905.95.camel@redhat.com \
--to=riel@redhat.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=kernellwp@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=wanpeng.li@hotmail.com \
/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.