From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796402818; b=2acJwE9hbOElKpzUnQrek4938vIvyD2SWsfE5VqNJJglQ2zpwsgE7so0UeOZIIDzzfQF S6ef027RoSCluZd3q/geGaMvSJxsw2OHwxmAB2ZTtOM77Hpdgzv+qGWz5pE8bMZPRhLK1 inwj414eQIu9lIQCmZ+KAmzv7jPlJVOanGqplsPB+loh6Ls1vGiyYcPKwpJ51RHeMjgjx VnK3QmsHlubePmpEEWRpGRsHuoOnWZXVgJ/1O3rv4TJiQos6amnRR5TTvojl9CZPQTdSX RuSKeKWT7mdAubmuQeFGRoq+sog9DbeACDFF3IT7ajoAzXQXRNVfummcfXmengdnISA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796402818; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=y0iOpfDBwV49ciM7uSHt0gvJLAEdMuTW+CoaK+amzBM=; b=TBW9FFOPv6IYm1agxo1VNXJJMbPJgfpW4yzy1fuDY8kJMljmWa5qkiPsUkmu+F2+FNHw eYDwoYyPmMeZY+87g9HXkGHORmBzTMNoy2iLUpPaPqiDQvKWBkybbTlsMMzOiaEhd51q3 BxD1iS1/m2NOHvTXhtFl5aGiZUIEtFXiXL1Czzq5aps3loxBqKh6e3kzSKen7TwboNLrk TQZ/OijYRcGnDZRNn9ks+EIxIULLaJ5M0aM1gvXT1jwHWd4nxF9BIGl5yRf5xRM8v8281 qp+EjE3YM6In4JCZS/yHqWc17eh79hITmHD79nUHa9RfWplx+iSSrt+Z5bE7+/dxcRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oUOOHJSD; arc=none smtp.remote-ip=74.125.82.43 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCC35606A32F for ; Fri, 4 Dec 2026 16:46:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CCC35606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oUOOHJSD Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-1b589050416so1318054c88.0 for ; Fri, 04 Dec 2026 08:46:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796402817; x=1797007617; darn=lists.linux.dev; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=y0iOpfDBwV49ciM7uSHt0gvJLAEdMuTW+CoaK+amzBM=; b=oUOOHJSD56hRk4opyxVrXoKrMkBu2ZgfTIY30fuWCmF0DJg4+sn7GIIn4ft9FjM7av 1jSr/rSKEApbvxxLrVv5JRsol9q+FekCDx/aTUCNbP7S0NYP0cCKZ9xAdHgX6YyHsZAt iz5N6nBlkJkgzct2U2mT7pv1p2Fuyy2mW9AmXKAfiHtlkHhBtL5VJMeF1oZw/LvGyyIC w1eZyZgJXVtOpWeOh623XYuyb1nLviO4lQIAFVvYEH5ZsxbEp3+hPvd2Aecmn8n3Kszo UzKwJYGBDNY7e0w5FgUXb4f0flwsDidSNWITW9ZbfMILTs3ACP4mNrBSvk3yq2D/SO79 2fsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796402817; x=1797007617; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=y0iOpfDBwV49ciM7uSHt0gvJLAEdMuTW+CoaK+amzBM=; b=qJe1lDiiVMqLXf9JUUUKxLKeNdgJvK4H8D202tmzlUpHxzfFJCq3znwzQxFUEvy76M YkIlWlmLy3B+Q6Sye9VpcwwT1pnwJYegT2ovbnyANGFE4DqFNtLLr/aulq7dCePIpTpQ aMfQM5GW5Y6ot8R1LAx8CpO6889gJHYP8PDKDXGNjtyNeiae5EWJ96FtCvTKYo6pI4xQ Am1guWHcblBodOO1UK6cuv94z4POi1xnEBZyTs3nRKg8TpQMSOAi9xljW4KbiUQweCoU /T5+NtghkO2RGEzpc2ovqx2O8URIzo6QFaq3VDCG6TGRjHK9QfgnZzoIJQH9V+7yU4A4 SuWA== X-Forwarded-Encrypted: i=1; AL+hErH+gYBHqTwV7gyKVhIozqlyAxkO6la+4u+1X45nHLNDunXt0Qkr23YNTSBIh2KURZzo2Oet9A==@lists.linux.dev X-Gm-Message-State: APuU4Z+U80OoD2R0a+s0PiEie2O6flV5tKAbE56sPc9ZD89/fkCA9rWu 9hWHyZb2jNUhSaDdEhnb9UZodzwtE3QaQTVtbci/ljXN6hZsRzFeZBOx X-Gm-Gg: AZFdTZcszVDq8ZBz8qAbsbelemkCTmYZIpDLiMv+j9F6gexZiY7G+FkkS86xFRpGqVW X6B4qeLZAwOy/zG2Z5TQbBcf6QV5qXz+nuIKtahAcfmEicm4ef1VC561usVJgSmMr/8nJB/cg65 ueN73CyZOJdutW1MMG1uxrHF+cQ0xuF9A3zcMtnl4F/SvXOEfz2wi2BtwmEvHm/5c8Tmfj5DmVR vfXCQ+rJJShkKtu8hHW8U469eQ1hfQ+flkUSazLry+z2RbNUWvO2220Gkr7KxxQ91QuYRH0jjh7 lz0iGbp+YhBTTUwthRo6Hoj7IACuZk1dJKemvo3JbtU3PZRs9AUlSEfhiRguSEs+05N+4uWcrSa /FSBnm81PsAN5NFJKBdiO/pvnnoklZlHZwtObjlV5DT0nCrlHG+zGQjJZAkAWvFFEX4KlpJ4fX5 hzxQvsVxdnqkQRxyY5Do6ABqu0lajzpicAD/p5h1OnhmwP8xsTmm20U8wXTOPHzMLGxBCy5lu49 xuYw2lxEaVW9VeUKlZ1elpp7Skf0LUdbmJOWmLvdscjBHGxxZiz4b7vud6E/xwK3IolGT/EVDGP 4oeVd2M5U1A8vfA2xUxAKM24hZlZGkqIZm78zSIOhqh/aD+q0NP5qH0u5mHltFTj8ozVCA== X-Received: by 2002:a05:7022:438d:b0:199:e38c:29a0 with SMTP id a92af1059eb24-1b5d7108db7mr3770860c88.31.1796402816786; Fri, 04 Dec 2026 08:46:56 -0800 (PST) Received: from KASONG-MC4 ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d6487115sm8211723c88.15.2026.12.04.08.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 08:46:56 -0800 (PST) Date: Sat, 5 Dec 2026 00:46:40 +0800 From: Kairui Song To: sashiko-reviews@lists.linux.dev Cc: Kairui Song , 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 , Lorenzo Stoakes , "Liam R. Howlett" , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Vlastimil Babka , Suren Baghdasaryan , Nhat Pham , Youngjun Park , Zi Yan , Gregory Price , "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 , damon@lists.linux.dev, Ridong Chen , tj@kernel.org, mkoutny@suse.com 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: damon@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Dec 03, 2026 at 09:20:52PM +0800, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Low] mm/madvise: open-coded LRU and MGLRU ref manipulation in > mm/madvise.c > -- > > commit fc7c744a30464213e9e1a5e43f610a1bb8e8a4d7 > Author: Kairui Song > > mm/madvise: adapt for LRU refs based operations for MGLRU > > This commit adds madvise_cold_prep_folio() and madvise_pageout_prep_folio() > to update folio young, workingset, and LRU reference state for both the > active/inactive LRU and MGLRU during MADV_COLD and MADV_PAGEOUT. > > > diff --git a/mm/madvise.c b/mm/madvise.c > > index 227f1c759668c..28ffaf921e9f0 100644 > > --- a/mm/madvise.c > > +++ b/mm/madvise.c > > @@ -368,6 +368,38 @@ static inline int madvise_folio_pte_batch(unsigned long addr, unsigned long end, > > FPB_MERGE_YOUNG_DIRTY); > > } > > > > +static void madvise_cold_prep_folio(struct folio *folio) > > +{ > > + /* > > + * For the active/inactive LRU, a folio demoted out of the active > > + * list should have PG_workingset so its refault is still accounted > > + * as a workingset refault, and the referenced bit always needs to > > + * be cleared even for inactive folios. For MGLRU, MADV_COLD clears > > + * refs in folio_deactivate(); MADV_PAGEOUT handles refs after isolation. > > + */ > > + if (!lru_gen_enabled()) { > > + folio_clear_lru_refs(folio); > > + if (folio_test_active(folio)) > > + folio_set_workingset(folio); > > + } else { > > + folio_test_clear_young(folio); > > + } > > +} > > + > > +static void madvise_pageout_prep_folio(struct folio *folio) > > +{ > > + unsigned int refs = folio_lru_refs(folio); > > + > > + /* > > + * For MGLRU, clear refs below LRU_REFS_WORKINGSET and cap > > + * the rest at it: MADV suggests the folio is cold, so the eviction shadow > > + * should not record its hotness in the high tier counters, but > > + * the workingset classification is preserved for PSI. > > + */ > > + if (lru_gen_enabled()) > > + folio_set_lru_refs(folio, refs >= LRU_REFS_WORKINGSET ? LRU_REFS_WORKINGSET : 0); > > +} > > [Severity: Low] > As reported by David Hildenbrand (Arm) on v6 [1], can the LRU and MGLRU > reference, workingset, and young state updates in > madvise_cold_prep_folio() and madvise_pageout_prep_folio() be moved into > folio or reclaim helpers? > > Branching on lru_gen_enabled() and manipulating folio_lru_refs(), > folio_set_lru_refs(), and LRU_REFS_WORKINGSET directly couples > mm/madvise.c to MGLRU internals that otherwise stay inside LRU and > reclaim code. I already explained this part before twice, things will get cleaner with further cleanup which need to touch more things later.