Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp693287pxx; Wed, 28 Oct 2020 14:42:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBWSoFJZrWrI1JAoJNm7FDmGrDl6TOo0mdRt2hj0WdyaNAyUTCaEHYpPVT1eZI25w7schl X-Received: by 2002:aa7:c746:: with SMTP id c6mr937768eds.221.1603921321886; Wed, 28 Oct 2020 14:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603921321; cv=none; d=google.com; s=arc-20160816; b=Yf9QOIMjoEfSCOPfo9xaJZmyWASOCYYYLJ1QZelu5ZV4NoTHPUOHSdBLX+d+0YKiV7 ZZnX6rgfj1CNdiMFN4r5Q8HbrobkTL3rEnrJ+6SkTR5aRXdxDE3iGrVwMjWHQeaW50zs swoITuwx3222+R0Gm6lCNZSRqZLCST8TEIe3WCXNIX1kzNu+qvDPcNSBB/Uf15u+ENN/ 6I4wrdt9NpToA0qCQKAuxnnmUTWEMOZ195BRC1GTTFU8KuCErB/M91VW4pQbv55lq9zW TyOhrxWY64NhzAU/weN5XNjc73Wik8xdzYGLmS/Bntsssr9FHDB4e7SF/CwuNmL7y6Fj /MVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=I/LBifM/+WVHaRpaxKjR0QAKC1O3x8QI4e1T4nSFr0M=; b=bTPRCZ3vrsz5Ud41RTu7SI+rueGI3gEaCM4U43WriDQJFhhhms2Da5CPtu1we+E5BY 6+s61JMvY52uqxQCBQns2sKmHjYtBk+kFM81KCky8MMQ1qJK9K7xsGIO0T5kbzuk5t40 K41G50gqtjiIhyZS4u4FZWT2cInGEkFn+5NlLrOPGjOsqdMeWUrV6I1B3UGn4+OSewCM 8tk78yBeXuBZrQgrZPvXvn5uKG+DNvkxxkKhaxAIJJT/D2fh/Y6WyUViI0IYztsVG1Fz 41Cs1dV6xJNRoctx8xaG3BuJthfyjsfKdpXIyPzF9mw7SjR2L1N1CM/iKc4uJ6/O21Ks q3QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KbVPBhA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si553761edt.51.2020.10.28.14.41.40; Wed, 28 Oct 2020 14:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KbVPBhA9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1832916AbgJ0XHS (ORCPT + 99 others); Tue, 27 Oct 2020 19:07:18 -0400 Received: from mail-yb1-f201.google.com ([209.85.219.201]:33762 "EHLO mail-yb1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1832911AbgJ0XHR (ORCPT ); Tue, 27 Oct 2020 19:07:17 -0400 Received: by mail-yb1-f201.google.com with SMTP id c196so3182905ybf.0 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=kwaBqPSu8CIfKLJoEV3lm9mo3f7pZwU3cejD6qJiuIxLKDtsE0wCtoetAIUE9Ne9K3 kbXVbn4Lse4Eiju22bnylS4H12hzehTbvG99xB0B784GRB1rh6Icp21ADdvjpwcfdDPo IwLVnpJzkTPHEDWkr+u2ebkGOzuClBihVGIP5XLqlGeN8WrbFQmqzigNorJuUi2chWs0 gPZ2r1pYlE4EJ1hdP0+T7sZlx9LLTzbbEOh+qOKbJTM2ffoE3apJZDN+XriK7O9EwzAL GuLu1t71DaVyEKmG0F4JpsSnNoZfVCrS4PJs/RkuimZMq6hMBGT1WgtQ41oH8rni7Lhv ik0g== X-Gm-Message-State: AOAM531nZKRgcsP9usjVEoG5s/fd/JUjIMkpt7Nty0qDBsLsrcwwCO/X uRiRSxOmNg08vDMstxqppMXaTrTb1V0a5N2Wdgc8 Sender: "axelrasmussen via sendgmr" 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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