From: Peter Zijlstra <peterz@infradead.org>
To: Rik van Riel <riel@redhat.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
pbonzini@redhat.com, fweisbec@gmail.com, wanpeng.li@hotmail.com,
efault@gmx.de, tglx@linutronix.de, rkrcmar@redhat.com
Subject: Re: [PATCH 5/5] irqtime: drop local_irq_save/restore from irqtime_account_irq
Date: Wed, 22 Jun 2016 00:28:32 +0200 [thread overview]
Message-ID: <20160621222832.GU30909@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1466547814.8637.8.camel@redhat.com>
On Tue, Jun 21, 2016 at 06:23:34PM -0400, Rik van Riel wrote:
> > > cpu = smp_processor_id();
> > Per this smp_processor_id() usage, preemption is disabled.
>
> This code is called from the timer code. Surely preemption
> is already disabled?
That's what I said.
> > >
> > > + /*
> > > + * Softirq context may get interrupted by hardirq context,
> > > + * on the same CPU. At softirq entry time the amount of
> > > time
> > > + * spent in hardirq context is stored. At softirq exit
> > > time,
> > > + * the time spent in hardirq context during the softirq is
> > > + * subtracted.
> > > + */
> > > + prev_hardirq = __this_cpu_read(prev_hardirq_time);
> > > + prev_softirq_start = __this_cpu_read(softirq_start_time);
> > > +
> > > + if (irqtype == HARDIRQ_OFFSET) {
> > > + delta = sched_clock_cpu(cpu) -
> > > __this_cpu_read(hardirq_start_time);
> > > + __this_cpu_add(hardirq_start_time, delta);
> > > + } else do {
> > > + u64 now = sched_clock_cpu(cpu);
> > > + hardirq_time = READ_ONCE(per_cpu(cpu_hardirq_time,
> > > cpu));
> > Which makes this per_cpu(,cpu) usage somewhat curious. What's wrong
> > with
> > __this_cpu_read() ?
>
> Is __this_cpu_read() as fast as per_cpu(,cpu) on all
> architectures?
Can't be slower. Don't get the argument though; you've used __this_cpu
stuff all over the place, and here you use a per_cpu() for no reason.
> > >
> > > +
> > > + delta = now - prev_softirq_start;
> > > + if (in_serving_softirq()) {
> > > + /*
> > > + * Leaving softirq context. Avoid double
> > > counting by
> > > + * subtracting hardirq time from this
> > > interval.
> > > + */
> > > + s64 hi_delta = hardirq_time -
> > > prev_hardirq;
> > > + delta -= hi_delta;
> > > + } else {
> > > + /* Entering softirq context. Note start
> > > times. */
> > > + __this_cpu_write(softirq_start_time, now);
> > > + __this_cpu_write(prev_hardirq_time,
> > > hardirq_time);
> > > + }
> > > + /*
> > > + * If a hardirq happened during this calculation,
> > > it may not
> > > + * have gotten a consistent snapshot. Try again.
> > > + */
> > > + } while (hardirq_time !=
> > > READ_ONCE(per_cpu(cpu_hardirq_time, cpu)));
> > That whole thing is somewhat hard to read; but its far too late for
> > me
> > to suggest anything more readable :/
>
> I only had 2 1/2 hours of sleep last night, so I will not
> try to rewrite it now, but I will see if there is anything
> I can do to make it more readable tomorrow.
>
> If you have any ideas before then, please let me know :)
Heh, step away from the computer ... ;-)
next prev parent reply other threads:[~2016-06-21 22:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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-16 16:06 ` [PATCH 2/5] nohz,cputime: remove VTIME_GEN vtime irq time code riel
2016-06-16 16:06 ` [PATCH 3/5] cputime: allow irq time accounting to be selected as an option riel
2016-06-16 16:06 ` [PATCH 4/5] irqtime: add irq type parameter to irqtime_account_irq riel
2016-06-16 16:06 ` [PATCH 5/5] irqtime: drop local_irq_save/restore from irqtime_account_irq riel
2016-06-21 21:49 ` Peter Zijlstra
2016-06-21 22:23 ` Rik van Riel
2016-06-21 22:28 ` Peter Zijlstra [this message]
2016-06-21 22:32 ` Rik van Riel
2016-06-22 21:55 ` Rik van Riel
2016-06-23 13:52 ` Paolo Bonzini
2016-06-23 15:24 ` 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 5/5] irqtime: drop local_irq_save/restore from irqtime_account_irq riel
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 5/5] irqtime: drop local_irq_save/restore from irqtime_account_irq 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=20160621222832.GU30909@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pbonzini@redhat.com \
--cc=riel@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox