Linux cgroups development
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: linux-mm@kvack.org, Tejun Heo <tj@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Koutny <mkoutny@suse.com>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
	Muchun Song <muchun.song@linux.dev>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Kemeng Shi <shikemeng@huaweicloud.com>,
	Nhat Pham <nphamcs@gmail.com>, Baoquan He <bhe@redhat.com>,
	Barry Song <baohua@kernel.org>,
	Youngjun Park <youngjun.park@lge.com>,
	Qi Zheng <qi.zheng@linux.dev>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	Kaiyang Zhao <kaiyang2@cs.cmu.edu>,
	David Rientjes <rientjes@google.com>,
	Yiannis Nikolakopoulos <yiannis@zptcorp.com>,
	"Rao, Bharata Bhasker" <bharata@amd.com>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [RFC PATCH 0/9 v2] mm/memcontrol: Make memory cgroup limits tier-aware
Date: Thu, 16 Jul 2026 15:11:30 +0200	[thread overview]
Message-ID: <a8a0e540-414b-4174-a9f9-2c501fb46130@kernel.org> (raw)
In-Reply-To: <CAN+CAwPK4cW6k6LazZsbuvewswOwzM8VJgPvcg0jef7FwfF1qg@mail.gmail.com>

On 5/11/26 22:03, Joshua Hahn wrote:
> On Mon, May 11, 2026 at 5:56 PM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>>
>> On 4/23/26 22:34, Joshua Hahn wrote:
>>> INTRODUCTION
>>> ============
>>> Memory cgroups provide an interface that allow multiple works on a host to
>>> co-exist via weak and strong memory isolation guarantees. This works, because
>>> for the most part, all memory has equal utility. Isolating a cgroup’s memory
>>> footprint restricts how much it can hurt other workloads competing for memory,
>>> or protects it from other cgroups looking for more memory.
>>>
>>> However, on systems with tiered memory (e.g. CXL), memory utility is no longer
>>> homogeneous; toptier and lowtier memory provide different performance
>>> characteristics and have different scarcity, meaning memory footprint no longer
>>> serves as an accurate representation of a cgroup’s consumption of the system’s
>>> limited resources. As an extreme example, a cgroup with 10G of toptier
>>> (e.g. DRAM) memory and a cgroup with 10G of lowtier (e.g. CXL) memory both
>>> appear to be consuming the same amount of system resources from memcg’s
>>> perspective, despite the performance asymmetry between the two workloads.
>>>
>>> Therefore on tiered systems, memory isolation cannot currently happen, as
>>> workloads that are well-behaved within their memcg limits may still hurt the
>>> performance of other well-behaving workloads by hogging more than its
>>> “fair share” of toptier memory.
>>>
>>> Introduce tier-aware memcg limits, which establish independent toptier limits
>>> that scale with the memory limits and the ratio of toptier:total memory
>>> available on the system.
>>>
>>> INTERFACE
>>> =========
>>> This series introduces only one adjustable knob to userspace; a new cgroup mount
>>> option “memory_tiered_limits” which toggles whether the cgroup mount will scale
>>> toptier limits. It also introduces 4 new read-only sysfs entries per-cgroup:
>>> memory.toptier_{min, low, high, max}.
>>>
>>> The new toptier memory limits are scaled according to the amount of toptier
>>> memory and total memory available on the system as such:
>>>
>>> memory.toptier_high = (toptier_mem / total_mem) * memory.high
>>>
>>> For instance, on a host with 100GB memory, with 75G toptier and 25G CXL, the
>>> “toptier ratio” would be 75 / 100 = 0.75. A cgroup with the following memcg
>>> limits {min: 8G, low: 12G, high: 20G, max: 24G} might see toptier limits scaled
>>> at {min: 6G, low: 9G, high: 15G, max: 18G}.
> 
> Hi David!!
> 
> It was great seeing you at LSFMMBPF. I didn't get a chance to have a
> conversation with you at Zagreb but hopefully I will be less shy and say
> hello next conference : -)

Sorry for the late reply :) Yes, hopefully talk to you in person next time!

> 
>> Assume you have a bigger hierarchy (HBP, DRAM, CXL), or assume you have multiple
>> NUMA nodes with a hierarchy each.
>>
>> Your proposal doesn't really seem to be very versatile, or am I wrong?
> 
> Let me address these comments separately!
> 
> First, for the multi-numa-per-tier case, I think this is already pretty well
> handled by my series. Once we realize that a memcg is consuming too much memory
> from a tier, we trigger reclaim from that memcg via
> try_to_free_mem_cgroup_pages,
> which as far as I can tell already handles the multi-numa per memcg case.
> Other than restricting the scan_control's nodemask to target the nodes
> from that tier, I don't think there's anything else to be done.

I am not really sure about the "toptier" notion, in particular if your memory
hierarchy is not static.

Imagine that you have only DRAM in your system. Then you hotplug some slow CXL
memory. The you hotplug some HBM CXL memory.

The meanting of "toptier" changes, which is rather confusing to me.

> 
> Next for the 3+ tier case, I think this is a lot more scalable than it seems
> at first. This series depends on another RFC that I sent out [1],
> which pushes the concept of "stock" from memcg to page_counter, which means
> that it is more scalable to just add more page counters to each memcg.
> This means that each tier would just need another page_counter to track its
> memory usage, and we trigger selective reclaim on the tier that is being
> targeted via the scan control nodemask we introduce in this series.
> 
> At my talk in LSFMMBPF, Usama noted that the user-visible API should probably
> remain the same, no matter what. The way I have currently established the
> memcg files aren't really scalable, so Usama suggested turning the
> "memory.toptier_XXX" sysfs files to "memory.tiered_XXX", which would include
> a newline-separated / space-separated list of per-tier limits. Something like:
> 
> $ cat memory.tiered_max
> tier_0 20971520
> tier_1 31457280
> ...

memcgs are currently not NUMA aware, so this could be one possible direction.

But is "tier" the right abstraction? I really don't know.

Are tier numbers really what we want? I don't know.

We'd really need some feedback from memcg folks.

> 
> So we have a way to make both the user-facing side stable, and the internals
> also more scalable.
> 
> With that said, I've opted to leave the internals to 2 tiers for now -- I think
> it is not too late to add the generalization series when we start seeing
> 3+ tier systems out there in the wild. My goal was to introduce tieredness,
> and we can work towards generalization in a future work.
> 
> On that note, it seems like in general mm is aware of 3+ tiers, but most of the
> existing work revolves around distinguishing between toptier/everything else.
> I got this impression from reading mm/memory-tiers.c -- but please feel free
> to correct me if you feel like I have the wrong idea here : -)

I assume you're right, but it's something different if we end up providing a
proper memcg API towards the users.

> 
> So perhaps the generalization work would benefit from first introducing more
> general tier awareness (not just toptier vs. rest) in memory-tiers.c.
> 
> What do you think? Does this approach of introducing toptier restriction for
> now, and then generalizing in future work make sense to you?

I'd suspect that we'd want to support multiple tiers from day one -- especially
get the interfaces right.

-- 
Cheers,

David

  reply	other threads:[~2026-07-16 13:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 20:34 [RFC PATCH 0/9 v2] mm/memcontrol: Make memory cgroup limits tier-aware Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 1/9 v2] cgroup: Introduce memory_tiered_limits cgroup mount option Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 3/9 v2] mm/memcontrol: Refactor page_counter charging in try_charge_memcg Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 4/9 v2] mm/memcontrol: charge/uncharge toptier memory to mem_cgroup Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 5/9 v2] mm/memcontrol: Set toptier limits proportional to memory limits Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 6/9 v2] mm/vmscan, memcontrol: Add nodemask to try_to_free_mem_cgroup_pages Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 7/9 v2] mm/memcontrol: Make memory.low and memory.min tier-aware Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 8/9 v2] mm/memcontrol: Make memory.high tier-aware Joshua Hahn
2026-04-23 20:34 ` [RFC PATCH 9/9 v2] mm/memcontrol: Make memory.max tier-aware Joshua Hahn
2026-05-11 15:56 ` [RFC PATCH 0/9 v2] mm/memcontrol: Make memory cgroup limits tier-aware David Hildenbrand (Arm)
2026-05-11 20:03   ` Joshua Hahn
2026-07-16 13:11     ` David Hildenbrand (Arm) [this message]
2026-07-16 15:29       ` Joshua Hahn
2026-07-16 16:55       ` Gregory Price
2026-07-16 17:33       ` Joshua Hahn

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=a8a0e540-414b-4174-a9f9-2c501fb46130@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=bharata@amd.com \
    --cc=bhe@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chrisl@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kaiyang2@cs.cmu.edu \
    --cc=kasong@tencent.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=qi.zheng@linux.dev \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=yiannis@zptcorp.com \
    --cc=youngjun.park@lge.com \
    --cc=yuanchu@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox