From: Frederic Weisbecker <frederic@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Dumazet <edumazet@google.com>,
LKML <linux-kernel@vger.kernel.org>,
Levin Alexander <alexander.levin@verizon.com>,
Peter Zijlstra <peterz@infradead.org>,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>,
Wanpeng Li <wanpeng.li@hotmail.com>,
Dmitry Safonov <dima@arista.com>,
Thomas Gleixner <tglx@linutronix.de>,
Radu Rendec <rrendec@arista.com>, Ingo Molnar <mingo@kernel.org>,
Stanislaw Gruszka <sgruszka@redhat.com>,
Paolo Abeni <pabeni@redhat.com>, Rik van Riel <riel@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Miller <davem@davemloft.net>
Subject: Re: [RFC PATCH 1/2] softirq: Account time and iteration stats per vector
Date: Fri, 12 Jan 2018 19:54:29 +0100 [thread overview]
Message-ID: <20180112185428.GE1950@lerouge> (raw)
In-Reply-To: <CA+55aFwwpSbjo=04KmekzfZ2VxQze68s54KtOt4+XhhQxx9fVQ@mail.gmail.com>
On Fri, Jan 12, 2018 at 10:12:32AM -0800, Linus Torvalds wrote:
> On Fri, Jan 12, 2018 at 6:34 AM, Frederic Weisbecker
> <frederic@kernel.org> wrote:
> >
> > That's right. But I thought it was bit large for the stack:
> >
> > struct {
> > u64 time;
> > u64 count;
> > } [NR_SOFTIRQS]
>
> Note that you definitely don't want "u64" here.
>
> Both of these values had better be very limited. The "count" is on the
> order of 10 - it fits in 4 _bits_ without any overflow.
>
> And 'time' is on the order of 2ms, so even if it's in nanoseconds, we
> already know that we want to limit it to a single ms or so (yes, yes,
> right now our limit is 2ms, but I think that's long). So even that
> doesn't need 64-bit.
Ok.
>
> Finally, I think you can join them. If we do a "time or count" limit,
> let's just make the "count" act as some arbitrary fixed time, so that
> we limit things that way.
>
> Say, if we want to limit it to 2ms, consider one count to be 0.2ms. So
> instead of keeping track of count at all, just say "make each softirq
> call count as at least 200,000ns even if the scheduler clock says it's
> less". End result: we'd loop at most ten times.
>
> So now you only need one value, and you know it can't be bigger than 2
> million, so it can be a 32-bit one. Boom. Done.
Right.
Now I believe that the time was added as a limit because count alone was not
reliable enough to diagnose a softirq overrun. But if everyone is fine with
keeping the count as a single metric, I would be much happier because that
means less overhead, no need to fetch the clock, etc...
>
> Also, don't you want these to be percpu, and keep accumulating them
> until you decide to either age them away (just clear it in timer
> interrupt?) or if the value gets so big that you want o fall back to
> the thread instead (and then the thread can clear it every iteration,
> so you don't need to track whether the thread is active or not).
>
> I don't know. I'm traveling today, so I didn't actually have time to
> really look at the patches, I'm just reacting to Eric's reaction.
Clearing the accumulation on tick and flush, that sounds like a good plan.
Well I'm probably not going to use the tick for that because of nohz (again)
but I can check if jiffies changed since we started the accumulation and
reset it if so.
I'm going to respin, thanks!
next prev parent reply other threads:[~2018-01-12 18:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 5:35 [RFC PATCH 0/2] softirq: Per vector threading Frederic Weisbecker
2018-01-12 5:35 ` [RFC PATCH 1/2] softirq: Account time and iteration stats per vector Frederic Weisbecker
2018-01-12 6:22 ` Eric Dumazet
2018-01-12 14:34 ` Frederic Weisbecker
2018-01-12 18:12 ` Linus Torvalds
2018-01-12 18:54 ` Frederic Weisbecker [this message]
2018-01-12 5:35 ` [RFC PATCH 2/2] softirq: Per vector thread deferment Frederic Weisbecker
2018-01-12 6:27 ` Frederic Weisbecker
2018-01-12 9:07 ` Paolo Abeni
2018-01-12 14:56 ` Frederic Weisbecker
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=20180112185428.GE1950@lerouge \
--to=frederic@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.levin@verizon.com \
--cc=davem@davemloft.net \
--cc=dima@arista.com \
--cc=edumazet@google.com \
--cc=hannes@stressinduktion.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pabeni@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=rrendec@arista.com \
--cc=sgruszka@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--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