From: Johannes Weiner <hannes@cmpxchg.org>
To: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: nphamcs@gmail.com, shakeel.butt@linux.dev, mhocko@kernel.org,
roman.gushchin@linux.dev, muchun.song@linux.dev, tj@kernel.org,
lizefan.x@bytedance.com, mkoutny@suse.com, corbet@lwn.net,
lnyng@meta.com, akpm@linux-foundation.org,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH v3 1/1] memcg/hugetlb: Adding hugeTLB counters to memcg
Date: Tue, 29 Oct 2024 16:48:46 -0400 [thread overview]
Message-ID: <20241029204846.GB636494@cmpxchg.org> (raw)
In-Reply-To: <20241028210505.1950884-1-joshua.hahnjy@gmail.com>
On Mon, Oct 28, 2024 at 02:05:05PM -0700, Joshua Hahn wrote:
> This patch introduces a new counter to memory.stat that tracks hugeTLB
> usage, only if hugeTLB accounting is done to memory.current. This
> feature is enabled the same way hugeTLB accounting is enabled, via
> the memory_hugetlb_accounting mount flag for cgroupsv2.
>
> 1. Why is this patch necessary?
> Currently, memcg hugeTLB accounting is an opt-in feature [1] that adds
> hugeTLB usage to memory.current. However, the metric is not reported in
> memory.stat. Given that users often interpret memory.stat as a breakdown
> of the value reported in memory.current, the disparity between the two
> reports can be confusing. This patch solves this problem by including
> the metric in memory.stat as well, but only if it is also reported in
> memory.current (it would also be confusing if the value was reported in
> memory.stat, but not in memory.current)
>
> Aside from the consistency between the two files, we also see benefits
> in observability. Userspace might be interested in the hugeTLB footprint
> of cgroups for many reasons. For instance, system admins might want to
> verify that hugeTLB usage is distributed as expected across tasks: i.e.
> memory-intensive tasks are using more hugeTLB pages than tasks that
> don't consume a lot of memory, or are seen to fault frequently. Note that
> this is separate from wanting to inspect the distribution for limiting
> purposes (in which case, hugeTLB controller makes more sense).
>
> 2. We already have a hugeTLB controller. Why not use that?
> It is true that hugeTLB tracks the exact value that we want. In fact, by
> enabling the hugeTLB controller, we get all of the observability
> benefits that I mentioned above, and users can check the total hugeTLB
> usage, verify if it is distributed as expected, etc.
>
> With this said, there are 2 problems:
> (a) They are still not reported in memory.stat, which means the
> disparity between the memcg reports are still there.
> (b) We cannot reasonably expect users to enable the hugeTLB controller
> just for the sake of hugeTLB usage reporting, especially since
> they don't have any use for hugeTLB usage enforcing [2].
>
> [1] https://lore.kernel.org/all/20231006184629.155543-1-nphamcs@gmail.com/
> [2] Of course, we can't make a new patch for every feature that can be
> duplicated. However, since the existing solution of enabling the
> hugeTLB controller is an imperfect solution that still leaves a
> discrepancy between memory.stat and memory.curent, I think that it
> is reasonable to isolate the feature in this case.
>
> Suggested-by: Nhat Pham <nphamcs@gmail.com>
> Suggested-by: Shakeel Butt <shakeel.butt@linux.dev>
> Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
next prev parent reply other threads:[~2024-10-29 20:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 21:05 [PATCH v3 1/1] memcg/hugetlb: Adding hugeTLB counters to memcg Joshua Hahn
2024-10-28 22:38 ` Shakeel Butt
2024-10-29 20:28 ` Roman Gushchin
2024-10-29 20:48 ` Johannes Weiner [this message]
2024-10-29 21:04 ` Nhat Pham
2024-10-30 11:35 ` Michal Hocko
2024-10-30 15:01 ` Johannes Weiner
2024-10-30 15:27 ` Michal Hocko
2024-10-30 18:30 ` Johannes Weiner
2024-10-30 20:43 ` Joshua Hahn
2024-10-30 23:26 ` Andrew Morton
2024-10-31 8:12 ` Michal Hocko
2024-10-31 16:09 ` Johannes Weiner
2024-10-31 19:03 ` Joshua Hahn
2024-11-01 1:34 ` Andrew Morton
2024-11-01 18:33 ` Joshua Hahn
2024-11-01 20:02 ` Andrew Morton
2024-11-01 20:28 ` Joshua Hahn
2024-10-30 14:52 ` Chris Down
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241029204846.GB636494@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=joshua.hahnjy@gmail.com \
--cc=kernel-team@meta.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan.x@bytedance.com \
--cc=lnyng@meta.com \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.