From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796390771; b=dm1C6/x1OREFYiX4N+tjl6QFjfSyFhsyk752GSanLaPqFccEi6ZxDgXomayxYsx2OTlC 2dyRcbjy7+CfzFP9y2YXrCeD1CHo1E6c+7jbyf8OzgTxaSHhgkW+hQx2LUj+7CC8M8Yr+ I7P494P4FhQJaPEJvmYS5qLrlQvuLpgmemiNLpwRuwu9kzg+6pPMh1fK+/opall6k1rV/ CgsvUMJ82HxQu9XMuhogkYr9cXHmEj2G8LxGHFZvVMCzPZWfkwSj21FDHCKVzhrWuhav3 m9f2rjJHJRBXZOzCNAyEtv6P64V3GXc+MCcqz+RBQI48JdNeKQr6yROwMpq7kqg+ayA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390771; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=/Ffr78ZLI17yCOi4ZJf+HFLrua58KyNPeeyJQuWJdHQ=; b=p80gbFWvw0qAiek16LYVB2ml7XUACmAyEHiqeVZ+uotHAMGMBf63alcMgcHlKcYUS6eV gbNctRSmKljj+XSssxmY4YrKnf/NxBa8Bxv0hWM8f/sz5usnBQYlz1Jx+r7CMiOWAZ9jV xDLcmkvWwsykOpu3ijiKt1SNU4SBZcMpk6O2KixccVNGh2avbsPzyvOjgR9Mqjy8OMvFn NafsE8rxd0WTKPIozmxbL4KB5gCIHyrcOwhrPw2zZsugV+yH+tmIPWLilw3/lv0By0fjD QPDfPw/o93lf4QbVeTdAGU3K5Z52tWWlSEFiMlQ+ov8QlYf5/ZwKMEoglbPygWnWAoQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eNG2d2iW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95E30606A322; Fri, 4 Dec 2026 13:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eNG2d2iW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F5E91F0092C; Fri, 4 Dec 2026 13:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796390770; bh=/Ffr78ZLI17yCOi4ZJf+HFLrua58KyNPeeyJQuWJdHQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=eNG2d2iWg0XhCIfiagfASGPyvzxSBbgG6N7FirJr7jVxiD98E4wFBMh0gZMpSCoon 2ZZPYmCWbdUv7Egz3YNed4wJmONuRrfEur3FTbmKV6KXQu9aw/Fq5lT3QsHCKvW2C1 W/YG5scWgz552ztPuCqVUt/lt6tx6mEMguye4kxAWgJ9jy4BDVOnjHWjxf3L3Ehhvb /X24MSWtB2cZoB3gCw/aGfkjcUWHEiXukMIJ6JPyG6DmwmsnZnfDQy9QFun9Sx5Ztc 6NnbxTt2+U2KpVMUl7/bpLrp9r/BZd17SqYqFeOI1bSCVvVYVtgYbp7Cp3Ci4LTCgk HNLJ0d+nk2YrQ== Date: Fri, 4 Dec 2026 13:25:56 +0000 From: "Lorenzo Stoakes (ARM)" To: Kairui Song Cc: Gregory Price , linux-mm@kvack.org, Andrew Morton , Johannes Weiner , Muchun Song , Qi Zheng , Ying Huang , Chris Li , Baoquan He , Nico Pache , Usama Arif , Michal Hocko , Roman Gushchin , Shakeel Butt , David Hildenbrand , "Liam R. Howlett" , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Vlastimil Babka , Suren Baghdasaryan , Nhat Pham , Youngjun Park , Zi Yan , "Matthew Wilcox (Oracle)" , Baolin Wang , Ryan Roberts , Dev Jain , Lance Yang , Hugh Dickins , SJ Park , David Rientjes , Yu Zhao , Vernon Yang , Zicheng Wang , Tal Zussman , Xiang Liu , Ehab Ababneh , Zhao Zhengzhuo , Lian Wang , Joanne Koong , Kunwu Chan , Hui Zhu , Maxim Muzafarov , Tianyi Chen , Aveline Noir , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, damon@lists.linux.dev, linux-doc@vger.kernel.org, Ridong Chen Subject: Re: [PATCH v8 14/19] mm/madvise: adapt for LRU refs based operations for MGLRU Message-ID: References: <20261204-mglru-fg-v8-0-64f81c876c15@tencent.com> <20261204-mglru-fg-v8-14-64f81c876c15@tencent.com> X-Mailing-List: linux-doc@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Dec 04, 2026 at 09:11:19PM +0800, Kairui Song wrote: > On Fri, Dec 4, 2026 at 8:19 PM Lorenzo Stoakes (ARM) wrote: > > > > On Fri, Dec 04, 2026 at 01:02:45AM +0800, Kairui Song via B4 Relay wrote: > > > From: Kairui Song > > > > > > For the active/inactive LRU, madvise clears PG_referenced so that one more > > > access is not enough to reactivate a folio, and keeps PG_workingset on a > > > folio demoted out of the active list so its refault is still accounted as > > > a workingset refault (PSI). > > > > > > MGLRU keeps that history in the folio's refs count instead, which now > > > lives in PG_referenced, PG_workingset and LRU_REFS_MASK, so writing to > > > those bits directly corrupts the count. The two hints want different > > > things: > > > > > > - MADV_COLD resets the count in folio_deactivate(), which also requests > > > deactivation. > > > - MADV_PAGEOUT clears non-workingset refs and caps the rest at > > > LRU_REFS_WORKINGSET after isolation, before handing the folio to > > > reclaim_pages(). The hint marks the folio as cold, so the > > > eviction shadow records the capped count and does not inflate the > > > eviction/refault counters of the hot tiers that drive aging, while > > > folios at or above the workingset threshold keep their PSI > > > classification. > > > > > > PG_young is cleared for both LRUs as before, so the referenced walk does > > > not count stale history as a recent access. > > > > > > Reviewed-by: Kunwu Chan > > > Tested-by: Andrew Morton > > > Signed-off-by: Kairui Song > > > > It'd be nice for us to figure out a way eventually to make this modular re: > > reclaim backends. > > Don't worry, anything that looks not so nice here won't stay for too long :-D Awesome :) > > > The implementation looks sensible and you're breaking things out sensibly also > > so not objecting to it though :) > > > > Also hopefully Gregory's rework of the cold/pageout bits can make this even > > nicer (I realise I owe review on that, swamped etc. :) > > Totally understandable :), BTW, any spoiler available for that rework? > I have quite a few ambitious plans for maybe related parts, mostly > included in the cover letter and previous discussions, hopefully, > there won't be too many conflicts. Am thinking of this series, it's on my TODO for review but my TODO is infinite... :) https://lore.kernel.org/linux-mm/20261014183024.2075709-1-gourry@gourry.net/ -- Cheers, Lorenzo