From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96E54C282DE for ; Fri, 14 Mar 2025 00:17:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96F64280003; Thu, 13 Mar 2025 20:17:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91FC0280001; Thu, 13 Mar 2025 20:17:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80E1E280003; Thu, 13 Mar 2025 20:17:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 63834280001 for ; Thu, 13 Mar 2025 20:17:47 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B7F941206D4 for ; Fri, 14 Mar 2025 00:17:48 +0000 (UTC) X-FDA: 83218243416.05.6B67FD3 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by imf18.hostedemail.com (Postfix) with ESMTP id CA0E41C000A for ; Fri, 14 Mar 2025 00:17:46 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Ejugr1nw; spf=pass (imf18.hostedemail.com: domain of yosry.ahmed@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741911467; 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=Y+4LDr8b1UADNuiOjRFlkioCNLHtqn/OFPYvEBwiVkY=; b=7UlH0nONgmdMW81yrbic1xFuqfSNqmSX/rqmxO3VS0OqYCDjiNfRYy4XpqR8h6YyvGS4gy 8FUzrfO+UAi7PW07mmlq3JeAjv7CUeSyM6rhkRMY7CXS6uOaHu8nGu4hgLnt5z3n4XVfVB qG9b80Z0pkd8TNfmT29gfLgR/gbeOEo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741911467; a=rsa-sha256; cv=none; b=n7YAxibz6FddH7KKQ5ys/rDIx0etPxm0gj9SHvkrZ7dZG1ON5SU17xxjWX919/yfZrCLRl CXVM4RF/9MxHGq4vJ7UnVZMhmCFrWxNdJnbERTvpmXCUYU2MuFA6gHMnFVTJ6u1PzaZnIo NWsXwYincIEgAPS9Qro6tngAvchYMnE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Ejugr1nw; spf=pass (imf18.hostedemail.com: domain of yosry.ahmed@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Fri, 14 Mar 2025 00:17:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1741911464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Y+4LDr8b1UADNuiOjRFlkioCNLHtqn/OFPYvEBwiVkY=; b=Ejugr1nwbZ+MM0aIlGoFdawDyyNuEFjuJGu+2l90TaF2p3vGyHU5Y0m14TDotM2NeDLV4q bjhBIu215h/cYt1eDA/5orirKC7i0pi/u66o3/TBr/2IE++SxMMe6bg0tv4t8HcICVZuHd pUBCFgDNvZ1yWiDZGI5/pcFGw37CVow= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yosry Ahmed To: Zhongkun He Cc: akpm@linux-foundation.org, mhocko@suse.com, hannes@cmpxchg.org, muchun.song@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: vmscan: skip the file folios in proactive reclaim if swappiness is MAX Message-ID: References: <20250312094337.2296278-1-hezhongkun.hzk@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250312094337.2296278-1-hezhongkun.hzk@bytedance.com> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CA0E41C000A X-Stat-Signature: wtqe89o7n5jexn8m3qhr7njb69e5ss59 X-HE-Tag: 1741911466-302089 X-HE-Meta: U2FsdGVkX1+JyoIz1P5xGNrkvEmMmC31KfiHvAvVyvtDpW2YnaOL8RlymWAtvZZHOm5By8BTlGtn5NGy7WTUp5jR0n/VT2XVrV//WuTFsRyhsjc9tOm5fqOtt4buenvP2jAFiSPy3KBAwcUMDC/ALi8toqoL8NEHXb94TFsrOFE7/RLogUmVp9+W8PONoEcm+mGyakqrdqsmrQkJJo0XemLIr1rSsfT849pEEcOw/tt61oWMRO5GZRNRgX8ZQXayxP5Cgv0VMtTqjp9UaSgHLMiFvELzGfh2muC/mdo2mnWEwhncbfVrxvJIIsHqzEcam1xLf/VtE4bfTDkTNRwfapwa2MAY9CgdrCnAyDv+6racJ/9HlCfbblIoqcdvA+Kfxn3drQ8xE8AxzqvFoJJvLau0LUHIubRT+yDwBX/foRcD5AHfZtvCNS9fPUTYkHI8zNjHgS6xgq/uxBHeUYwLaksdySryIDaQaBXqshz6fBlVbVTWH9t3BHF6aYEy7U/0Kzgiw7gcHV04RGwlp47Sc7nadg5GYV3O+Jcrid44LxwAS3tqNOAoXnGPHwJseZKFbNSSVO6VX20mzprP0cdEBLH2ityLAe0jz1WM8EHY7nZRDB6HAsT/Ju9PS79GEaOwmk0IwFpFVv08CGzzElaW3Rag9RN9xnHiMwVvHsSHr6h/h+2Q75tvxN39XS3PJQMY6ODFVTNUQ5dBkcENMvC0vtFg0+4zejK+7s87oZ4jrZee3W5ObqhknWWrGJNcn5Nq/geaYPhl3xzonWCuGK+D100EeUc+0TV3QDcAiyrSBQb/Jw3PfGFYJU/W4g/JdO2hGYvj26auKr9DqsQR/QUCV54pGuRl+2Lz/jxGnZRlMJyM8pu8GbHbRXJQlXqR8MOxFDqDEL9jxiILmDpeHnP7Wi/cxv+4a48wCMwK5hx1tSjdyIEwUPhbcrQOvI9/I2DIB/v1TSItHJXhdySSvLv Eoz6YdT9 7TCIf0o6tBSJ1lKVIdJyMr787DI7JbLH5tQ1h7r/qvygf+3HKSLKhqJkOa10dJVnle70R9zpRTbISr8kqc3dHPdLhUnCorfcoXQr5XeMBE4f5uNgWwbPlcU7LBidqdnLmOy/kOus5fsri3eRXjx4Gz0Rzc46pUPxoF46o1bci8Y1/IFOZAKVnuREuue8qXS/61ILFj9mk/M5t7FEqWPX//CtMINzNokyhRMwbflQjMDtyonf96JjfEVU1/oJxnDhP4XiMi8ipNnPl7+U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Mar 12, 2025 at 05:43:37PM +0800, Zhongkun He wrote: > With this patch 'commit <68cd9050d871> ("mm: add swappiness= arg to > memory.reclaim")', we can submit an additional swappiness= argument > to memory.reclaim. It is very useful because we can dynamically adjust > the reclamation ratio based on the anonymous folios and file folios of > each cgroup. For example,when swappiness is set to 0, we only reclaim > from file pages. > > However,we have also encountered a new issue: when swappiness is set to > the MAX_SWAPPINESS, it may still only reclaim file folios. This is due > to the knob of cache_trim_mode, which depends solely on the ratio of > inactive folios, regardless of whether there are a large number of cold > folios in anonymous folio list. > > So, we hope to add a new control logic where proactive memory reclaim only > reclaims from anonymous folios when swappiness is set to MAX_SWAPPINESS. > For example, something like this: > > echo "2M swappiness=200" > /sys/fs/cgroup/memory.reclaim > > will perform reclaim on the rootcg with a swappiness setting of 200 (max > swappiness) regardless of the file folios. Users have a more comprehensive > view of the application's memory distribution because there are many > metrics available. > > With this patch, the swappiness argument of memory.reclaim has a more > precise semantics: 0 means reclaiming only from file pages, while 200 > means reclaiming just from anonymous pages. > > Signed-off-by: Zhongkun He Reviewed-by: Yosry Ahmed > --- > mm/vmscan.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index c767d71c43d7..f4312b41e0e0 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2438,6 +2438,16 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, > goto out; > } > > + /* > + * Do not bother scanning file folios if the memory reclaim > + * invoked by userspace through memory.reclaim and the > + * swappiness is MAX_SWAPPINESS. > + */ > + if (sc->proactive && (swappiness == MAX_SWAPPINESS)) { > + scan_balance = SCAN_ANON; > + goto out; > + } > + > /* > * Do not apply any pressure balancing cleverness when the > * system is close to OOM, scan both anon and file equally > -- > 2.39.5 > >