From: Axel Rasmussen <axelrasmussen@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"David Rientjes" <rientjes@google.com>,
"Davidlohr Bueso" <dbueso@suse.de>,
"Ingo Molnar" <mingo@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Jerome Glisse" <jglisse@redhat.com>,
"Laurent Dufour" <ldufour@linux.ibm.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Michel Lespinasse" <walken@google.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Will Deacon" <will@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org,
"AKASHI Takahiro" <takahiro.akashi@linaro.org>,
"Aleksa Sarai" <cyphar@cyphar.com>,
"Alexander Potapenko" <glider@google.com>,
"Alexey Dobriyan" <adobriyan@gmail.com>,
"Al Viro" <viro@zeniv.linux.org.uk>,
"Andrei Vagin" <avagin@gmail.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Brendan Higgins" <brendanhiggins@google.com>,
chenqiwu <chenqiwu@xiaomi.com>,
"Christian Brauner" <christian.brauner@ubuntu.com>,
"Christian Kellner" <christian@kellner.me>,
"Corentin Labbe" <clabbe@baylibre.com>,
"Daniel Jordan" <daniel.m.jordan@oracle.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"David Gow" <davidgow@google.com>,
"David S. Miller" <davem@davemloft.net>,
"Dmitry V. Levin" <ldv@altlinux.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"Eugene Syromiatnikov" <esyr@redhat.com>,
"Jamie Liu" <jamieliu@google.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"John Garry" <john.garry@huawei.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Jonathan Adams" <jwadams@google.com>,
"Junaid Shahid" <junaids@google.com>,
"Kees Cook" <keescook@chromium.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
"Konstantin Khlebnikov" <khlebnikov@yandex-team.ru>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Masahiro Yamada" <yamada.masahiro@socionext.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Michal Hocko" <mhocko@suse.com>,
"Mikhail Zaslonko" <zaslonko@linux.ibm.com>,
"Petr Mladek" <pmladek@suse.com>,
"Ralph Campbell" <rcampbell@nvidia.com>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Roman Gushchin" <guro@fb.com>,
"Shakeel Butt" <shakeelb@google.com>,
"Tal Gilboa" <talgi@mellanox.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Uwe Kleine-König" <uwe@kleine-koenig.org>,
"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
"Yang Shi" <yang.shi@linux.alibaba.com>,
"Yu Zhao" <yuzhao@google.com>, "Tom Zanussi" <zanussi@kernel.org>
Subject: Re: [PATCH v2 0/7] Add histogram measuring mmap_lock contention latency
Date: Thu, 28 May 2020 18:39:08 -0700 [thread overview]
Message-ID: <CAJHvVchm6jaOk53h543mdagao7GT6nhBgReQcFkJKisHSmFN_g@mail.gmail.com> (raw)
In-Reply-To: <20200528202435.65396221@oasis.local.home>
[-- Attachment #1: Type: text/plain, Size: 4663 bytes --]
On Thu, May 28, 2020 at 5:24 PM Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 28 May 2020 16:52:38 -0700
> Axel Rasmussen <axelrasmussen@google.com> wrote:
>
> Hi Axel,
>
> First, your patch threading is messed up. All the patches should be a
> reply to this cover page, and not individual emails which get lost
> among other patches.
>
Sorry - I'll fix this in the future. (I mistakenly ran git send-email on
each patch individually, rather than globbing them into a single command.)
>
> Next, we already have histogram logic with trace events. Why not build
> off of that. Or perhaps update lockdep which can record contention with
> all locks. Why create yet another histogram infrastructure that is used
> for just a specific purpose?
>
The use case we have in mind for this is to enable this instrumentation
widely in Google's production fleet. Internally, we have a userspace thing
which scrapes these metrics and publishes them such that we can look at
aggregate metrics across our fleet. The thinking is that mechanisms like
lockdep or getting histograms with e.g. BPF attached to the tracepoint
introduces too much overhead for this to be viable. (Although, granted, I
don't have benchmarks to prove this - if there's skepticism, I can produce
such a thing - or prove myself wrong and rethink my approach. :) )
>
> -- Steve
>
>
> > The overall goal of this patchset is to add a latency histogram which
> measures
> > `mmap_lock` acquisition time. This is useful to measure the impact of
> ongoing
> > work like maple trees and range locks (https://lwn.net/Articles/787629/),
> and
> > it is also useful to debug userspace processes which experience long
> waits due
> > to lock contention.
> >
> > This patchset is built upon walken@google.com's new `mmap_lock` API
> > (https://lkml.org/lkml/2020/4/21/1307). In its current form, it should
> apply
> > cleanly to a 5.7-rc7 tree to which Michel's patchset has already been
> applied.
> >
> > To summarize the changes being made at a high level:
> >
> > - Add a histogram library: a `struct histogram` is effectively an array
> of
> > thresholds (i.e., buckets), and an array of per-cpu `u64` counts of the
> > number of samples in each bucket.
> >
> > - Modify Michel's mmap_lock API to record samples in a histogram, owned
> by the
> > `mm_struct`, on each lock acquisition. For contended lock acquisitions,
> we
> > compute the amount of time spent waiting, which determines the bucket.
> >
> > - For uncontended cases, we still record a sample, but with "0" latency.
> The
> > reasoning for this is, a) we don't want to incur the overhead of
> actually
> > measuring the time, but b) we still want to end up with an accurate
> count of
> > acquisition attempts, as this lets us compute latency percentiles
> (e.g., "x%
> > of lock acquisitions completed in <= y ns").
> >
> > Changes since v1 (sent to a few folks within Google for initial review):
> >
> > - Added a tracepoint to the contended case.
> > - Modified `mmap_write_lock_nested` to split the {un,}contended cases.
> > - Removed support for having more than one histogram in `mm_struct`.
> > - Removed any histogram code not explicitly used in this patchset.
> > - Whitespace cleanups.
> >
> > Axel Rasmussen (7):
> > histogram: add struct histogram
> > histogram: add helper function to expose histograms to userspace
> > mmap_lock: add a histogram structure to struct mm_struct
> > mmap_lock: allocate histogram (if enabled) in mm_init
> > mmap_lock: add /proc/<pid>/mmap_lock_contention interface
> > mmap_lock: increment histogram whenever mmap_lock is acquired
> > mmap_lock: add a tracepoint to contended acquisitions
> >
> > fs/proc/base.c | 25 +++
> > include/linux/histogram.h | 293 +++++++++++++++++++++++++++++++
> > include/linux/mm_types.h | 11 ++
> > include/linux/mmap_lock.h | 92 +++++++++-
> > include/trace/events/mmap_lock.h | 34 ++++
> > kernel/fork.c | 55 ++++++
> > kernel/locking/rwsem.c | 4 +-
> > lib/Kconfig | 3 +
> > lib/Makefile | 2 +
> > lib/histogram.c | 212 ++++++++++++++++++++++
> > mm/Kconfig | 13 ++
> > mm/Makefile | 1 +
> > mm/mmap_lock.c | 46 +++++
> > 13 files changed, 782 insertions(+), 9 deletions(-)
> > create mode 100644 include/linux/histogram.h
> > create mode 100644 include/trace/events/mmap_lock.h
> > create mode 100644 lib/histogram.c
> > create mode 100644 mm/mmap_lock.c
> >
> > --
> > 2.27.0.rc0.183.gde8f92d652-goog
>
>
[-- Attachment #2: Type: text/html, Size: 6242 bytes --]
next prev parent reply other threads:[~2020-05-29 1:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 23:52 Axel Rasmussen
2020-05-29 0:24 ` Steven Rostedt
2020-05-29 1:39 ` Axel Rasmussen [this message]
2020-05-29 8:09 ` Peter Zijlstra
2020-05-29 15:03 ` Masami Hiramatsu
2020-05-29 22:38 ` Axel Rasmussen
2020-05-29 5:32 ` Thomas Gleixner
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=CAJHvVchm6jaOk53h543mdagao7GT6nhBgReQcFkJKisHSmFN_g@mail.gmail.com \
--to=axelrasmussen@google.com \
--cc=Liam.Howlett@oracle.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=avagin@gmail.com \
--cc=brendanhiggins@google.com \
--cc=chenqiwu@xiaomi.com \
--cc=christian.brauner@ubuntu.com \
--cc=christian@kellner.me \
--cc=clabbe@baylibre.com \
--cc=cyphar@cyphar.com \
--cc=dan.j.williams@intel.com \
--cc=daniel.m.jordan@oracle.com \
--cc=davem@davemloft.net \
--cc=davidgow@google.com \
--cc=dbueso@suse.de \
--cc=ebiederm@xmission.com \
--cc=esyr@redhat.com \
--cc=glider@google.com \
--cc=guro@fb.com \
--cc=jamieliu@google.com \
--cc=jgg@ziepe.ca \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=john.garry@huawei.com \
--cc=junaids@google.com \
--cc=jwadams@google.com \
--cc=keescook@chromium.org \
--cc=khlebnikov@yandex-team.ru \
--cc=kirill.shutemov@linux.intel.com \
--cc=krzk@kernel.org \
--cc=ldufour@linux.ibm.com \
--cc=ldv@altlinux.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rcampbell@nvidia.com \
--cc=rdunlap@infradead.org \
--cc=rientjes@google.com \
--cc=rostedt@goodmis.org \
--cc=shakeelb@google.com \
--cc=takahiro.akashi@linaro.org \
--cc=talgi@mellanox.com \
--cc=tglx@linutronix.de \
--cc=uwe@kleine-koenig.org \
--cc=vbabka@suse.cz \
--cc=vincenzo.frascino@arm.com \
--cc=viro@zeniv.linux.org.uk \
--cc=walken@google.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=yamada.masahiro@socionext.com \
--cc=yang.shi@linux.alibaba.com \
--cc=yuzhao@google.com \
--cc=zanussi@kernel.org \
--cc=zaslonko@linux.ibm.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