From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B175C433E0 for ; Fri, 29 May 2020 00:24:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 15C6F207F9 for ; Fri, 29 May 2020 00:24:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15C6F207F9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5D08E8001A; Thu, 28 May 2020 20:24:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55AEA80010; Thu, 28 May 2020 20:24:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 421768001A; Thu, 28 May 2020 20:24:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 26AD380010 for ; Thu, 28 May 2020 20:24:45 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E25362DFC for ; Fri, 29 May 2020 00:24:44 +0000 (UTC) X-FDA: 76867860888.24.foot86_80b1d23617a54 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id CC02D1A4AA for ; Fri, 29 May 2020 00:24:44 +0000 (UTC) X-HE-Tag: foot86_80b1d23617a54 X-Filterd-Recvd-Size: 7280 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 May 2020 00:24:44 +0000 (UTC) Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DBF922078C; Fri, 29 May 2020 00:24:37 +0000 (UTC) Date: Thu, 28 May 2020 20:24:35 -0400 From: Steven Rostedt To: Axel Rasmussen Cc: Andrew Morton , David Rientjes , Davidlohr Bueso , Ingo Molnar , Ingo Molnar , Jerome Glisse , Laurent Dufour , "Liam R . Howlett" , Matthew Wilcox , Michel Lespinasse , Peter Zijlstra , Vlastimil Babka , Will Deacon , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, AKASHI Takahiro , Aleksa Sarai , Alexander Potapenko , Alexey Dobriyan , Al Viro , Andrei Vagin , Ard Biesheuvel , Brendan Higgins , chenqiwu , Christian Brauner , Christian Kellner , Corentin Labbe , Daniel Jordan , Dan Williams , David Gow , "David S. Miller" , "Dmitry V. Levin" , "Eric W. Biederman" , Eugene Syromiatnikov , Jamie Liu , Jason Gunthorpe , John Garry , John Hubbard , Jonathan Adams , Junaid Shahid , Kees Cook , "Kirill A. Shutemov" , Konstantin Khlebnikov , Krzysztof Kozlowski , Mark Rutland , Masahiro Yamada , Masami Hiramatsu , Mathieu Desnoyers , Michal Hocko , Mikhail Zaslonko , Petr Mladek , Ralph Campbell , Randy Dunlap , Roman Gushchin , Shakeel Butt , Tal Gilboa , Thomas Gleixner , "Uwe =?UTF-8?B?S2xlaW5lLUvDtm5pZw==?=" , Vincenzo Frascino , Yang Shi , Yu Zhao , Tom Zanussi Subject: Re: [PATCH v2 0/7] Add histogram measuring mmap_lock contention latency Message-ID: <20200528202435.65396221@oasis.local.home> In-Reply-To: <20200528235238.74233-1-axelrasmussen@google.com> References: <20200528235238.74233-1-axelrasmussen@google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: CC02D1A4AA X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 28 May 2020 16:52:38 -0700 Axel Rasmussen 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. 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? -- 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//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