From patchwork Fri Oct 25 00:25:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JP Kobryn X-Patchwork-Id: 13849861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58AF8D10395 for ; Fri, 25 Oct 2024 00:26:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D96CB6B0083; Thu, 24 Oct 2024 20:26:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1E986B0085; Thu, 24 Oct 2024 20:26:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B48466B0088; Thu, 24 Oct 2024 20:26:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 93B8B6B0083 for ; Thu, 24 Oct 2024 20:26:09 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A8D05AB354 for ; Fri, 25 Oct 2024 00:25:31 +0000 (UTC) X-FDA: 82710231534.13.2E6B232 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf04.hostedemail.com (Postfix) with ESMTP id 2A13A40009 for ; Fri, 25 Oct 2024 00:25:42 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Jltdf5sD; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729815928; a=rsa-sha256; cv=none; b=mi2TqUYi4tdlnLSW+eIjLMYLD/hJxY2UBAfU1srRVnuBojYdR+BW0hthco5Hrj/DasnK2k YgohTimDZiT3ZjOjMlLx1Vt6A1374GrSxFUgJ6IjkowCHc6aihdyoRetiDP1gSX9iE4AUY /MI6zK4GCTo9niuXaDR9wBBgtwQWXzM= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Jltdf5sD; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729815928; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eleAA8GQoILopeSGwt8qD2sFnpMPZ+qYQRQD58BJFx4=; b=rlNQ+RCdR7EzJ02lazUQej5j3vYpCLpYM7890IcyrCXuuq6ffbpt7RLKhSfm588r109uVn ENuRoGT9Xl3naFAjTp2DTjONX0A0Jt7NsTW59BI+hPS8BaRuTEc3D3Z3rImvyKBlJURLVt jBuKtiWieW8ekKGOZBlyp/0cKp1SHf8= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-71e953f4e7cso1071991b3a.3 for ; Thu, 24 Oct 2024 17:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729815966; x=1730420766; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eleAA8GQoILopeSGwt8qD2sFnpMPZ+qYQRQD58BJFx4=; b=Jltdf5sD9q/JBvMopYSXnkfsL08x8ctQlghd705uYmZGxtWn3uZIqvtT/Eu/Zgi+TS /URgI8HpQSEX7kF7uwTJ/w1puWhQZKR1XWm7Y5gmcLtlsSmuSyT4NIMkHiV7ofXhIp1g CBzzQ45egoS40dj511Q/o+0L/8GKlZ5e6eJ7QFAhYtQ2UoQmawA9eYUd/s1gM1s2Jgl4 Q9lpTlnD+rTo1O22/FSuZ8RXeGvXRuDHfdI8yDY7hQpyeHuOX9YKRSVNPr4OZLxs2oFs pHYBrZPe6LTD53lvm7vnWUTx7L1fhMk4CUeFIgp1jpdGLujEq5+l9HQROlVjb+9XD7ri Bblw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729815966; x=1730420766; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eleAA8GQoILopeSGwt8qD2sFnpMPZ+qYQRQD58BJFx4=; b=NPvzxmBdO04ayB++gFS10qnrbKWsjMBIoPsrZQRGW+aSzLkBO+j5/SrXKnE/m3HmIk 1OfHGffBcMVK4D8pli8t2CTHFj6qHKrkviwrtIgiSvoaljmI/Ew6tdmbYOXojIYSjUXh toOpUfX3xWQV9SIzhqkw9aZaTsKHLkWhIifUDyNq6fT/vMp8tsVsQz6/VutapDM8HOR8 CL5WTJFP6bVpK8t8jg0OvaQUgZpMfukTOYPmSvmP7x45QKdH7mf3cxnqFus/Osi4UZX1 g9poLnghM1ysRUbvvqjgOly0wV0zCnRo5Qbka/M9/vw7k4oevwLKQ13o6YJ3nDpyFySp nK0g== X-Gm-Message-State: AOJu0Yxjx55ow3jJ60EnYdJ5/ltAoHIu4SR+oASbeSt5dPNLw1aPV7Wn 15G9TRqZOpDjxfyjJREUL8eBnAixzJsaqzzG2QZB5omTV1QuF/9hhiD8wMBH X-Google-Smtp-Source: AGHT+IFku3793G7NqJ6klFI9OVEwE0ZbQKW5RkBJ07ubX56OXMplVCNsWge2Qq5pPtxU4sCKi2RQfw== X-Received: by 2002:a05:6a00:2ea3:b0:71e:e3:608 with SMTP id d2e1a72fcca58-72030cd4786mr10469056b3a.26.1729815965865; Thu, 24 Oct 2024 17:26:05 -0700 (PDT) Received: from saturn.. (c-67-188-127-15.hsd1.ca.comcast.net. [67.188.127.15]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72057a0b707sm21572b3a.128.2024.10.24.17.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 17:26:05 -0700 (PDT) From: JP Kobryn To: shakeel.butt@linux.dev, hannes@cmpxchg.org, yosryahmed@google.com, akpm@linux-foundation.org, rostedt@goodmis.org Cc: linux-mm@kvack.org, cgroups@vger.kernel.org Subject: [PATCH 1/2] memcg: add memcg flush tracepoint event Date: Thu, 24 Oct 2024 17:25:10 -0700 Message-ID: <20241025002511.129899-2-inwardvessel@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025002511.129899-1-inwardvessel@gmail.com> References: <20241025002511.129899-1-inwardvessel@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: euh3o1f4dtmix4wpsy5cu6ucoeq9fm37 X-Rspamd-Queue-Id: 2A13A40009 X-Rspamd-Server: rspam02 X-HE-Tag: 1729815942-315730 X-HE-Meta: U2FsdGVkX1/IOs3YKiV96ujPX1qYL8dYPhxGc2stQHMZ780eUuIwxj/rgrFsz708BY/HNqAUsy+sMKuLNFsQaoif5c7iDAQlsbklf7FD0Zw1guE9rChaRb6ROfNPKIkfBQwwuw535Az13hJA6C4VG9kuJc4VC5wNdAFQDHBjls2yVAdkvPOpAdIVZ01k2C+S5pWlNe9H3RkaHrY2jXZb/2zJ1iQOwf90iiX4gzLqOof5EnwDCd5UA0nOLTRLd2fTFFK8AttyIp9Fh1cObA45tZcaR0PHhK5TM0QvW+bfCv8ygnFwbBGP78AEQt6gVwEiih8DxVvh/SDAyioR2Ec+uKsdDqvmZBRTTNJw51aH+WtJ7fNAZDsgI/QY6jg0OeTNjotavNP8Wat7rb7eCrUlzLznuSgSEB7OM0Zc/kmBkHINmaJ7V+3Zt89senue9FXGxNZBqvP2bcL3Dt1PNAZZO31HJmszXJmlHVee+V4WVwS9n3Wy7c6O2yllWM9p/NwQYdstpd1UFoSGA7GM1AAsbGYa73Owktx0nYbsYSsRBys3OPKiaveit5EtReSC+Dw2eB3cnfNaRZ9disU7rVlqTiQrTi5ccN//qYXbeNHJzOduy32xFsqf6sEFMpXaA2aT1j5oKkX1MIvGYUOOikJ6hi6guC+m5evfTRyMzMaWSqWj2CzCe5t6NJFqMmNmRCNuzHLwnHM35WUWNG7nyEzZvsB3cncwGAD7C0uWVp7SrAvswv8LaouSzNWGzCpoMvlgfpn/rbWwx5XCD9lkrARDWFMeCvS2vmb6Db9IX82ILIC2Vh9wVqkcoP/1wU1Auq5OQ+89Fy7BDyQgNbrmeWcd2WTL1GznKJSHs8yN72pO5v82+JWI/XceYOfAORBa6C7mqgAe0lCYlXf7K4fizfF1vRXbUhbUzpVUDqdwIJImIoP9Mh4Vaex8tJFTWJdOdSmtSD7hAoTjGTO6hHriOn3 igzUQQzb aW23bZodMqZkpPm4hEGMXw+I3BchQo12IhJhE0SyyguwRKpmGDhBvUkV8qBqAZG0enOyHvABOXiUBqbqOnk+2ObHuDxnUSf5AZ4Y2cuGR0GWC0FLEiBM71xCXmUWXBk4gjNy777AYCv/Ws2aAnZSnz8RYzFYgMuEja5Cs4SOrnz8EN4Y0AhJS7qsw9hupoLbID8jHAc+4EagbUqsdGbxopRtRGOoA6UHwwOiDN0VETvezPMZB4tI2sUQgpSRrX9Q3mIdrVkQSXvafdx376DLIZCu1DD4fVYqWrY1NPPq/HCKn4Vfbzxm+1ceZG8U0DIPd8f94KGZucPumk+R+08iJGXUbqDdq1GxJ6s056em3jjgl2k0hn/dJ4UyeKA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This is a tracepoint event that contains the memcg pointer and an enum value representing the reason associated with the flush. Signed-off-by: JP Kobryn --- include/trace/events/memcg.h | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/include/trace/events/memcg.h b/include/trace/events/memcg.h index 8667e57816d2..9cccf0f13d4f 100644 --- a/include/trace/events/memcg.h +++ b/include/trace/events/memcg.h @@ -8,6 +8,43 @@ #include #include +#define MEMCG_FLUSH_REASONS \ + EM(TRACE_MEMCG_FLUSH_READER, "reader") \ + EM(TRACE_MEMCG_FLUSH_READER_SKIP, "reader skip") \ + EM(TRACE_MEMCG_FLUSH_PERIODIC, "periodic") \ + EMe(TRACE_MEMCG_FLUSH_ZSWAP, "zswap") + +#ifndef __MEMCG_DECLARE_TRACE_ENUMS_ONLY_ONCE +#define __MEMCG_DECLARE_TRACE_ENUMS_ONLY_ONCE + +/* Redefine macros to help declare enum */ +#undef EM +#undef EMe +#define EM(a, b) a, +#define EMe(a, b) a + +enum memcg_flush_reason { + MEMCG_FLUSH_REASONS +}; + +#endif /* __MEMCG_DECLARE_TRACE_ENUMS_ONLY_ONCE */ + +/* Redefine macros to export the enums to userspace */ +#undef EM +#undef EMe +#define EM(a, b) TRACE_DEFINE_ENUM(a); +#define EMe(a, b) TRACE_DEFINE_ENUM(a) + +MEMCG_FLUSH_REASONS; + +/* + * Redefine macros to map the enums to the strings that will + * be printed in the output + */ +#undef EM +#undef EMe +#define EM(a, b) { a, b }, +#define EMe(a, b) { a, b } DECLARE_EVENT_CLASS(memcg_rstat_stats, @@ -74,6 +111,25 @@ DEFINE_EVENT(memcg_rstat_events, count_memcg_events, TP_ARGS(memcg, item, val) ); +TRACE_EVENT(memcg_flush_stats, + + TP_PROTO(struct mem_cgroup *memcg, enum memcg_flush_reason reason), + + TP_ARGS(memcg, reason), + + TP_STRUCT__entry( + __field(u64, id) + __field(enum memcg_flush_reason, reason) + ), + + TP_fast_assign( + __entry->id = cgroup_id(memcg->css.cgroup); + __entry->reason = reason; + ), + + TP_printk("memcg_id=%llu reason=%s", + __entry->id, __print_symbolic(__entry->reason, MEMCG_FLUSH_REASONS)) +); #endif /* _TRACE_MEMCG_H */