From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57FCF3E9F8D for ; Thu, 23 Jul 2026 20:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784838085; cv=none; b=qdy1qr+CmlbFL6O5+lbUUXvXKbtwlzLQciIyo4E2wB4TSifj6KWbPegoNXvlcAmt1UYupAXu7uW8OXknEDk/6e2kd5w57P0uIXq81xthrPL6fc2uybccrXLSoBUai0D7rcA9iVSnzSedZjZVGzA6KlI8tYpWy8P0kBB2TEzL9A4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784838085; c=relaxed/simple; bh=qhTFtcs+K9pMyshGCzhFk2k3M3wv62ULXFylkT6mSU0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I4RZ3FrAkATXBTht562Nh6EgnmgRpMpwIRP/Vvu6JejC5CJk4jW0dVOY0zLyCqKGnMIAtnzTugx1CFp0yIYgFBuC1GIudsyXW2TyzEGNSaHeIPFPl78R0PO8ysnPQMrvRTKqe9CI/WwdguwXtw91n4o5Hm5zEIDoKWf3KbIB9wM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SsVXGtGl; arc=none smtp.client-ip=209.85.161.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SsVXGtGl" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-6aad8c40ca7so547414eaf.3 for ; Thu, 23 Jul 2026 13:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784838082; x=1785442882; darn=vger.kernel.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:content-type; bh=a7NoLvTE348K+Na68Jw9OquhlDUzGX30hZ/eyZXWDcM=; b=SsVXGtGl0faSCHR0qEjcqRIsQxxpspTuCvI/0teEvP5P4sNuhz13NpIHq3phS+uw57 5cukLHMjBp9HHK+hOnJgFhvLSEv0TT1xHTbtT5PW8U5cRGlQHEDluORXeXY3Nhu47dFu ZVZJZMBHVqeD4ANwny8qp/d/3YMPJWyAwSkKI3odjlMIke28nL2Jm4cCOnGtinv1UAuJ naigI7g5gX+InF3KYovQnsMEqjuoKPynMrfzcTCdX/iV9178kJ2DKno/GDCD/40PhOmH 8HbnvY8+jlFgElOvXjmlGDFNj3bnzeor3csU1jDBSxGGwP4l233Sz3VxVVNj/WKDMLwg B7yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784838082; x=1785442882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=a7NoLvTE348K+Na68Jw9OquhlDUzGX30hZ/eyZXWDcM=; b=JWJyX/Vrs0+bWe6e6RFjKqRPuT8o7ilpwtQ7kcha2B3ez+NroJfwzYPhAdMP8NdysL POuH/BeKM5hGmmrF3pUUX7LlXwkl8Dkpu1gK2wAnwqowOdvUHHJZ4h1cK7qnIWbQPZ0H oRILPYrJ1RDTi6BP8PIZXkLQIKOJa+7b/h5GCa1RRtdfkbmELo58/lEyEQl0euEcWABv o7whbGVvC1lpAdHoalPr/Ew47BDCQBG73gomvquIJJ7AXW9sgeYSGkRsgsm2kbx2Gi+P TCPyrE4XrwJ/oA4Q7JAGsz/V1iZdDdc/CpubsHFCtSnN+o34qGi+A8+O008TDYxzJ4MA U9ZQ== X-Forwarded-Encrypted: i=1; AHgh+RrAFtIBX/E3hkl6Vkx95lAse9YFAH61EKkXMZwCsSNBmLuWpoeSG/bcN9NSc6JVS5MOxIVTe3nQV388kK8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/BpUQEaLgRP3JoZlW5PVl/Xkw+nq2/QzDqUeN1HuPTkwvDbH5 0prnxN7o2wuq36agrzHNPXlQL33wUleSNCTAAhr27R5Q/e+WpbhzdFRH X-Gm-Gg: AR+sD10DeAsfAywBCspucP9whmOnhqu9gGXI+CEIU4T4l9GcAVff18cU0I1b4twp6Wm x3uNqq6sIruZBH3DQgYQDyKulHhE9rZOoJ4u4S0VncPa3we1xto2SupAG3pBCH/vsyonBl5uBlC 1Jm3+qzLejLNO3RtugdjRMEkUOwTbvUZvCqZRWZQSLkUEbZRclEbJxFXm7ul2kPqKOkh+bekeWK Ie0nsm+zyPgeMIRmHvM79J+f0y2i6atrDYOoEodumChaR10QDy34AfrBj/FG0UbL0RF7KuKDVum rrNY/j+OSqwjCBs52HdvcR08U05slUr8EhMtoKRHqxopKYwZpjkJjYHQayMqrOLTpwuPJGJhj2W hbFmc5GHX3evKH/okFmA++XdXebBNFkQSohkySQ4zfQDSxtg+47OuceKnMVMhhiCmihXf1IY/wx tq/LJhePB5Xqkp5R/Jwa+KSbwJkip1FOQ= X-Received: by 2002:a05:6820:7042:b0:69e:43a2:349 with SMTP id 006d021491bc7-6aad4139c06mr1581776eaf.47.1784838081210; Thu, 23 Jul 2026 13:21:21 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:9::]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6aa79ef5a37sm4173918eaf.13.2026.07.23.13.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 13:21:20 -0700 (PDT) From: Joshua Hahn To: Gregory Price Cc: "David Hildenbrand (Arm)" , linux-mm@kvack.org, Tejun Heo , Johannes Weiner , Michal Koutny , Michal Hocko , Roman Gushchin , Shakeel Butt , Andrew Morton , Chris Li , Kairui Song , Muchun Song , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Kaiyang Zhao , David Rientjes , Yiannis Nikolakopoulos , "Rao, Bharata Bhasker" , 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, 23 Jul 2026 13:21:18 -0700 Message-ID: <20260723202119.3688800-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Thu, 16 Jul 2026 12:55:55 -0400 Gregory Price wrote: > On Thu, Jul 16, 2026 at 03:11:30PM +0200, David Hildenbrand (Arm) wrote: > > > > > > 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. Hello Gregory, hello David, So circling back here a little bit (sorry that it took a while to get back) > I think this is a naming problem. > > Maybe we should start calling this "initiator tier" or something. > Maybe tier is even the wrong notion here, but it's the best we have. I think the confusion is that "toptier-ness" doesn't give the full picture for whether a node is a promotion candidate, a promotion candidate node needs to both be toptier (adistance < toptier_adistance) AND also have CPUs. So a HBM node that is hotplugged can definitely be toptier in that it has a smaller adistance than the toptier_adistance, and will probably even have a smaller adistance than the DRAM node, but if it doesn't have CPUs, it won't be a promotion candidate. It gets a bit more confusing because this distinction is not a tier-wide distinction; you can have two HBM nodes hotplugged where only one of them is CPUless -- then we cannot make any statement on whether the tier is a proper promotion candidate, only that one of the nodes within that tier is a candidate. > But I agree "toptier" naming doesn't generalize to complex systems. The merits of calling a node a "toptier" node is therefore a little dubious I think, it's just one part of whether a node can be promoted to. Anyways, I think this is outside the scope of this series. I think that for the scope of what I am working on I will try to move away from referring to things as "toptier" nodes but rather call them "promotion candidate" nodes. I hope that distinction will make this series easier to understand and read. > > > $ cat memory.tiered_max > > > tier_0 20971520 > > > tier_1 31457280 One change here is that it is not really possible to have 0..N-1 indexed tiers, since those are not stable. For instance, hotplugging a HBM node (as David pointed out) would replace what tier_0 is. However, one thing that remains stable is the abstract distance (adistance) the tiers are associated with, so I'll preserve the ABI that I have right now, so we can have something like tier_42 20971520 tier_128 31457280 And if HBM does come up as the "highest tier" with the lowest abstract distance we will just have tier 16 1048576 tier_42 20971520 tier_128 31457280 And we will not have any problems with tier_0 defining DRAM and then later switching to define HBM. It is certainly less interpretable but I think this is the only way to have a stable set of tiers, since adistance is pre-calculated for all possible nodes at lateinit time. > > memcgs are currently not NUMA aware, so this could be one possible direction. > > > > But is "tier" the right abstraction? I really don't know. > Really I think we're trying to classify 3 general pools of memory > > - Precious: HBM > - Preferred: DRAM (initiator preferred targets) > - Non-Preferred: CXL (fallback and demotion targets) > > HBM nodes are already weird in terms of fallback ordering, but ignoring > that for a moment. > > Non-preferred "tiers" are slightly different than preferred "tiers". > > Under normal operation (assume no mempolicy or cgroup weirdness): > > 1) Direct reclaim NEVER targets non-preferred tiers (kswapd only) > 2) Promotion NEVER targets non-preferred tiers (promotion -> toptier) > 3) Under total system pressure (direct reclaim on top tier), we swap > directly from the preferred tier out to swap > > So non-preferred tiers don't have the same reclaim behavior associated > with them. In fact i'm pretty sure we could summarize non-preferred > tiers as being managed hyper-lazily in the current scheme. > > (if there's space, have at it - otherwise you have to wait for kswapd). > > In my head, I think what we mostly want is: > - Precious - controlled entry, Private node? > - Preferred - semi-precious, fairness desired > - Non-preferred - not precious, lazy managed, no fairness > > Just some food for thought. I've been poking at making non-preferred > tiers less lazily managed, and I'm just finding this results to massive > regressions. Thanks for your insights Gregory. All of what I am saying is just in aggressive agreement with what you and David have pointed out. I am working to make the next version generic across tiers. Thank you both! I hope you all have a great weekend, Joshua