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 1C465C282EC for ; Fri, 14 Mar 2025 10:35:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67235280004; Fri, 14 Mar 2025 06:35:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F952280001; Fri, 14 Mar 2025 06:35:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C179280004; Fri, 14 Mar 2025 06:35:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2EC3F280001 for ; Fri, 14 Mar 2025 06:35:50 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1B6181A0E00 for ; Fri, 14 Mar 2025 10:35:50 +0000 (UTC) X-FDA: 83219800860.15.D9D9B16 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 71DBD180009 for ; Fri, 14 Mar 2025 10:35:46 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dWsf4Meg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf24.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.208.172 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741948548; a=rsa-sha256; cv=none; b=mrz57B573O6TPF8gJJ6ImNNTHIq+PfqhU/nwmyN6TXzaNH3lhzJkoReoud/LOFWR2wzIXQ c6cNA5IqNnBQEqh4m2yEm+VEC3BFeD58UedEgfHp9dLA+YVeefWxf9yKQ3koiMeD0Jg6bZ OyIY62WUSdMh/+PGYGnGCKeErKJ5Rfo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=dWsf4Meg; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf24.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.208.172 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741948548; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OCmMR17KASub8kG2P4Bhk5E3WXSg+MDPvYkx4oQr4cA=; b=LFwgABDn0ah137QVdtFuD4RtxFOuZc3wu6QXlcVpc2k63uQvITnG1FDTaYbrV1tFSIpegW Nnwv9w3d1iJBKt+oAF4g4drd2uEqU/331npV3PXp+QoV9q1W5pa7TWP3DYZqfCq69wCEOQ ZKglVxQFKKdZUBhL2WFBz3QKavoq80I= Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-30c05fd126cso18091231fa.3 for ; Fri, 14 Mar 2025 03:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1741948544; x=1742553344; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OCmMR17KASub8kG2P4Bhk5E3WXSg+MDPvYkx4oQr4cA=; b=dWsf4MegzBsVcil7hUslS2edy4pPg3zqu42uGr2ktTx0L3cPQvfxQgRZ9hB2N38FFd lH9dvtHiFnMuxTm5WErf7l37pGMHFLKliMe5jroov1mfdDxV/Y8j7liypSedIJhUSQb3 a09c2VciOXGOSZf6F7rbrSIdoIkojz6CmCSpYJg059ocGIYEG1CoMwbk8CS2rzVt43z8 WSVEGRJ3U9D4TP9sHvkC3kkKzjEdBhMYQF4Bav1TNKaVqNf6PtKkzCxyzjlDvyFaFZC8 YmbA+rzPgaxSr1o6rqguJHZZzipOty6hl7xK/JypG2mgbPERwULzWXt3fJ9mLe5jm0CZ 7Scw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741948544; x=1742553344; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OCmMR17KASub8kG2P4Bhk5E3WXSg+MDPvYkx4oQr4cA=; b=odUYvdzWEq4LNR1x0/WRCZpRM3YvxhJoBj0c3ZlQrNI0u5P2VWIO+CmQvZgIvjBlyR P+9f5a6BxYGiEdPxLdGXkYMgRl3H07y7zh3/1zEfEvQgqWbchmHp5FOFToDR+htI3nbD KWSgWDQDRA3OrL6sZxDX2abxXK+dy93WAr4TyG0cpon1MOmhDw50Es+kD1oa8fK8I84R KsuVv/HK9BUL6HgWS3z+E8yQORTvwpmMHtprcl8X+9nSr57gxjEBfjy3QCKWGt8+ZkcA 3Aj4zo7Mp44b6AR1W3N9TLJAX1dHQdwCiLOaorI4ukwlp1Dna6+t8NLDIZDlQNQ6uvQ1 Bzyw== X-Forwarded-Encrypted: i=1; AJvYcCUtFptgEvArXQwsPtcH6Nt9qXiTXNUteSBsed5RQFjCkDDAV0vX/EkkJlaSIre4uUuGw0PJd91e9A==@kvack.org X-Gm-Message-State: AOJu0YwjNbNBGmLHO9BB1Wi2c2TxrCqwG39ct/J/ijXvM4VFtZOLlR6f G6hW5M2bDe58sc/yOk04Tz2PZ7h8lmjEU/V4yfPQouPdeSh6QTrVO3ZPIMOfT+p1JTH/jVPbXqV fcL6rI3DcbyK9xoNElTqZ00HporNNo3vxWj3ubg== X-Gm-Gg: ASbGnct34QuGklt2JbwNDYolV3wfxXNYC8s977K+bPKOwKWR2h9AQaZB0nrfH6o4xWw A5OG+p3CwIGJzim2gEh86akBLUJt4FZ5nSIoxQzziWBo400McSUmQZ6c+n2YTRhrgHBsE+uQk3C TBEIpHcnxY0FtEEsTTkzQaMd/mvtfGv+SvNiPV2Pq0C17JorrSNQ== X-Google-Smtp-Source: AGHT+IGmFtwNm8vMybPTd+nTfyXxMsR6vhRH4fTRCZm951GF+DGPrO/St4ijKA18t+Y/Zpfd3omrzTA9U3vvZjG4TPc= X-Received: by 2002:a2e:3806:0:b0:30c:317:f3ec with SMTP id 38308e7fff4ca-30c4a875efemr5722801fa.17.1741948544300; Fri, 14 Mar 2025 03:35:44 -0700 (PDT) MIME-Version: 1.0 References: <20250314033350.1156370-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Zhongkun He Date: Fri, 14 Mar 2025 18:35:07 +0800 X-Gm-Features: AQ5f1Jo5Z3yuAmBxomFYh1PXxcwNGIlc2EbM8aTJzpoe1eRsPDdY8IaOBKGA3VY Message-ID: Subject: Re: [External] Re: [PATCH V2] mm: vmscan: skip the file folios in proactive reclaim if swappiness is MAX To: Michal Hocko Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, muchun.song@linux.dev, yosry.ahmed@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Queue-Id: 71DBD180009 X-Stat-Signature: 1q9csib1br3rjnoqbr7bkn18x4w1jw94 X-Rspamd-Server: rspam06 X-HE-Tag: 1741948546-574847 X-HE-Meta: U2FsdGVkX18S8m///2Mdqouv1wTgPLd/I7Z6qf+3/mBCSQgpgbX9Oq5rddq2yb3cLcvTUat7cLR54Cco40YRk3A4SE2yEXQklbIRWJfbH6LsRtnir0WEOVc54YMnMRNLoxQLYgPCCZGWeGBPwNlwSpLktiqK+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1P48m8MVB126EMObsP/yLLSFpK0ctihdHIwkXYnpGZuiDnhxuAAtVLV6LhiWamCpfDeucMnInYT/tw== 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 5:28=E2=80=AFPM Michal Hocko wrot= e: > > 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=3D arg to > > > memory.reclaim")', we can submit an additional swappiness=3D arg= ument > > > to memory.reclaim. It is very useful because we can dynamically adjus= t > > > the reclamation ratio based on the anonymous folios and file folios o= f > > > 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 du= e > > > 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 co= ld > > > 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_SWAPPINE= SS. > > > For example, something like this: > > > > > > echo "2M swappiness=3D200" > /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 comprehe= nsive > > > 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 s= kip > > > 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. > Yes, you are right. There is a demo if we bypass LRU balancing heuristics in pro reclaim. I have a question, but I'm not sure if it should be considered. For example= , if anon scan=3D5 and swappiness=3D5, then 5*5/200=3D0. The scan becomes zer= o. Do you have any suggestions? diff --git a/mm/vmscan.c b/mm/vmscan.c index f4312b41e0e0..75935fe42245 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2448,6 +2448,19 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, goto out; } + /* + * Bypassing LRU balancing heuristics for proactive memory + * reclaim to make the semantic of swappiness clearer in + * memory.reclaim. + */ + if (sc->proactive && sc->proactive_swappiness) { + scan_balance =3D SCAN_FRACT; + fraction[0] =3D swappiness; + fraction[1] =3D MAX_SWAPPINESS - swappiness; + denominator =3D MAX_SWAPPINESS; + goto out; + } + /* * Do not apply any pressure balancing cleverness when the * system is close to OOM, scan both anon and file equally Additionally, any feedback from others is welcome. Thanks. > [1] https://lore.kernel.org/all/CACSyD1OHD8oXQcQmi1D9t2f5oeMVDvCQnYZUMQTG= bqBz4YYKLQ@mail.gmail.com/T/#u > -- > Michal Hocko > SUSE Labs