From patchwork Tue Oct 27 23:07:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 11862239 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 96F8261C for ; Tue, 27 Oct 2020 23:07:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3F6A52222C for ; Tue, 27 Oct 2020 23:07:18 +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="KbVPBhA9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F6A52222C 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 3A0346B005C; Tue, 27 Oct 2020 19:07:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 34F946B005D; Tue, 27 Oct 2020 19:07:17 -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 23DCC6B0062; Tue, 27 Oct 2020 19:07:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id E7E8A6B005C for ; Tue, 27 Oct 2020 19:07:16 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8CB8D3626 for ; Tue, 27 Oct 2020 23:07:16 +0000 (UTC) X-FDA: 77419243272.04.quiet38_13105a827280 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 739EB800106C for ; Tue, 27 Oct 2020 23:07:16 +0000 (UTC) X-Spam-Summary: 1,0,0,67b8416401c62842,d41d8cd98f00b204,3iqiyxw0kcnc3q7ek3lfnll7g9hh9e7.5hfebgnq-ffdo35d.hk9@flex--axelrasmussen.bounces.google.com,,RULES_HIT:41:152:355:379:541:966:967:968:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:1801:2196:2198:2199:2200:2393:2525:2559:2564:2682:2685:2731:2736:2859:2904:2912:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3152:3355:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4117:4321:4385:4605:5007:6261:6653:6691:6737:7875:7903:8531:9025:9969:10004:10400:11026:11232:11473:11658:11914:12043:12048:12291:12296:12297:12438:12555:12683:12895:13138:13231:14181:14394:14659:14721:21080:21222:21433:21444:21451:21627:21740:21939:21987:30034:30054:30070,0,RBL:209.85.219.201:@flex--axelrasmussen.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yg6d3skkqbayznfa4aqof4hotrqycyemawai7skj8sp3inpdyt3k9kut5kzz1.1j5wcyc hcwpobws X-HE-Tag: quiet38_13105a827280 X-Filterd-Recvd-Size: 6028 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 23:07:15 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id b25so3171680ybj.2 for ; Tue, 27 Oct 2020 16:07:15 -0700 (PDT) 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=I/LBifM/+WVHaRpaxKjR0QAKC1O3x8QI4e1T4nSFr0M=; b=KbVPBhA9IiQ+iud7lnAC/gSuu6WvRf9aYf5QWO+OJgEdMx92YhzKAbart8/hS+gKnN qaWsNPtp5BCWJbEn3RH2tFaOmOM1NMqaPTaSCMX7zmcCXI5hF3JNxRNIJe88AWPQIzux 3sTiZbTGZeTBqw4f3UwdQP8qOsY4EM/27qldD8WxxcpZ9++cKDzFfQndMXW2EWc+65cx Hopb9gepeI7m5/mlFNBO6BjKizn/IncT1qXMdGECSc9r5oL6ntZ7xr7B/mFNXqLug+7J HyjpRjJUj9QklUKDUy+byNGFAOzEDHuj8KT68tp8ON8gzR0KRX9UI5B5iokTW/HzrCD4 FazA== 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=I/LBifM/+WVHaRpaxKjR0QAKC1O3x8QI4e1T4nSFr0M=; b=NR+Im8GYJbaBaw/sNstshMoMx/3Ic9GgglSEuSdBQf0dyXutNidFeZAQaftwuSujQJ fT8a9/vsxvTRUgCPXImX/9axjn++yfgDsh6CcauOpyAEfzx7SEKXZEaXsYH7Ae2WOXvU 0UnkbycRjgATiY82QkgmtQsSSMN3CAfn82faZLmih9k/dlkoDXxSWw5c4b8OhIJ0XLpn 9mJ3OadnJJiQqICdWaepWIJtN/2gnpUVXU70vCN4PV44Wz4eYlTAaTnI0WFqhhUOkK+D ZyNV9BhdW/pCY6j2nKC9IH2IF8/ylOmtSC4SzUVhtC2cUYVpvkA53ydA5DTMi7r9tkRe Ibkw== X-Gm-Message-State: AOAM532QKy0wp2FA+zH1PAlNaAILZW4pMD9rkA543Czwpg5316Z+Hvmf FwqDaovEf2+ZqeFBS5WDX5tOYXoMm3WTLXVQkTuH X-Google-Smtp-Source: ABdhPJwSnCSOzg2YHYNimogzE/KLllYmDLWuCJeCvRlDF7bWaV1OVkBfKGXl63pROwxs+ucCBvoczfPuZfJD/QkyMHmw X-Received: from ajr0.svl.corp.google.com ([2620:15c:2cd:203:f693:9fff:feef:c8f8]) (user=axelrasmussen job=sendgmr) by 2002:a25:8091:: with SMTP id n17mr6600207ybk.291.1603840034996; Tue, 27 Oct 2020 16:07:14 -0700 (PDT) Date: Tue, 27 Oct 2020 16:07:10 -0700 Message-Id: <20201027230711.2180435-1-axelrasmussen@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog Subject: [PATCH v5 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 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 upon linux-next (since it depends on some recently-merged patches [1] [2]). I removed the existing {Reviewed,Acked}-by: lines from v4, since I think the patch has changed significantly enough to warrant another look (and I figure it's better to err in this direction in any case :) ). 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 | 95 +++++++++++++++- include/trace/events/mmap_lock.h | 107 ++++++++++++++++++ mm/Makefile | 2 +- mm/mmap_lock.c | 187 +++++++++++++++++++++++++++++++ 4 files changed, 385 insertions(+), 6 deletions(-) create mode 100644 include/trace/events/mmap_lock.h create mode 100644 mm/mmap_lock.c --- 2.29.0.rc2.309.g374f81d7ae-goog