From patchwork Thu May 28 23:52:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 11577275 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 987DC90 for ; Thu, 28 May 2020 23:53:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 649FF206E2 for ; Thu, 28 May 2020 23:53:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mBZa7X8r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 649FF206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 82919800B8; Thu, 28 May 2020 19:53:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8019B80010; Thu, 28 May 2020 19:53:01 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71311800B8; Thu, 28 May 2020 19:53:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 592D380010 for ; Thu, 28 May 2020 19:53:01 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1D85B181AC217 for ; Thu, 28 May 2020 23:53:01 +0000 (UTC) X-FDA: 76867780962.28.top62_8eb930efaae1c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 0409C6D73 for ; Thu, 28 May 2020 23:53:00 +0000 (UTC) X-Spam-Summary: 2,0,0,0f8a9feefd26fe24,d41d8cd98f00b204,3207qxg0kclywtahnwoiqooajckkcha.ykihejqt-iigrwyg.knc@flex--axelrasmussen.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2740:2912:3138:3139:3140:3141:3142:3152:3165:3353:3865:3866:3867:3868:3871:4117:4605:5007:6261:6653:6737:6742:6743:9010:9969:10004:10400:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:13161:13229:14096:14097:14181:14394:14659:14721:21080:21444:21627:30054:30091,0,RBL:209.85.219.202:@flex--axelrasmussen.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: top62_8eb930efaae1c X-Filterd-Recvd-Size: 6986 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 May 2020 23:53:00 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id i190so947056ybg.6 for ; Thu, 28 May 2020 16:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=XGMqQwnndi2D0kIOd8fRs3e9yQLxoc/+AqptDy+c8dk=; b=mBZa7X8ryPIaCW9k2DuaI60mMcnTbinIX3ABmtpuRFmwvWVtcp0dGCNjx8sGHXRWyO 3g9qYhidRLUvNzSaK4hlHqwNLVqh3X6JGWATs3+ziTkBG7ASddX0k9vhYSzADPrfd+X6 PejSGyWQ/jLxcM/9HTwsMOXoSUUZnB7pPeR9FKO84BMWwAO4CxBAVgV1LwMd64g+Sm6c trSUK4DZnHNtP6yOWtZU0Su8Xjv0Mrogv+wPHCJqxQntRkq19cV/oWkoRu0RUEVzzv34 wiF0PKkwFVZ2nxm7TWSQlHEdZ0wESIUI89uplbsCYVvQ9BmLdQ1nG4ukoIijp6oOOdWC 0iwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=XGMqQwnndi2D0kIOd8fRs3e9yQLxoc/+AqptDy+c8dk=; b=pHWAirw3x8tQMAm26PEMmxSMaEAy+8ZyNk+jq1tvzQYq83ZFoJt05sKZe9VNv+VCum Xa7AvdLJm6ECVqtS/5Vnl2S61erwDseysfJ8hMF3ImKgYmZ22eH7IYWAku+1X9ijx1Wm 35NsxV8dIElzEjlS+DDORcpdTHE8tKfqc1QM1c6lscnxK7ZqvdCrAt+seYE06/5y6akc tMWqkLa1eNrbCv36eA9uVBulVzs5lkwo/9LY48+qUfOfeILvQsrS/UUIPHcO+Jr+D/y4 livKV80nTFQ9cK2hB3rFC64IrQnAMIl8Tgh2isu7VCl9HsqSt5lL+n8oy6x+XPC2td6v azFA== X-Gm-Message-State: AOAM531U4+X3VfzxHYCz3FQxNFUbzzmbyDuw7A2JxjLS8DOHeT/hBNEl F4mRSU4uzvocV5f+RFuiSbCi5GJtLkA+ArV/auQm X-Google-Smtp-Source: ABdhPJwIS7bK1T6mMrfjsRUY0LC6TcdIrHTI+NXlXI0/bAT2o0dyiWoh778AfYHV+Kog73RIZyRpi4/AnxvHZZnwrlML X-Received: by 2002:a25:338b:: with SMTP id z133mr9235332ybz.329.1590709979886; Thu, 28 May 2020 16:52:59 -0700 (PDT) Date: Thu, 28 May 2020 16:52:56 -0700 Message-Id: <20200528235256.76129-1-axelrasmussen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog Subject: [PATCH v2 3/7] mmap_lock: add a histogram structure to struct mm_struct From: Axel Rasmussen To: 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 Cc: 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 , Steven Rostedt , Tal Gilboa , Thomas Gleixner , " =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= " , Vincenzo Frascino , Yang Shi , Yu Zhao , Axel Rasmussen X-Rspamd-Queue-Id: 0409C6D73 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: This histogram will be used to measure lock acquisition latency, when the acquisition is contended. Cases where we acquire the lock immediately with no contention are recorded as "0" (to avoid incurring the cost of really computing the time, while retaining the ability to get an accurate total lock acquisition count). Signed-off-by: Axel Rasmussen --- include/linux/mm_types.h | 11 +++++++++++ mm/Kconfig | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index d13b90399c16..efeb5db1959d 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -376,6 +376,10 @@ struct core_state { struct completion startup; }; +#ifdef CONFIG_MMAP_LOCK_HISTOGRAMS +struct histogram_rcu; +#endif + struct kioctx_table; struct mm_struct { struct { @@ -437,6 +441,13 @@ struct mm_struct { * counters */ struct rw_semaphore mmap_lock; +#ifdef CONFIG_MMAP_LOCK_HISTOGRAMS + /* Histogram of mmap_lock contended acquire delays. kmalloc'd + * so we can use a forward declaration, to avoid circular + * dependencies between headers. + */ + struct histogram_rcu *mmap_lock_contention; +#endif struct list_head mmlist; /* List of maybe swapped mm's. These * are globally strung together off diff --git a/mm/Kconfig b/mm/Kconfig index c1acc34c1c35..231862afc2ce 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -817,6 +817,19 @@ config DEVICE_PRIVATE config FRAME_VECTOR bool +config MMAP_LOCK_HISTOGRAMS + bool "mmap_lock histograms" + select HISTOGRAM + default n + + help + Record and report latency histograms describing mmap_lock + contention. Stats can be read from /proc//mmap_lock_contention. + True latency is only computed for *contended* acquires, to minimize + overhead. Uncontended acquires are recorded as having "0" latency. + + If unsure, say "n". + config ARCH_USES_HIGH_VMA_FLAGS bool config ARCH_HAS_PKEYS