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=-6.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 59107C5517A for ; Thu, 5 Nov 2020 21:17:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D9E420724 for ; Thu, 5 Nov 2020 21:17:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ntxuuYSI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D9E420724 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 D36336B0195; Thu, 5 Nov 2020 16:17:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC0386B0199; Thu, 5 Nov 2020 16:17:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B854E6B019E; Thu, 5 Nov 2020 16:17:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id 82BD26B0195 for ; Thu, 5 Nov 2020 16:17:48 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1640B362B for ; Thu, 5 Nov 2020 21:17:48 +0000 (UTC) X-FDA: 77451626616.09.hope17_2e00e70272cd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id E93CE180AD80F for ; Thu, 5 Nov 2020 21:17:47 +0000 (UTC) X-HE-Tag: hope17_2e00e70272cd X-Filterd-Recvd-Size: 6019 Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 21:17:47 +0000 (UTC) Received: by mail-qt1-f202.google.com with SMTP id i20so1774733qtr.0 for ; Thu, 05 Nov 2020 13:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=CWQ9UWAzLNf25Gm+QM5JO9SZkGZbnesBYaj1Ii23SGw=; b=ntxuuYSIC//Ipv5nwAlhlbI0u2ggda1uKlvsAZpzhngQvdJ5Euw0QzjPIzMUnqk711 xPRn/iciXDVVRfKK+PBec4MFO87PHwxvg0uMnVYNNVa3jSMq6YyuRmjhHHglUk1Exnxe iB6/5Ctz+2u/X1VxprIqJeLyV/G/968LJ16ay5VUty5Br/gG1FDTWEQUT8xWe2Lgnc21 9ZOCpcgjpEAjGVQ2g+e5vAO0FCz2eCrdVp/VzKWtTEnaCXxReKaJ7A6kULLy2l3VlUA0 9jjqv5XxPm4Qp7Ix5Dk7as94TeIo+0G0gIfqTT6nyNB0M5iRtbov7p8qLpcijJzqeGdD Nz6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=CWQ9UWAzLNf25Gm+QM5JO9SZkGZbnesBYaj1Ii23SGw=; b=uEJpcDsqtbvN7pgqv3euTwsqZpZJCtzvaA8mKNaWSmWra8UzctZ+7dbCtKeTNDBkP2 pE2ppYquakp51Ox2PlCyQ0q3UYGTsv099eso/sxzwbkEK9L1LylBuZFDFyaWrbR09DnA oS0O47vhMtUVFpLPEiRt1HmzRTFNIPXhKqcAY1vXS2yByU/trzNBpZfz1DvqPK9Nqq0Q lNNn5P1+1Qo9jSfyTFoqJiwtgzw/rh/kAtA3RN4Z69dFBF1+R6wfWUoWrGzo/CiR1vUy DmCr7PaXs+7lDDd/37wr8tGFeKuowdZvLpAZRMjiUkxpBV0+vBQTj2thc5PIKItORQfM CbmA== X-Gm-Message-State: AOAM533Us0OHVlqcqcEAmKkfEnTDeFxtmogCeCuJPgGXQWQNvOpUrQDj IngTuo0nd+CNXswF7T9dB4u67T20RQXN+QyFXqzJ X-Google-Smtp-Source: ABdhPJxpCI0j/7GQ1w8tNdmeM3i5b0/jhF/8/xh2whMjpj6P07qokJapGr3eV5NRC9G5uhsSSWqiOoVRYrNepOwWYpLj X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:f693:9fff:feef:c8f8]) (user=axelrasmussen job=sendgmr) by 2002:ad4:4041:: with SMTP id r1mr2103637qvp.49.1604611066573; Thu, 05 Nov 2020 13:17:46 -0800 (PST) Date: Thu, 5 Nov 2020 13:17:38 -0800 Message-Id: <20201105211739.568279-1-axelrasmussen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v6 0/1] mmap_lock: add tracepoints around lock acquisition From: Axel Rasmussen To: Steven Rostedt , Ingo Molnar , Andrew Morton , Michel Lespinasse , Vlastimil Babka , Daniel Jordan , Jann Horn , Chinwen Chang , Davidlohr Bueso , David Rientjes , Laurent Dufour Cc: Yafang Shao , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Axel Rasmussen Content-Type: text/plain; charset="UTF-8" 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 patchset adds tracepoints around mmap_lock acquisition. This is useful so we can measure the latency of lock acquisition, in order to detect contention. This version is based on v5.10-rc2. Changes since v5: - Michel pointed out that rwsem_release in mmap_read_trylock_non_owner doesn't actually release the lock, it just releases lockdep's ownership tracking. So, it's incorrect to call __mmap_lock_trace_released there, so the call has been removed. Changes since v4: - Redesigned buffer allocation to deal with the fact that a trace event might be interrupted by e.g. an IRQ, for which a per-cpu buffer is insufficient. Now we allocate one buffer per CPU * one buffer per context we might be called in (currently 4: normal, irq, softirq, NMI). We have three trace events which can potentially all be enabled, and all of which need a buffer; to avoid further multiplying the number of buffers by 3, they share the same set of buffers, which requires a spinlock + counter setup so we only allocate the buffers once, and then free them only when *all* of the trace events are _unreg()-ed. Changes since v3: - Switched EXPORT_SYMBOL to EXPORT_TRACEPOINT_SYMBOL, removed comment. - Removed redundant trace_..._enabled() check. - Defined the three TRACE_EVENTs separately, instead of sharing an event class. The tradeoff is 524 more bytes in .text, but the start_locking and released events no longer have a vestigial "success" field, so they're simpler + faster. Changes since v2: - Refactored tracing helper functions so the helpers are simper, but the locking functinos are slightly more verbose. Overall, this decreased the delta to mmap_lock.h slightly. - Fixed a typo in a comment. :) Changes since v1: - Functions renamed to reserve the "trace_" prefix for actual tracepoints. - We no longer measure the duration directly. Instead, users are expected to construct a synthetic event which computes the interval between "start locking" and "acquire returned". - The new helper for checking if tracepoints are enabled in a header is used to avoid un-inlining any of the lock wrappers. This yields ~zero overhead if the tracepoints aren't enabled, and therefore obviates the need for a Kconfig for this change. [1] https://lore.kernel.org/patchwork/patch/1316922/ [2] https://lore.kernel.org/patchwork/patch/1311996/ Axel Rasmussen (1): mmap_lock: add tracepoints around lock acquisition include/linux/mmap_lock.h | 94 +++++++++++++++- include/trace/events/mmap_lock.h | 107 ++++++++++++++++++ mm/Makefile | 2 +- mm/mmap_lock.c | 187 +++++++++++++++++++++++++++++++ 4 files changed, 384 insertions(+), 6 deletions(-) create mode 100644 include/trace/events/mmap_lock.h create mode 100644 mm/mmap_lock.c -- 2.29.1.341.ge80a0c044ae-goog