From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D87CA606A322 for ; Thu, 3 Dec 2026 04:09:32 +0000 (UTC) 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=cLL6GfpC Received: by kanga.kvack.org (Postfix) id 004E76B05B2; Wed, 2 Dec 2026 23:09:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1EAC6B05B3; Wed, 2 Dec 2026 23:09:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0DDD6B05B4; Wed, 2 Dec 2026 23:09:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7551B6B05B2 for ; Wed, 2 Dec 2026 23:09:31 -0500 (EST) Received: from smtpin02.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 056BD14059A for ; Thu, 3 Dec 2026 04:09:30 +0000 (UTC) X-FDA: 85501342542.02.4F7D88B Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by imf07.hostedemail.com (Postfix) with ESMTP id 1642340006 for ; Thu, 3 Dec 2026 04:09:26 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=cLL6GfpC; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=ying.huang@linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796270969; b=rtoCqyNgEiN2bHxKCYZdJY+kbpfyz88sPJ8mfFxIY4r8BkmynXLvxS7uxd5Ov9OP398hlm /rdEgH0UYJN+wdPubro/gTf3bzbrMJCER9NeNHGDu2deHyHxL21acH9ZtYSyqT1wK3msIn rGIORoX+WWCYdaC6rzNZ+DyTj4f5U2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796270969; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sD65MF3b+hxskOA8sNoFPmhA817VXnXd0E8vGdRB/oE=; b=A2aedBohubGXlRfYSjFzDlaVu6qLPx5X2OOJv22/tNPs3T/+fB8om0cnCBfVaBQnZCQ880 tgpY4OhBCyQC4QSCNbnBbhZ1LMQ4S5j8SkBxLsXRwp2RZjJMCWA0jvrpXP5r6v+Wid3RYB hadtSWhaDTlPR/q3raEWbK8l2NiaL60= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=cLL6GfpC; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf07.hostedemail.com: domain of ying.huang@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=ying.huang@linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796270963; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=sD65MF3b+hxskOA8sNoFPmhA817VXnXd0E8vGdRB/oE=; b=cLL6GfpCBnUa6yO98lJnbfcF/TpYcGZDzBZQQdqcShtO4JihHvPBFBSRbywFWN6Bnd5P33m1c5Apx+9gwa9czbnoHxfpPs2VPUVImHHmfc56PzZVa2LIqLZe5gEujB1Nuiyj6cG57WjnMWmW7dHxF6Ni3P51+6TTTW5bSYf7GOA= 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-contentspam033037009110;MF=ying.huang@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0XGCph30_1796270960; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0XGCph30_1796270960 cluster:ay36) by smtp.aliyun-inc.com; Thu, 03 Dec 2026 12:09:21 +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: <20261202150538.294531-6-joshua.hahnjy@gmail.com> (Joshua Hahn's message of "Wed, 2 Dec 2026 07:28: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> <87fqwgzau0.fsf@DESKTOP-5N7EMDA> <20261202150538.294531-6-joshua.hahnjy@gmail.com> Date: Thu, 03 Dec 2026 12:09:20 +0800 Message-ID: <871p7zxaxb.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Stat-Signature: kmh5wqfqiytcso4imxt6p5dunndxaz5t X-Rspamd-Queue-Id: 1642340006 X-Rspam-User: X-Rspamd-Server: rspam01 X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST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lS9eS5CVLY3/En6RJLcMyZtCJg/HHX6 v0bq5SJr Lg5JBLMU85rZ2n6OoRAtSyT3YqKGTvYlFGowDrxioQhaLERa4KYBbRZY0PTNgmVaS/3zaKRTSvFlTwLr7qZ+i2j0aMNUMZYmnLpaGceLFHi+acsfYbqNWh4PfW8zxX34VemrpXThI28hIPBtyqpEBDKji+9PodbI2J/Ox6n/nx3ZJdEJOOvlKE6MO3/TxgZ+qeoCz8JpslZf+2ZcUfIybEYDvlNMtixHqoKzWb7YQvEKvV46eYqx7N/CspeQIYUWEOLwp6GDcJUQdu3SzuwMCDNGQ0X/9u37V1vjEtcWp+eFNdHJ3IfalKlT5/FKGSH3QmhSwp6DTcf/36mhqRsaPWnI4gLh7CO6GHmHuRzRrFuIvJ5WvVd6MpuylWhvYfRFIUmeEhHG0MaTwhgFvSutbpm0+2PkN4iXgd11XEd5sfaZpmRpHFrFNg7ebicLRHFqxUpH7 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Joshua Hahn writes: > On Wed, Dec 02, 2026 at 10:16:07AM +0800, Huang, Ying wrote: >> 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? > > I think you could have an iterator that just checks the usage against > the promo watermark, maybe like: > > for (zone) { > if (!managed_zone(zone)) > continue; > if (zone_watemark_ok(zone, 0, promo_wmark_pages(zone), > ZONE_MOVABLE, 0)) > return true; > } > > As for if we need the extra free space I'm not really sure. It would be > there to prevent an accidental demotion skip, but given that the drift > can be at most 125 pages per cpu, I'm not sure if it's big enough to > cause too much concern? Also I think this would push the error in the > other direction where we demote when we have enough room. > > I don't feel particularly strongly about this, just wanted to think out > loud. FWIW I think migrate_balanced_pgdat() does something similar. > If you think this will be a concern, I'd be happy to just change that > watermark check above to promo + step. [snip] IIUC, if memory usage < DRAM size, we want reclaiming; if memory usage > DRAM + CXL size, we want demotion to create DRAM -> CXL -> swap memory hotness tiers. And we demote in between as well. If so, I think it's better to use WMARK_PROMO + drift margin, to avoid missing the second situation. --- Best Regards, Huang, Ying