From: Denys Vlasenko <dvlasenk@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org,
Frederic Weisbecker <fweisbec@gmail.com>,
Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
Fernando Luis Vazquez Cao <fernando_b1@lab.ntt.co.jp>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH 4/4] nohz: Fix iowait overcounting if iowait task migrates
Date: Fri, 25 Apr 2014 20:56:22 +0200 [thread overview]
Message-ID: <535AAFD6.9050900@redhat.com> (raw)
In-Reply-To: <20140424191856.GD26782@laptop.programming.kicks-ass.net>
On 04/24/2014 09:18 PM, Peter Zijlstra wrote:
> On Thu, Apr 24, 2014 at 08:45:58PM +0200, Denys Vlasenko wrote:
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 268a45e..ffea757 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -4218,7 +4218,14 @@ void __sched io_schedule(void)
>> current->in_iowait = 1;
>> schedule();
>> current->in_iowait = 0;
>> +#ifdef CONFIG_NO_HZ_COMMON
>> + if (atomic_dec_and_test(&rq->nr_iowait)) {
>> + if (raw_smp_processor_id() != cpu_of(rq))
>> + tick_nohz_iowait_to_idle(cpu_of(rq));
>> + }
>> +#else
>> atomic_dec(&rq->nr_iowait);
>> +#endif
>> delayacct_blkio_end();
>> }
>
> You're really refusing to collapse that stuff eh?
I'm sending two patches on top of my last patch set
which tidies up a few such aspects (another one
is where we fetch a percpu variable before knowing
that we'll need it, potentially wasting a few cycles).
>> +void tick_nohz_iowait_to_idle(int cpu)
>> +{
>> + struct tick_sched *ts = tick_get_tick_sched(cpu);
>> + ktime_t now = ktime_get();
>> +
>> + write_seqcount_begin(&ts->idle_sleeptime_seq);
>> + ts->iowait_exittime = now;
>> + write_seqcount_end(&ts->idle_sleeptime_seq);
>> +}
>
>
> So what again was wrong with this one?
>
> http://marc.info/?l=linux-kernel&m=139772917211023
That code has no provision to record when last iowait task
left the rq.
Therefore it can undercount iowait - it's very similar
to the problem I had before patch #4 in my patch series.
My patches 1-3 can overcount iowait because they consider
the entire idle period "iowait" if nr_iowait_cpu() != 0
at the *beginning*.
Hidetoshi's patches consider the entire idle period "iowait"
if nr_iowait_cpu() != 0 at the *end*.
He needs to code carefully so that this delayed decision
doesn't make reader functions return wrong results.
However, if nr_iowait_cpu() was 0 at the end it does not mean
that most of this time period it was also 0. It could have been
mostly !0 - and in this case iowait will be undercounted.
I personally thought that both over- or undercounting iowait
might be acceptable.
If not, then *some* form of recording and accounting
for exact moment when last iowait task left the rq is necessary.
That's what I did in patch #4.
--
vda
next prev parent reply other threads:[~2014-04-25 18:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-24 18:45 [PATCH 1/4] nohz: Only update sleeptime stats locally Denys Vlasenko
2014-04-24 18:45 ` [PATCH 2/4] nohz: Synchronize sleep time stats with seqlock Denys Vlasenko
2014-04-24 18:45 ` [PATCH 3/4] nohz: Fix idle/iowait counts going backwards Denys Vlasenko
2014-04-24 18:45 ` [PATCH 4/4] nohz: Fix iowait overcounting if iowait task migrates Denys Vlasenko
2014-04-24 19:18 ` Peter Zijlstra
2014-04-25 18:56 ` Denys Vlasenko [this message]
2014-04-29 14:47 ` Frederic Weisbecker
2014-05-05 18:06 ` Denys Vlasenko
2014-05-07 13:38 ` Denys Vlasenko
2014-04-29 16:20 ` Frederic Weisbecker
2014-05-05 18:14 ` Denys Vlasenko
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=535AAFD6.9050900@redhat.com \
--to=dvlasenk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=fernando_b1@lab.ntt.co.jp \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=peterz@infradead.org \
--cc=seto.hidetoshi@jp.fujitsu.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).