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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05DD1D149D6 for ; Fri, 25 Oct 2024 17:05:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ABF46B0082; Fri, 25 Oct 2024 13:05:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45BDE6B0083; Fri, 25 Oct 2024 13:05:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FC986B0085; Fri, 25 Oct 2024 13:05:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 133D96B0082 for ; Fri, 25 Oct 2024 13:05:03 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 84E04C0D7D for ; Fri, 25 Oct 2024 17:04:41 +0000 (UTC) X-FDA: 82712748342.20.A0328FC Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf21.hostedemail.com (Postfix) with ESMTP id 9F27C1C0022 for ; Fri, 25 Oct 2024 17:04:22 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YEAX2d62; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729875774; a=rsa-sha256; cv=none; b=GuRDyaT7nGv0+KjHx09GOzT93hhzTbx8d20rTj8n3LNyBYJWuG5lWjfIXcynW+6kioXH0w 0Ia+I74TmLWo7gQx7s/dazSoP2+Pb8vY5fTRFyAVsLIe/y1tFvczGEglH88eUOTyq9YHXF Tb9Gn1QaUsLbEqr+p+xGBCInODbwy+Y= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YEAX2d62; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.174 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=1729875774; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LRFIYl8E2jrWC1NtQtQF7GfyGiCK2124bLm5Fb0yKXA=; b=hsMSIXCUAR5LOVrqbD4H45FV0sBycevjwPksTU21LhdDdtd3prngIFhF81wGfoSZtPiYLS 5TSm+QFcA3kxCNUcvSpfbZQ+033K4VG5MLF32ld9H060hXK693THza71wRVPKyhTho/cjE RiGbEK4+/+duPUfl6fFhGzSY8J3RNSQ= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20cbca51687so19769475ad.1 for ; Fri, 25 Oct 2024 10:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729875899; x=1730480699; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=LRFIYl8E2jrWC1NtQtQF7GfyGiCK2124bLm5Fb0yKXA=; b=YEAX2d62TxsY6E7BwpW52LIKeUOY12JHcIqTcdL1F9SQrIqhNtUVia6aRnewbfA4VO MXYj6lD/KksHVJbYKgGoqu5zuJPIy9rUpc88GA1dbk1RTwhzUjSFy02HicRKbqzl+OIp W0OHLdWw8kn62OeaJODl1X1Hj5cIbh4k2CyTugjbj3LFCcW9A2qI6q65AByUEZ5LfBor 4UHozSXuZYGu2RohnoC2rFkiZoCwbDU4nL3rCvxq9V/0qCf2cZu7y5GItXYf+WCcdoaR OZiTU5eU27Ya28iijRQLQi0gG+oFGFqCvUIO10GIlzL4lqg/utefXbMqzu6jEWVY5hbO W79w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729875899; x=1730480699; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LRFIYl8E2jrWC1NtQtQF7GfyGiCK2124bLm5Fb0yKXA=; b=ZMxYDXkv9XQExYt2Trfs7cSRQetIAxPagxWBU7tOYtGis00ZwAegtmZlj7/H3OIq1/ zHN/yl5OVuUkIDgfe5ZT/d6z6nEyf04z5Cj7NSu9RL+LtaGWFTWEV6qYnxD2fq55VBow hi22/M6o8/loo40vnB958U398DHtqd/ZYEek5yOgBZJJwsq6jg8yRXpfbG2LoneT48Mb FsqJkyKW/vFYtm4vNpdI79QJKwN49mYqehphE+yGOT0sDU4qJrDV9cIVt6E5WorpVHFp D6wRUV6BEPH5cG/MHKUgmibU0wZ5QkQyBNfvpl0FvoQsjRnmBphAjKd6dZPheBZ7l6JX KEHg== X-Forwarded-Encrypted: i=1; AJvYcCW9DLCZwRXeDJLo+D+M4In4kF8QPqe+Sbahrnt64cSDT9GdQwhmg3pI6PHMq+8iCtxDOw44VyQdlg==@kvack.org X-Gm-Message-State: AOJu0YxSN8IMAKWZdLh7tN7Fy6DjOvqYMKMa3vYPTSxW9MSiQAW7VFCA vAJd4xzbYN1DZsrcg446UTG6Z6xtmfoYgsYkYMzJMtpz3cNblZWc X-Google-Smtp-Source: AGHT+IHzABdwO/ZAD7FHZkScyCXJXwKdC98MiRTqd1AzNXRXRklkzQ32SGxcKJ5BhQ8dh9IjbW30AA== X-Received: by 2002:a17:902:e54a:b0:20c:8907:902 with SMTP id d9443c01a7336-20fa9eb5a9bmr133739405ad.49.1729875899377; Fri, 25 Oct 2024 10:04:59 -0700 (PDT) Received: from [192.168.2.10] (c-67-188-127-15.hsd1.ca.comcast.net. [67.188.127.15]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-210bc044932sm11370515ad.253.2024.10.25.10.04.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Oct 2024 10:04:58 -0700 (PDT) Message-ID: <3da0f38a-51f1-43fa-a625-6bb1fe992920@gmail.com> Date: Fri, 25 Oct 2024 10:04:57 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] memcg: use memcg flush tracepoint To: Yosry Ahmed , Shakeel Butt Cc: hannes@cmpxchg.org, akpm@linux-foundation.org, rostedt@goodmis.org, linux-mm@kvack.org, cgroups@vger.kernel.org References: <20241025002511.129899-1-inwardvessel@gmail.com> <20241025002511.129899-3-inwardvessel@gmail.com> Content-Language: en-US From: JP Kobryn In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9F27C1C0022 X-Stat-Signature: tu8f3q1wfr6om9mbr6qswxjpcmcq9hzc X-Rspam-User: X-HE-Tag: 1729875862-110176 X-HE-Meta: U2FsdGVkX1/wA3njkecHg21Qo2jGh8vNTMLiIdD44ut8ouDvxz6Yqp/IZ+H1dEuE+OaMOhbzXUcKtBEKyKIfhWRPyXPKisjA7qoGgWDNZkZO4tDX89uFWYJNeYgOZrrhNQc13ubJPVwUMYyJCMP9DkwCxSnqs8oFz8DNoHh1e1Law2zt/uHyZo0l0HamQ1XWYEaC9YTKJIn5CiLU0zNKY8/VNgWy0zZD2bzGtK/Lc8wC//X1aiiotoUxZipWK+4bSZ4Wbqq7ziRtHPk1KOqmuKOcg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o0PQf2BscN0V0dw4wxYBqK5AD3MLbT9ZoYxHB7Z9r8R3vwmUzArsQDsd4Xg2Jbyg+b6ev3723Y 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: List-Subscribe: List-Unsubscribe: On 10/25/24 12:40 AM, Yosry Ahmed wrote: > On Thu, Oct 24, 2024 at 6:16 PM Shakeel Butt wrote: >> On Thu, Oct 24, 2024 at 05:57:25PM GMT, Yosry Ahmed wrote: >>> On Thu, Oct 24, 2024 at 5:26 PM JP Kobryn wrote: >>>> Make use of the flush tracepoint within memcontrol. >>>> >>>> Signed-off-by: JP Kobryn >>> Is the intention to use tools like bpftrace to analyze where we flush >>> the most? In this case, why can't we just attach to the fentry of >>> do_flush_stats() and use the stack trace to find the path? >>> >>> We can also attach to mem_cgroup_flush_stats(), and the difference in >>> counts between the two will be the number of skipped flushes. >>> >> All these functions can get inlined and then we can not really attach >> easily. We can somehow find the offset in the inlined places and try to >> use kprobe but it is prohibitive when have to do for multiple kernels >> built with fdo/bolt. >> >> Please note that tracepoints are not really API, so we can remove them >> in future if we see no usage for them. > That's fair, but can we just add two tracepoints? This seems enough to > collect necessary data, and prevent proliferation of tracepoints and > the addition of the enum. > > I am thinking one in mem_cgroup_flush_stats() and one in > do_flush_stats(), e.g. trace_mem_cgroup_flush_stats() and > trace_do_flush_stats(). Although the name of the latter is too > generic, maybe we should rename the function first to add mem_cgroup_* > or memcg_*. > > WDYT? Hmmm, I think if we did that we wouldn't get accurate info on when the flush was skipped. Comparing the number of hits between mem_cgroup_flush_stats() and do_flush_stats() to determine the number of skips doesn't seem reliable because of the places where do_flush_stats() is called outside of mem_cgroup_flush_stats(). There would be situations where a skip occurs, but meanwhile each call to do_flush_stats() outside of mem_cgroup_flush_stats() would effectively subtract that skip, making it appear that a skip did not occur. Maybe as a middle ground we could remove the trace calls for the zswap and periodic cases, since no skips can occur there. We could then just leave one trace call in mem_cgroup_flush_stats() and instead of an enum we can pass a bool saying skipped or not. Something like this: mem_cgroup_flush_stats() {     bool needs_flush = memcg_vmstats_needs_flush(...);     trace_memcg_flush_stats(memcg, needs_flush);     if (needs_flush)         do_flush_stats(...); } Yosry/Shakeel, do you have any thoughts on whether we should keep the trace calls for obj_cgroup_may_zswap() and periodic workqueue cases?