From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796177781; b=njv6EeWK4Lcz0uvDHV8ssg5a237oY/7dprG2pdIAP+404dsTHr98qh10+0ZIF4kUXqOg Lmiay0DclnfvTPF2SamvEZ6TPVISejZqO/zifgvCL+tS71MNTygidj+vc3uvw4mQLsmwv 85yjtf8z5VaJSGVhibD2+EpBb3PM38ZVGkiHTnGwV2WFuKzllw6ctrDXFlMnFEogg4RiS jC3YDzBWD8k+1h+yMCpjbtvCPowm7HaTB/j4S3Tddz5ayQcp6X9fvt3Tj5LTFNYQzHpVF +TRjSDqbI9C1xHJwNLFaYg0IPM1q5/dQmTijka8zduRzimxZiCTEVQmmmqw2v2X7fNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796177781; 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=qdKGx+z6joJIgZxb/rG8yJpHt3MT3r51za2hmiHxjdU=; b=BTJ1BB/wZDiLAK5bLN7H2H32bAzc4eAjC1qylDVtrjgz1WvQHLtcyPCwDmTyOw4gFhRz gGIHQbBVy/ymFUIc8HsPB/BbWZk5nfwIKXpnB23fN/PAyNjmkmJek7itfrvldOOYOH6BO ajmgP6J9VJwOAF6gc11Zn5VvPWwSye3C6UztekF+gu1U7+PYqYnjdTht6GLa4j4CCYdSP QY3tPdy6w5nUPKBWV0/P6wZMLAMlfUBZz9fE1dA1pf6+t32DO+7fQSYX5WqrUQcAGFIMb z8oZs1bOO/teH3JBcOXVeA6o5qhpIqKDCNN36a5OP/Pa2ClcMFOY1+HhsnVLcFVoBVA== 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=h+mtEQYA; arc=none smtp.remote-ip=115.124.30.124 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 CC54A606A322 for ; Wed, 2 Dec 2026 02:16:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CC54A606A322 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) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=h+mtEQYA DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796177771; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=qdKGx+z6joJIgZxb/rG8yJpHt3MT3r51za2hmiHxjdU=; b=h+mtEQYANhvpoWP5mMXj1tBGR0qnifOdCzOPHCgRe73HLhm2t6sJzu6f9MTBGgiktYQOFeg1dkzanBaOezjIEE9wCXo7xsv1sI/MjlGEL2gW80F2UQ2JJd+BoRlADdSEPW+RcjTmQ/tjqtOfLowf1ub8Un2Y1AmBcv1FKbKXp7I= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;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=20;SR=0;TI=SMTPD_---0XG5dJ60_1796177768; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0XG5dJ60_1796177768 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 10:16:09 +0800 From: "Huang, Ying" To: Johannes Weiner Cc: 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: <20261201155714.294531-1-joshua.hahnjy@gmail.com> (Joshua Hahn's message of "Tue, 1 Dec 2026 07:58:52 -0800") References: <20261130215258.2202513-1-joshua.hahnjy@gmail.com> <20261130215258.2202513-3-joshua.hahnjy@gmail.com> <87qzg1yv12.fsf@DESKTOP-5N7EMDA> <20261201155714.294531-1-joshua.hahnjy@gmail.com> Date: Wed, 02 Dec 2026 10:16:07 +0800 Message-ID: <87fqwgzau0.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 Joshua Hahn writes: > On Tue, Dec 01, 2026 at 09:45:13PM +0800, Huang, Ying wrote: >> 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. > > [... snip ...] > >> > + if (sc && cgroup_reclaim(sc) && !sc->proactive && memcg && >> > + mem_cgroup_get_nr_swap_pages(memcg) > 0 && >> > + pgdat_free_space_enough(pgdat)) > > Hi Ying, I hope you have been doing well, thanks a lot for taking a > look at the patch! > >> pgdat_free_space_enough() is much larger than WMARK_PROMO. Is it better >> to use a watermark that is closer to it? > > Yeah, that's a good point. Thinking about it again, I guess space_enough > is only the ratelimiting threshold, so it wouldn't make much heuristic > sense here anyways. Maybe pgdat_balanced() is a better fit here? Then > this check here will be in agreement with kswapd. I'm not sure whether it's good to use pgdat_balanced() directly. Could we use a simplified version with just some extra free space to deal with stats drift? > Hopefully the rest of the commit makes sense to you. Yes. I think that it's a real problem we need to deal with. > Thanks again, > I hope you have a great day! You too! > Joshua > >> > + 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