From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796140735; b=NwZS8++UehfiTTdFNfQTO68tAiUEoYoHCuwSNnBIsIMH0WiI2Iwrxu9D3t7SM0Vcq1nq a3Hs6RBJWoC6Xhk2g1V4e9u+njEGYx3rvRMqSgVRQAY5X8XYFvdiYouX5Lro3VovQTaSx AWDvTzmPB6geisbx8poGwrp4AAh2owKWCFRKwOBUydWysET+yxiI5N5NGqwE+z8+FcjnY 1G3NsmR4/ROBYsM/Qy4gJrhID9B8akkop4wFPnThv8lA+zlz4VPEAo93zJi7TxKLTfR5E aSItbXM77kdwcxRQBzhjeNRjFRyM3SN+/C2WfexPuoDf4inW6st5gdTI7i10yW2/mzA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796140735; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=kMHkgSYt59eCPLnPJ8LEO568haJpH1WNk3r8zkbxtYU=; b=Tn5nYybgLwqcLZsN1Zk+s/7041H/MHNUf08Xnu7FxXEZsLYtFt7EQ0Y8PE1nORZF3OT5 tFv4xqw84f8SJ9CE0eHdXOalIEN86nQB03kixjIORsO8QN1RxA4167mpRSEj6T/YgFGeQ b33K6k26VkcZ5oU7tPubTyw+OhRC0iF+abiZ26qBPdfqvvhDct5xBqaeLKrY60wBXFR5r xFkVrcRcgx2xwhpbw6nsbqDscUutyVpCdHOLI2xnvzHNxDpzE0dDa67HDWji0/bZEFUiq Mc6m7HOWJI/R9yRAiD551R3u2fOlwX1PngC2ZQm7CqLYnAj3jGUa2zuIKZhtiXi6U0Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="V/h4FrlI"; arc=none smtp.remote-ip=209.85.160.47 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3478606A31A for ; Tue, 1 Dec 2026 15:58:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F3478606A31A 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.a=rsa-sha256 header.s=20260707 header.b=V/h4FrlI Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-483d290f398so6178477fac.2 for ; Tue, 01 Dec 2026 07:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796140734; x=1796745534; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kMHkgSYt59eCPLnPJ8LEO568haJpH1WNk3r8zkbxtYU=; b=V/h4FrlIOA3jHdr47Bv1XNHHw1FmGyNfvYIeVsunWOZkkxIPe2K2CzLm9Z6c0LqcG0 NkH4/baMreQJpl/WoLJ5AlDaWyGYHWCqCWEqfMpEI2DT1S8CspOpMzmhXydkfKd28nle bWyb/5SHHwurv5ujFgnmyZT4evJnOOeFWAoQ8SFKsKLputBO9v2EKEWE61x+nonCefDS wlddL12oTvYnLxrlAGp4gvyGqtGF+US95eS2xEaPiwaZE0UuRHRXy2KlD40sUZdqw/cA 1pLQQaBJM8AGfwNVm9zE0lUq6xlqHE5dO0kIrcdSxGs9FyD2NIMpUQtUC/QcgEe4JFfn 5K+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796140734; x=1796745534; h=in-reply-to:content-disposition:content-type:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kMHkgSYt59eCPLnPJ8LEO568haJpH1WNk3r8zkbxtYU=; b=vuS7GHw8qjcy1+m5dt/n6PvS6+NxcUK2KPwmYgvDRP9taBTlsa4XKkoxzoe7ObanUi Zh6DZ8pX74WdrcSNUrY+xLqgaBQq6U05S0XNBDlHkbC8xvfHBy3KGg4mgn1UsI+4n3km FBa64uCukD6RAS+evoGZ8ttr2vAC9znE/pYurhTH7OO550Q97HvZ144Cuet5P2cPKGaH ov3arrSq2u7wS3nbTUHaHEhfNCfM9fcqn+DzcCYhutd9TkZ8SCl0PoSDjf1Ar/GUDBRa AFnC311zjVuhVeg5ZQj0L4Htf3nMMddTws5kcqf8gj0CDmCa/H3HEIgafzNVVedcsehQ 7GPA== X-Forwarded-Encrypted: i=1; AL+hErFPnvajVQGflWfGHLRMwO6HXF4twwNM/LeCRmyjGcCfPwF3vI8OORSXAEma2lDRydWyUWhJCBz9KIyD7Pc=@vger.kernel.org X-Gm-Message-State: APuU4Z/XnebUmjStLzQttlX26sITwMK/3bPWZ5t0hZrQ1/j8ydILRnYD uxbSuIhOHeSTrAc2LmH9mRpIxoF4CmBANW6pZ+e+CGnVkx0HEaMPlymA X-Gm-Gg: AZFdTZciSKkWWd7JVfMBjLgW9oFYxIJllud//MiZfYsnaH754RF74oY8DxgoIczr8mT 676jurTXqJfC7NQwA4yjHD0kgpJXOwElWffMd5ueLASsbXkpDw7+RJOjrk6f6TTfsnVC09Nt8j1 Q9hh/QijS0kumjGNaG4X1WoeEGbAzJqV1EWFTbDwQXzvcBwVmck6j0+tPsHRk4IybP9ACN9/5u8 mYYLu/AZA9P+DAL9XzJdzypjfCjLoD+9t1l2+WGstfWU0Mgg4SzTGf/1o9g4psGfms6KqfJFYVV VnKPmnX/yqx0GZnUfVIzn4h+8eC3xaBYe8Rl7B6SFKmGXTVzr3l5cNCX29S9EXPme2/Sw7B8CPk PhgZx2yviYG33WYsH06CoFg6T0qJRd58+5JnfcdphQ/535BzHjXcwKCEg+uVheA84RzBb5XhTnj i3bOd6bEMEVv/42OLp7vyiIawOfoOyLc0rqteVRgcwGp/Ep/1kR69PocZ1ldVIXQwZcAR9dnj8s DyR6DwbvxDX+VOTKUgXwfkoAnkJIkhppgmHDh/Ejxd5Nw7xoyBAdJnhvV2PyK/8YdaEs8cHC/6k NI3x4/TV8rpD4WMTQk3ge9Lu+DbQBtn02m5XsyYpQWHYQ83wyI6/d8OyyEU3cMxzQDGC3bmwojz QUxB0 X-Received: by 2002:a05:6870:4584:b0:4a8:b12:79f9 with SMTP id 586e51a60fabf-4bc84f1b70cmr34003672fac.46.1796140733803; Tue, 01 Dec 2026 07:58:53 -0800 (PST) Received: from localhost ([2a03:2880:10ff:18::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4bd3008160dsm34942217fac.16.2026.12.01.07.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 07:58:53 -0800 (PST) Date: Tue, 1 Dec 2026 07:58:52 -0800 From: Joshua Hahn To: "Huang, Ying" 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 Message-ID: <20261201155714.294531-1-joshua.hahnjy@gmail.com> Mail-Followup-To: "Huang, Ying" , 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 References: <20261130215258.2202513-1-joshua.hahnjy@gmail.com> <20261130215258.2202513-3-joshua.hahnjy@gmail.com> <87qzg1yv12.fsf@DESKTOP-5N7EMDA> 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=us-ascii Content-Disposition: inline In-Reply-To: <87qzg1yv12.fsf@DESKTOP-5N7EMDA> 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. Hopefully the rest of the commit makes sense to you. Thanks again, I hope you have a great day! 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