Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.118 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796132720; b=AnATcuCRrHJx+8bd20nSVU3kVMP8G79/apqe0fkPiFguSvAmKq0Vu0Cb7ppepl9WHeJp IaWegu6R6Ep19O//axfzV62o9F/IzX7CvwvZMGF+7fxK9jaPXppb3pkIWlSKCAY0+wNs2 DSP1Z1d3Jpyrm4w/DtAGwf66E4HYkNzz3QMp+4wC/WpOqElHZ+VtC8ifidEPYKm3AgREn kCtzp3ROr9dZPIPNkvhPGFfq96mFpUUdk8yqyMB97Q2hqq6AfuYyuQpWme0l9X+ye9Xl2 ee/8TMjXsc+V/dkWkpHjH+CUDZeUdcj2hCK3PDyAzWVfC3HHw0HiamRAU6atcq+yIzA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796132720; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:In-Reply-To:References:Date:Message-ID:User-Agent: MIME-Version:Content-Type; bh=nIxAp4bGVa/70hZxZNgD0cRvwKyf5ieQ8Rh4/aZx1BU=; b=zCRef6Y11l/FYOPT7EL58X+cDc/nFqx8QFf2S264/O44paTQjT2j+guHz3rbR6XTTavT 4jyD90JeaP+vZeCrvZq1A3zL6AK6QHG8yFNaKOI4kQnDABqwOnYb9Bk3j0BEh8dkxnvFF SBm2Tf7rEvPq3Z03KtvFgwkIDuh1S7Agk59oGlw+OH9VSf6TZq2wUIIFkMeeyuGlKhFXF o7wRuJkdz4R6AYLpdwOx336trQEd5xRw3dJ7ls5dQDEGTnyH9yjslsI/VjzXBL7P/B50J H+He3IPcRotd103gPe4WCyoRf4IDOvwYLTDrvPZsZ8SBNnQWeuK5XPZ3ps1AKnsLhbA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=QNNUXB8V; arc=none smtp.remote-ip=115.124.30.118 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C385606A32C for ; Tue, 1 Dec 2026 13:45:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9C385606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=QNNUXB8V DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796132717; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=nIxAp4bGVa/70hZxZNgD0cRvwKyf5ieQ8Rh4/aZx1BU=; b=QNNUXB8VbNEylmRzv8z6LqU+emo1neZgOzeypiYQvwGnduOBICjm84TAfUCCAdlXx/HnW3JLaiXZ6Nwp+YeJqEzerWGfU4Q6OvYzwNjVtz1RVQqyXixTU3HuzYAzOXaTM4r5BVX/2kZorBgZZoVsIWa8QMuGBUG54KhXLaJHRpA= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=ying.huang@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0XG0ViWy_1796132714; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0XG0ViWy_1796132714 cluster:ay36) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 21:45:15 +0800 From: "Huang, Ying" To: Joshua Hahn Cc: Johannes Weiner , Dave Hansen , Andrew Morton , Michal Hocko , Shakeel Butt , Qi Zheng , David Hildenbrand , Gregory Price , Zi Yan , Rakie Kim , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [RFC PATCH 2/2] mm/vmscan: don't demote in memcg limit reclaim while the node has room In-Reply-To: <20261130215258.2202513-3-joshua.hahnjy@gmail.com> (Joshua Hahn's message of "Mon, 30 Nov 2026 13:52:57 -0800") References: <20261130215258.2202513-1-joshua.hahnjy@gmail.com> <20261130215258.2202513-3-joshua.hahnjy@gmail.com> Date: Tue, 01 Dec 2026 21:45:13 +0800 Message-ID: <87qzg1yv12.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Hi, Joshua, Joshua Hahn writes: > When a memcg hits a memory limit, reclaim demotes folios from toptier > nodes and only swaps out the ones it fails to demote. Demoted folios > stay charged, so it does not bring the memcg closer to the limit. > It still counts towards reclaim progress though: > - try_to_free_mem_cgroup_pages(): If demotion can satisfy the nr_pages, > pages are not swapped out. > - try_charge_memcg(): Demoted pages count towards progress, so retries > are not used up. > > When toptier nodes have room, this is the undercommit case that commit > 3f1509c57b1b ("Revert "mm/vmscan: never demote for memcg reclaim"") > describes at the end. A memcg at its limit keeps demoting its own memory > to the lower tier with no bound, as long as demotion target nodes have > capacity to take the demotions. This leads to memcg-limit bound > workloads on otherwise empty machines to run mostly out of the lower > tier. If NUMA balancing tiering mode is on, the demotions constantly > churn against promotion that then brings those pages back to DRAM. > > This has been observed in Meta production workloads, where we see > pgdemote_direct taking up about 80% of pgsteal_direct, and CXL bandwidth > continuously being hammered while DRAM still has 60% of its memory free. > > In can_demote(), for non-proactive cgroup reclaim, don't demote from a > node that pgdat_free_space_enough() considers to have enough room, as > long as memcg can swap. This is the same check that promotion makes > to determine when the toptier is full. > > This still leaves 3 participants in the cross-node aging process: > proactive reclaim, kswapd / global direct reclaim, and memcgs that > cannot swap out. > > Signed-off-by: Joshua Hahn > --- > mm/memory-tiers.c | 3 +++ > mm/vmscan.c | 5 +++++ > 2 files changed, 8 insertions(+) > > diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c > index caf28ca662f75..57a25cbd7741f 100644 > --- a/mm/memory-tiers.c > +++ b/mm/memory-tiers.c > @@ -305,6 +305,9 @@ bool node_is_toptier(int node) > * advantage of fast memory capacity, all recently accessed slow > * memory pages will be migrated to fast memory node without > * considering hot threshold. > + * > + * Memcg limit reclaim does not demote from such a node either; see > + * can_demote(). > */ > bool pgdat_free_space_enough(pg_data_t *pgdat) > { > diff --git a/mm/vmscan.c b/mm/vmscan.c > index bc7579d47f9b4..cfd40771b4bf3 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -250,6 +250,11 @@ static bool can_demote(int nid, struct scan_control *sc, > if (nodes_empty(allowed_mask)) > return false; > > + if (sc && cgroup_reclaim(sc) && !sc->proactive && memcg && > + mem_cgroup_get_nr_swap_pages(memcg) > 0 && > + pgdat_free_space_enough(pgdat)) pgdat_free_space_enough() is much larger than WMARK_PROMO. Is it better to use a watermark that is closer to it? > + return false; > + > /* Filter out nodes that are not in cgroup's mems_allowed. */ > mem_cgroup_node_filter_allowed(memcg, &allowed_mask); > return !nodes_empty(allowed_mask); --- Best Regards, Huang, Ying