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=1796181741; b=TV96NxQgZqDQYdWR+4NlKw6ts82B3pFDuW07adiZII3pH3tSzb6uGQNUJCyY8rfLgv82 7jgsJtZoEp6XE8D8xmWO9ztr954sVFPClXOKFPQIYPcw5ju9KejUFiAt9v7iNFiL1t2Ma 3zXUcV0mqdv8zcd1KwMw3b2iy32MMWpA54WBF5k7zA0PTclPGFt8u9bjlc6qwAsRD7QBT h+ttWTqFUZTIvx77+el4hZTZUmQpIq3n4nd9n7a6Idaz+HOxr6dirqfCplQKF4/LwdAJl 6Th5WNKZ/FIJkPnkkRDI/v0X/W7pVykLUytzRhbP3bPm2GpkzbPr/4J5HD27aJX13fA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796181741; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-Id: In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding; bh=DdfEBdEC3EBSBk3qK8bXKlJHSjFxgDiwedS9KM8BtFE=; b=hnHeNZw2ck2qu15+zJsY7qFcnV+azxSQJUIbQlwsfU59SJ+/8cBj/R2fvJsUJpIXAlyJ P6kccqzcIqbVtcQJTTswdat9XG1jY+TZoalczTWjnmQukQIzntsdXTqI+N3TwV1i7R4Wi hkSgw4DURakPDQZoZBBay7DZl2DgQe6ZpULeJZ+CCpBqZmvO5rHtxfO+hs60NF3tzm0au rVutjI0GG1P7jK2j0KTZQRhTwmndgCF5GoKal4lEhzRnb1FMozBl/nfMbmvIaU4wm+kXF 6agTj4WRHimRClQGc01irkb1bgVexBsYoayISA75xAI/456cw+NUxOknNlxVqEtzzmQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=kHc1Yxbi; 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 72459606A32D; Wed, 2 Dec 2026 03:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=kHc1Yxbi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797051F00893; Wed, 2 Dec 2026 03:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796181741; bh=DdfEBdEC3EBSBk3qK8bXKlJHSjFxgDiwedS9KM8BtFE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=kHc1YxbiZl9NSzdpegLWruIqYE/hAEZ1qSZ/DtnmEiNcJfwojWw9dREq7cIinWQ5J dnYKs1R6/KpiDc2AWOgSO4Qbtvjfh+Gn+fCZ/DVsqeNEXBPY/c0HzSc2c6rBll7WfH PoBjS413bMiTjkVevWw5qaqSDvWlSNh7anH9fMHo= Date: Tue, 1 Dec 2026 19:22:18 -0800 From: Andrew Morton To: Kairui Song Cc: linux-mm@kvack.org, 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 , Kairui Song , Xiang Liu , Ehab Ababneh , Zhao Zhenzhuo , Lian Wang , Joanne Koong , Kunwu Chan , Hui Zhu , Maxim Muzafarov , Tianyi Chen , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, damon@lists.linux.dev, linux-doc@vger.kernel.org, Ridong Chen Subject: Re: [PATCH v7 00/19] mm/mglru: frequency guided promotion (MGLRU-FG) and flag cleanup Message-Id: <20261201192218.3cbb143406a2744a33e555ec@linux-foundation.org> In-Reply-To: <20261202-mglru-fg-v7-0-5965a96d86d0@tencent.com> References: <20261202-mglru-fg-v7-0-5965a96d86d0@tencent.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@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=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 02 Dec 2026 04:18:40 +0800 Kairui Song wrote: > This series implements MGLRU-FG following the idea proposed at LSF/MM/BPF > this year [1], based on current mm-new. Depending on the workload, it > improves the performance or reduces IO by roughly 10% to over 50%, > fixes multiple long-standing issues with MGLRU metrics, and drops one > page flag. > I gave this a 2-hour workout on 64 vCPU QEMU. Everything checks out. It might have found one thing: : The test gives a 128 MiB cgroup a 4 MiB file that it reads repeatedly : and a 512 MiB file whose reads force reclaim. The 4 MiB file is the : hotset: 1,024 pages we expect to survive the cold-file scans. : : With three hot-file reads per scan, the kernel before the series (A) : kept all 1,024 pages after warmup. The 19-patch kernel (B) sometimes : evicted every one: in 6 of 10 cycles in one run and 3 of 10 in another. : Reading the hot file then took about 2.4-3.2 ms on B versus about 1.3 : ms on A. B also scanned more pages. : : The result depends on access rate: with one hot-file read per scan, B : kept the pages and A mostly lost them. So the series helped one : workload but regressed this more frequently read one. The trace points : to hot pages being selected for eviction, but the run did not establish : a safe correction or isolate which of the 19 patches causes it. And it proposed a little GUP speedup: From: Andrew Morton Subject: mm/mglru: skip refs decoding for already referenced GUP folios Date: Tue, 01 Dec 2026 17:59:24 -0800 GUP-fast calls folio_inc_lru_refs_fast() for every folio it pins. After its first reference, a folio with PG_referenced set still incurs the generation decode, refs decode and static-key test on every pin. The v7 GUP helper is measurably slower than the preceding queue endpoint in this repeated-pin workload. Test PG_referenced first. If set, both the MGLRU refs count and the classical LRU referenced state are already nonzero, so the helper has nothing to change. Otherwise, check the remaining MGLRU refs bits and atomically set PG_referenced only when needed. Reevaluate all tests after a failed cmpxchg. This retains the original behavior for MGLRU on, off and during switching, including a folio still on a generation list after the static key turns off. In fresh 7.4.0-rc4 guests with the 19 v7 patches, GUP_FAST_BENCHMARK pinned 16 MiB of 4 KiB pages in 64-page batches for 8192 calls per thread. Across two interleaved baseline/fix pairs, the single-thread median kernel get time fell from 52.9/53.8 to 49.3/50.1 us per call. The 64-CPU medians fell from 88.3/85.7 to 79.8/85.8 us, with wider run-to-run variation. GUP selftests passed 60/60 with MGLRU enabled and 60/60 with it disabled; MADV selftests passed 24/24 with MGLRU disabled. No kernel warnings were observed. Link: https://patch.msgid.link/20261202-mglru-fg-v7-10-5965a96d86d0@tencent.com Cc: Kairui Song Cc: linux-mm@kvack.org include/linux/mm_inline.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -538,21 +538,16 @@ static __always_inline void folio_inc_lru_refs_fast(struct folio *folio) { unsigned long new_flags, old_flags = READ_ONCE(*folio_flags(folio, 0)); - unsigned int refs; - bool has_gen; BUILD_BUG_ON(LRU_REFS_REFERENCED >= LRU_REFS_ACTIVATED); do { - has_gen = lru_get_gen_flags(old_flags) >= 0; - refs = lru_get_refs_flags(old_flags); - if (has_gen || lru_gen_enabled()) { - if (refs) - break; - } else if (refs & LRU_REFS_REFERENCED) { + if (old_flags & BIT(PG_referenced)) break; + if (lru_get_gen_flags(old_flags) >= 0 || lru_gen_enabled()) { + if (old_flags & LRU_REFS_FLAGS) + break; } - new_flags = old_flags; - lru_set_refs_flags(&new_flags, refs | LRU_REFS_REFERENCED); + new_flags = old_flags | BIT(PG_referenced); } while (!try_cmpxchg(folio_flags(folio, 0), &old_flags, new_flags)); }