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 11EBFC282EC for ; Fri, 14 Mar 2025 17:52:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02631280003; Fri, 14 Mar 2025 13:52:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEEB5280001; Fri, 14 Mar 2025 13:52:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8FE1280003; Fri, 14 Mar 2025 13:52:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B8201280001 for ; Fri, 14 Mar 2025 13:52:57 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9B5061C966B for ; Fri, 14 Mar 2025 17:52:57 +0000 (UTC) X-FDA: 83220902394.21.F84565A Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) by imf01.hostedemail.com (Postfix) with ESMTP id A98CD40004 for ; Fri, 14 Mar 2025 17:52:55 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=vO4TWI+0; spf=pass (imf01.hostedemail.com: domain of yosry.ahmed@linux.dev designates 95.215.58.170 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=1741974776; 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=0dZqFzBvOCItadkQGv2XNoVXPrvgIGe2XFsi8JmjxZQ=; b=kJEw/ZgBN3WQRYlOZ7UrAwoA9eWhuZd/ByQ1oNniBQHDREnwaDIfA9n3THb/1odl/WGTUs LflvZz9bXcU0202/hUcPmAXmWe9pJ3ogxIfzRrWKk+4Fi5tzMWCscy935+Spx4/gO08BIj flu37gcEIxRIwfWFhWObiQD0FDQ76h8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741974776; a=rsa-sha256; cv=none; b=G9DQMx21kHlRjlBRcpKrXkPfaYHyqXB/VuIbEDNoEV0x56OyA35SandC8zcA6naJBrsy+R itx/cIXZ7vgoRoiGw5eLkDLowX2LvQeWhvUiaxUK7fKVNYXoqx4POECvs8vF7R/8QDR5C+ d9mTMSoZEUxH9ICsyJEolJHkEZFlVFw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=vO4TWI+0; spf=pass (imf01.hostedemail.com: domain of yosry.ahmed@linux.dev designates 95.215.58.170 as permitted sender) smtp.mailfrom=yosry.ahmed@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Fri, 14 Mar 2025 17:52:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1741974774; 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=0dZqFzBvOCItadkQGv2XNoVXPrvgIGe2XFsi8JmjxZQ=; b=vO4TWI+0GHsa2DTPqlsPpujAEUMgMrVuNOvN/6wbUF1Mq6keTs8cBRVunNgv9Jvlwdq8NO kL7+p5isUZYzJTo8TObTy3EG8V0Tvf9FDVbotCW6kxzlTSqQEJEIllT/fackhLWZWtR0c8 DXD0CEkIjRozdCBoY6kTLpGbQP68VP4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yosry Ahmed To: Johannes Weiner Cc: Michal Hocko , Zhongkun He , akpm@linux-foundation.org, muchun.song@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: References: <20250314033350.1156370-1-hezhongkun.hzk@bytedance.com> <20250314141833.GA1316033@cmpxchg.org> <20250314165739.GB1316033@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250314165739.GB1316033@cmpxchg.org> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A98CD40004 X-Stat-Signature: p4ra5acfoiz35dwm4ztfupnwgkwdusei X-HE-Tag: 1741974775-162682 X-HE-Meta: U2FsdGVkX189K26gb87oM3EvHh85kz+r4W9rg1arqRgsEt8RUrJOkgAyCYplr1HquAzZ3bCGZefIDSOc0qGz47s418ahnfxBLd3GaY4EePxaUJLutPQY8CuATlAtmbfgoTpvvXX63/9Z1oDymO1Yyl7iEYYB0yGKnei7tMWa6xgplV2leIIdutNvx+58arEJoJxWS2GwdNS2Rq8uWhv/s2SOE6WVptNsYMPjudmTLeTe84AykcXlgqcdyzxOuC3gCBIrgN0ep7tFdHLzl4k4PDDi56DJxmGO04F2WHWJZzzstl7fpdwMxl6lkJx4Md7Dt0IpXtS4X/c1IjqUWbmvzt5Y0n6W8vNAsBo718Y8A8lWZj2vB2uUy8JAJV/LXRsPuHR0MDU8u/dI7jmR275GErWvTv/awzn01qT0yRK/7dZdWipl50qrP5QnQL0srwIsl6V8eeIJQqBXpikGF3iJhZv3aLr4+/Axp0lLCQ26UEXFVRG4zU/zaax7zGp9WCcih9EFWJiv4xzVQ73kIxvG0f1GAXDxQEmtOaf4cLXr4eSFdNj+U2zgTLcGgpnX4zlwcWwg3bWsAQ0wMY4/Ahs8D6j9O3CFbkkWJaSwldLBkDnX/z0UxbTqDONtn06iUtSyy686Yt3TlJqj7eZdFhINwIHs1JsmMz+ufPB9CKwMg/owK4FLVoRsQ8awGJb/JGNufqflN8HnU1H9yxgcH8EtPO3QHRqpbQ1+DIsGvMNQOfsOB+XwTviKMp7JXaTJxQ0ZpNMten8EWboA9n/Jd5oisJQ8WoVWgq6cX6qYUzQBZtaRj40R+ZD87frRRT9Qmzs1Y6EpisWjaSLTVLD3obTW6msDB0RoQmJMOqRBG1kFtC4Pjl/IciBygF98EOcXQWb5g+Oghg86stixSQSF7hM9oWzhtquybpAIKsZr77ZCfImrtOVPccewVeXKmtG0Avnd4Xedfoo1GqiWYB2qEcW 260HKxZD 7P+Z3P7VjtPOJyrzGzLuq9KDLFpVqbNYbPkXlPU50T6uOFy7UZAR8YGy4KKxfNwzbCMVcaQGdyAvp2I3x9D7Of1lqYUzPrDhdLq7lGweRLszFcEStolqnWC5WrmirCsfRQLIYsf1FtD55aah+TP4t1hu63xu/zkpAnGYKIAs8oiga9aCLkfQhm6sHiUFMZQ1mQVnJ6Uj0ed9xjhpcYN4RhkP6zg== 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 12:57:39PM -0400, Johannes Weiner wrote: > On Fri, Mar 14, 2025 at 03:49:30PM +0100, Michal Hocko wrote: > > On Fri 14-03-25 10:18:33, Johannes Weiner wrote: > > > On Fri, Mar 14, 2025 at 10:27:57AM +0100, Michal Hocko wrote: > > [...] > > > > 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. > > > > What I meant here is that any other value than both ends of swappiness > > doesn't have generally predictable behavior unless you know specific > > details of the current memory reclaim heuristics in get_scan_count. > > > > > cache_trim_mode is > > > there to make sure a streaming file access pattern doesn't cause > > > swapping. > > > > Yes, I am aware of the purpose. > > > > > 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. > > > > I believe I do understand the requirement here. The patch offers > > counterpart to noswap pro-active reclaim and I do not have objections to > > that. > > > > The reason I brought this up is that everything in between 0..200 is > > kinda gray area. We've had several queries why swappiness=N doesn't work > > as expected and the usual answer was because of heuristics. Most people > > just learned to live with that and stopped fine tuning vm_swappiness. > > Which is good I guess. > > You're still oversimplifying and then dismissing. The heuristics don't > make swappiness meaningless, they make it useful in the first place. > > This control is used to define the rough relative IO cost of swapping > and filesystem paging, as a value between 0 and 200. > > This is clearly defined, and implemented as such. cache_trim_mode is > predicated on the *absence* of paging and caching benefits: A linear, > use-once file access pattern that *does not* benefit from additional > cache space. Kicking out anon for that purpose would be wrong under > pretty much any circumstance. That's why it "overrides" swappiness: > swappiness cannot apply when swapping at all would be nonsense. > > Proactive reclaimers like ours rely on this. We use swappiness to > express exactly what it says on the tin: the relative cost between > thrashing file vs anon. We use it quite effectively to manage anon > write rates for flash wear management e.g. Obviously that doesn't mean > we want to swap when somebody streams through a large file set. > > Zhongkun's case is a significant exception. He just wants to get rid > of known-cold anon set. This level of insight into userspace access > patterns is rare in practice. You could argue that MADV_PAGEOUT might > be more suitable for that. We have a similar use case at Google where we have a known-cold anon set and we proactively reclaim it. This is why we previously proposed type=anon/file/.., but swappiness is more flexible for use cases like the one Johannes describes above. > But I also don't necessarily see a problem > with making swappiness=200 do it; although we might have to teach our > proactive reclaimer to auto-tune between 1 and 199 then. Would it be better if we don't use the existing swappiness=200 for this? We can support something like memory.reclaim X swappiness=max instead to achieve the "anon only" mode without affecting the existing semantics of swappiness at all. I have a feeling I may have already proposed that at some point. In the kernel, we can define a new value (say 201 or 1000) that means anon only and set it in memory_reclaim() when "max" is specified. We can then explicitly check for this value in get_scan_count() (we probably also need to handle MGLRU?). >From a user perspective the swappiness semantics remain unchanged, and you do not need to teach your proactive reclaim to auto tune up to 199 of 200. We just support a new swappiness mode specific to proactive reclaim. WDYT?