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 ED0BFC282EC for ; Fri, 14 Mar 2025 14:18:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2FCB280002; Fri, 14 Mar 2025 10:18:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DF37280001; Fri, 14 Mar 2025 10:18:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A88B280002; Fri, 14 Mar 2025 10:18:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6C7F9280001 for ; Fri, 14 Mar 2025 10:18:41 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D76445696D for ; Fri, 14 Mar 2025 14:18:41 +0000 (UTC) X-FDA: 83220362442.05.79EE73F Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by imf29.hostedemail.com (Postfix) with ESMTP id D1FD3120007 for ; Fri, 14 Mar 2025 14:18:39 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=2mfpPDFn; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf29.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.169 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741961920; a=rsa-sha256; cv=none; b=UCtBSnkg9jDGeRdWv+Po8CMU+ZuGQx2SgH4VAIRRt6H1IxLF6twzQkE7gUQc1n39xEJNNh OcHjk46WOese+cLc/Dvcm4yT7GtgFQhSFWUkp6qlbx7RtOztOJ1XVXa80iCF7u+3fVY20u 6zqnDjrj3YS33BQOYjpkVYJZdxrC04c= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=2mfpPDFn; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf29.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.169 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741961920; 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=IaDYviHzXbMRVdS6PNoP5phPb9zBK8u8E5XEDQrfB7c=; b=MC+VtTvLf8J6oFKsuwhYn9Uzf8AqcZt57zvC0xrXatNOJ5qNRILcS2sKhSjRlMNXopLWeA G6kcp2iFaZ/jJnNvaI0sv4D2FmAEiS8+k948SiTTGg/rj2xyX2FOWkJLBdm1TiXQKjhufR 9hHURLoSAe9HIAr9h8cguTJeaEdNJyI= Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-476ae781d21so21244911cf.3 for ; Fri, 14 Mar 2025 07:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1741961919; x=1742566719; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IaDYviHzXbMRVdS6PNoP5phPb9zBK8u8E5XEDQrfB7c=; b=2mfpPDFn8Dp/uttKzT/F8rEiOC64++t9NneyOpw9cmgDWG1vpKBfp4U/azE0+JYpum 3ltJEQG6LkPs0A4q9VLzwYHa2e3h0ww+nZZ/l/ayf1PVg0oaU5mxRxr7XJX6XMTBsTtX XpZQlflsG957LCwsNaTle6ZK/QordP/t2WG2kiKkdSZty1+DOTWH+Rs0NlRjkOeonWU/ nvg4O5Mrr1bH3woCC+mUr9WRp9Q5cJiWEoYRlTLLVcB/p0fCGOQxfC62nLL/yucDZMjC 79+bmmEbDGtnwsw3CdiIC8L5l8HDie3YvHQwRKrGxPs5BQHY2oxDztbNcaLGBV0lMan3 xjIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741961919; x=1742566719; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IaDYviHzXbMRVdS6PNoP5phPb9zBK8u8E5XEDQrfB7c=; b=KmgmDY+oZ2lU8aeLkU5KfZomsGEnICBb3vv48uDtUaWUlQcLZuECE2FN4467EX3i/r r17vIxtLnSUNY0F5J/o6aDwrBubdvTsSKSr9GwzkiQ5q37Kb1vDQR8n2bg8Mzu+2Kii5 MtmqXaM8yho5uS2Vs4j7p8O75wMLNxUYayodtVB78aF2+R++LJS8J4iZ4pqKb0v4unXa QHVpMxrQcS879ESy8KC21BomYNEg4WCdA/X2QiY2mLl4HmiJ9PsPBTDoZElGtfpM70VP cg5pHqnQOdb/Hp8+CxCBc36Lp8HxdJt3yFi4ut21NPsoPY3UZrkL641iM8M3Ioez4K1f K3zg== X-Forwarded-Encrypted: i=1; AJvYcCU1F1AQ0EEdto2BLGmM5araHAVaGI8AO06FfFFGTkFSVZ2OnK6rC8Pv3g217kTrzy32oSDfoGn7Ww==@kvack.org X-Gm-Message-State: AOJu0YwKklDMdEs2IvfSnZqt9Bfvt+mBSAn3EeU0at9MDmLVneOTg2xt M8L/tTFLP0uvAh18XaydGvC1cd12ZRWEX9/2KW1D4JD2VsOiNsZvc4DDWF1plbE= X-Gm-Gg: ASbGnctGXnzOqGruWkPUhKnLoJ01/U3AfnPq5xZtcFmH0slGqtU3dwPOh2/ElzPDGNp mgxwTSCzSYQCwy8etnzk59oj0bXLUwnqEaALhtieyvkg44uEOZCyhMHIKlMZU34jqZQAixd0pEe atNgZjlixuAEA5ILU9UNkE1x/CAjNSUG63WMnGduFejBwaFR+UcILD197lusnlL2HpX5zGU9Njp 22ilQJikfZhnI9NZkOCz1m51uZDoNMpfw7WlD/N+MA5NgVvJNtcIK6y7BZHLCn96sw/5sj8XKuX ObBxu0ub8X8RawwHTgv+rh3t05j2zNmLEE251g8xV0g= X-Google-Smtp-Source: AGHT+IG7F2ni/878Zv1My77dBoi+suAvL96gvrp6tTD3MWR04MKx7wwf6zLBRFeSQYIOoSvEPfAl0g== X-Received: by 2002:a05:622a:250:b0:476:9e28:ce49 with SMTP id d75a77b69052e-476c81e8cc8mr35426001cf.43.1741961918922; Fri, 14 Mar 2025 07:18:38 -0700 (PDT) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with UTF8SMTPSA id d75a77b69052e-476bb6370aasm23704331cf.20.2025.03.14.07.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Mar 2025 07:18:37 -0700 (PDT) Date: Fri, 14 Mar 2025 10:18:33 -0400 From: Johannes Weiner To: Michal Hocko Cc: Zhongkun He , akpm@linux-foundation.org, muchun.song@linux.dev, yosry.ahmed@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2] mm: vmscan: skip the file folios in proactive reclaim if swappiness is MAX Message-ID: <20250314141833.GA1316033@cmpxchg.org> References: <20250314033350.1156370-1-hezhongkun.hzk@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: D1FD3120007 X-Rspamd-Server: rspam05 X-Stat-Signature: ddkh7qkzg1ymq75iq4chtu6hq81zc1oq X-HE-Tag: 1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i8bLvg+LAbeDImInPixlhh/uKzDBzBE8A5iiSsPMsCsGegmK2J3FYuz/tm0Abf+RfNE/L9sGdNzcTOuFSQYWPSNv0Wpa7VX/4aZhnt7OvFO49v8ryYeAVmSHNOB1vYxHjovW2KjgN1dWDpzCBWA0nnmt+E4gQKg5h5L4Cb/ud1O7ueCWzYKXd45At1tsy+gaSEPiC6iLqIGRGH0+EvvUrSVeE2xA7L6lJai4TcjnIwdZ0vxD+dqhSp4ntFCb/nQoYrvTxPJQ4CvAI+orTlhETCt+WBhnxSPWx+tUNVovpsoRAsNVmupvBQ7NW1/KXRcHR+KlZe+Ti45eL+OtjtWV9e+71/njx1RD0VQ/I3h1dknpxe9N8TSAnlkNVfC25fKY8BiH2iT2FSu3z4lgBKWNUuBhwdA+OA== 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 Fri, Mar 14, 2025 at 10:27:57AM +0100, Michal Hocko wrote: > On Fri 14-03-25 09:52:45, Michal Hocko wrote: > > On Fri 14-03-25 11:33:50, 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 folios. > > > > > > 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. For example, if we find that a certain cgroup has a > > > large number of inactive anon folios, we can reclaim only those and skip > > > file folios, because with the zram/zswap, the IO tradeoff that > > > cache_trim_mode is making doesn't hold - file refaults will cause IO, > > > whereas anon decompression will not. > > > > > > 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. > > > > Haven't you said you will try a slightly different approach and always > > bypass LRU balancing heuristics for pro-active reclaim and swappiness > > provided? What has happened with that? > > I have just noticed that you have followed up [1] with a concern that > using swappiness in the whole min-max range without any heuristics turns > out to be harder than just relying on the min and max as extremes. > What seems to be still missing (or maybe it is just me not seeing that) > is why should we only enforce those extreme ends of the range and still > preserve under-defined semantic for all other swappiness values in the > pro-active reclaim. I'm guess I'm not seeing the "under-defined" part. cache_trim_mode is there to make sure a streaming file access pattern doesn't cause swapping. He has a special usecase to override cache_trim_mode when he knows a large amount of anon is going cold. There is no way we can generally remove it from proactive reclaim.