From: Waiman Long <longman@redhat.com>
To: Michal Hocko <mhocko@kernel.org>, Dave Chinner <david@fromorbit.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Kees Cook <keescook@chromium.org>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
Davidlohr Bueso <dave@stgolabs.net>,
Miklos Szeredi <miklos@szeredi.hu>,
Daniel Colascione <dancol@google.com>,
Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH 0/2] /proc/stat: Reduce irqs counting performance overhead
Date: Tue, 8 Jan 2019 12:05:35 -0500 [thread overview]
Message-ID: <5525323d-7465-5bfc-862e-a3bcff61fb00@redhat.com> (raw)
In-Reply-To: <20190108161100.GE31793@dhcp22.suse.cz>
On 01/08/2019 11:11 AM, Michal Hocko wrote:
> On Tue 08-01-19 13:04:22, Dave Chinner wrote:
>> On Mon, Jan 07, 2019 at 05:41:39PM -0500, Waiman Long wrote:
>>> On 01/07/2019 05:32 PM, Dave Chinner wrote:
>>>> On Mon, Jan 07, 2019 at 10:12:56AM -0500, Waiman Long wrote:
>>>>> As newer systems have more and more IRQs and CPUs available in their
>>>>> system, the performance of reading /proc/stat frequently is getting
>>>>> worse and worse.
>>>> Because the "roll-your-own" per-cpu counter implementaiton has been
>>>> optimised for low possible addition overhead on the premise that
>>>> summing the counters is rare and isn't a performance issue. This
>>>> patchset is a direct indication that this "summing is rare and can
>>>> be slow" premise is now invalid.
>>>>
>>>> We have percpu counter infrastructure that trades off a small amount
>>>> of addition overhead for zero-cost reading of the counter value.
>>>> i.e. why not just convert this whole mess to percpu_counters and
>>>> then just use percpu_counter_read_positive()? Then we just don't
>>>> care how often userspace reads the /proc file because there is no
>>>> summing involved at all...
>>>>
>>>> Cheers,
>>>>
>>>> Dave.
>>> Yes, percpu_counter_read_positive() is cheap. However, you still need to
>>> pay the price somewhere. In the case of percpu_counter, the update is
>>> more expensive.
>> Ummm, that's exactly what I just said. It's a percpu counter that
>> solves the "sum is expensive and frequent" problem, just like you
>> are encountering here. I do not need basic scalability algorithms
>> explained to me.
>>
>>> I would say the percentage of applications that will hit this problem is
>>> small. But for them, this problem has some significant performance overhead.
>> Well, duh!
>>
>> What I was suggesting is that you change the per-cpu counter
>> implementation to the /generic infrastructure/ that solves this
>> problem, and then determine if the extra update overhead is at all
>> measurable. If you can't measure any difference in update overhead,
>> then slapping complexity on the existing counter to attempt to
>> mitigate the summing overhead is the wrong solution.
>>
>> Indeed, it may be that you need o use a custom batch scaling curve
>> for the generic per-cpu coutner infrastructure to mitigate the
>> update overhead, but the fact is we already have generic
>> infrastructure that solves your problem and so the solution should
>> be "use the generic infrastructure" until it can be proven not to
>> work.
>>
>> i.e. prove the generic infrastructure is not fit for purpose and
>> cannot be improved sufficiently to work for this use case before
>> implementing a complex, one-off snowflake counter implementation...
> Completely agreed! Apart from that I find that conversion to a generic
> infrastructure worth even if that doesn't solve the problem at hands
> completely. If for no other reasons then the sheer code removal as kstat
> is not really used for anything apart from this accounting AFAIR. The
> less ad-hoc code we have the better IMHO.
>
> And to the underlying problem. Some proc files do not scale on large
> machines. Maybe it is time to explain that to application writers that
> if they are collecting data too agressively then it won't scale. We can
> only do this much. Lying about numbers by hiding updates is, well,
> lying and won't solve the underlying problem.
I would not say it is lying. As I said in the changelog, reading
/proc/stat infrequently will give the right counts. Only when it is read
frequently that the data may not be up-to-date. Using
percpu_counter_sum_positive() as suggested by Dave will guarantee that
the counts will likely be off by a certain amount too. So it is also a
trade-off between accuracy and performance.
Cheers,
Longman
next prev parent reply other threads:[~2019-01-08 17:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-07 15:12 [PATCH 0/2] /proc/stat: Reduce irqs counting performance overhead Waiman Long
2019-01-07 15:12 ` [PATCH 1/2] /proc/stat: Extract irqs counting code into show_stat_irqs() Waiman Long
2019-01-07 21:42 ` Kees Cook
2019-01-07 15:12 ` [PATCH 2/2] /proc/stat: Add sysctl parameter to control irq counts latency Waiman Long
2019-01-07 15:58 ` Matthew Wilcox
2019-01-07 16:07 ` Waiman Long
2019-01-07 16:14 ` Matthew Wilcox
2019-01-07 16:19 ` Waiman Long
2019-01-07 16:33 ` Alexey Dobriyan
2019-01-07 16:59 ` Waiman Long
[not found] ` <20190118084456.GA10690@shao2-debian>
2019-01-21 20:02 ` [LKP] [/proc/stat] 3047027b34: reaim.jobs_per_min -4.8% regression Kees Cook
2019-01-21 21:25 ` Alexey Dobriyan
2019-01-07 22:32 ` [PATCH 0/2] /proc/stat: Reduce irqs counting performance overhead Dave Chinner
2019-01-07 22:41 ` Daniel Colascione
2019-01-07 23:49 ` Alexey Dobriyan
2019-01-07 22:41 ` Waiman Long
2019-01-08 2:04 ` Dave Chinner
2019-01-08 16:11 ` Michal Hocko
2019-01-08 17:05 ` Waiman Long [this message]
2019-01-08 17:32 ` Waiman Long
2019-01-08 16:58 ` Waiman Long
2019-01-08 22:27 ` Dave Chinner
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=5525323d-7465-5bfc-862e-a3bcff61fb00@redhat.com \
--to=longman@redhat.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dancol@google.com \
--cc=dave@stgolabs.net \
--cc=david@fromorbit.com \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mhocko@kernel.org \
--cc=miklos@szeredi.hu \
--cc=rdunlap@infradead.org \
/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).