From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6AD83D411A for ; Fri, 31 Jul 2026 08:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785487143; cv=none; b=PiBPZygCkV37R+oQa5VRmMHUyT0A19nrDbsyz4rcBu9c3AYso49TZgq3VMgfwyCiKZ9rDmFgRMJVreqirKsA2CbLVqxDAN7mbnZzcOquNCYEWlXF+Mu/0hOn/S0tEe6Mau0b/iBt3MGuL+q6pWhro8UYQwrS3WipTUTgezf98RU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785487143; c=relaxed/simple; bh=1MXvfrC8/oh9DI2op60Iu3vboJudUhOHfG4FINjw0I8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZGSc7CoLRaABA6Kek6zR4NKJ3QQSt2Q0OjRp+6r0H9qlsKexpLFUKUi72H+KXtEMEfCLunBYDFi5WrIvg5dCYBTiHVd5RoPBe1ArvLqlMtTyZpamqo3+8m3WeUjmUi2Jqrd45T8HWuQgYHMW9jlkYvLGW4w0uAzd0t6uV8ybOxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QyO6dISV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QyO6dISV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F5E11F000E9; Fri, 31 Jul 2026 08:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785487141; bh=1rnLid9Gk4gz87YPzn7Yuv3VMf7sSMoO6a7K32KAL6A=; h=From:To:Cc:Subject:Date; b=QyO6dISVOMXLgpuo4gnPGqmPB+luAsl+zm00IV6x4PkXDPemoHgUJPuwZnkr3SUll FijdQrgqa9ucSgiy5ue7d0cH6icMg30LURkqO+LEoKRmeLfP8H0mmlMF/nM3lY3t1q f4jk6MT+hslKYL++sBDrhLe9N1qZjiVM2sZQpl7xc9onpDLrJZwbk83L3KDeZd7M3w JRqWv3vTRmYYeF38QU+jYo/8hS+lHiK15N0KPayKIpecPnjuQrTz0IL6PuqpdiEj1G WZGQszjQ9kcSVujkelMhDP2V45fqSM+jIjYUF9s5X5KOx6mCn7bEEgVcy6Sley5zfh xi6Q3SgLqTMGg== From: "Barry Song (Xiaomi)" To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: axelrasmussen@google.com, david@kernel.org, hannes@cmpxchg.org, kasong@tencent.com, linux-kernel@vger.kernel.org, ljs@kernel.org, lyugaofei@xiaomi.com, mhocko@kernel.org, qi.zheng@linux.dev, shakeel.butt@linux.dev, stevensd@chromium.org, weixugc@google.com, yuanchu@google.com, chenridong@xiaomi.com, zhangbo56@xiaomi.com, wangzicheng@honor.com, lianux.mm@gmail.com, "Barry Song (Xiaomi)" Subject: [RFC PATCH v3 0/6] mm: mglru: fix swappiness behavior Date: Fri, 31 Jul 2026 16:38:37 +0800 Message-Id: <20260731083843.37811-1-baohua@kernel.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RFC v3: - Added Ridong's patch of improving isolate_folios() readability; - for lru_gen_imbalanced(), apply some suggestions from Zicheng and Kairui, considering lruvec size and use macro; - drop "mm: mglru: only fall back when reclaim is running at high priority" - mitigate aging for balanced swappiess value(near middle 100) as swappiness bias is less a concern for them; but slightly increased aging overhead might not be good. * RFC v2 link: https://lore.kernel.org/linux-mm/20260726122123.7614-1-baohua@kernel.org/ RFC v2: - Quickly address a few issues raised in the Sashiko comments so reviewers can ignore v1 and review a cleaner version instead. https://sashiko.dev/#/patchset/20260726012946.18684-1-baohua@kernel.org Thanks, Sashiko! The active/inactive LRU respects swappiness well. Anonymous page scanning and reclamation increase roughly linearly with swappiness, while file page scanning and reclamation decrease accordingly. For example, when swappiness reaches 200, both pgsteal_file and pgscan_file drop to zero while building the kernel in a 1 GB memcg. In contrast, MGLRU shows almost no change across different swappiness values. pgsteal_file Swappiness LRU MGLRU -------------------------------- 1 10567455 763612 36 990706 480205 71 688170 415848 106 446294 386164 141 286307 359196 176 201733 351686 200 0 330093 pgsteal_anon Swappiness LRU MGLRU -------------------------------- 1 4410548 2726362 36 2465268 2762859 71 2677908 2885124 106 2737227 2841796 141 2984276 3035015 176 3381338 2938302 200 13116359 3113499 pgscan_file Swappiness LRU MGLRU -------------------------------- 1 17997223 923094 36 1325674 539571 71 852345 464222 106 538207 464477 141 357253 412277 176 217536 399446 200 0 375902 pgscan_anon Swappiness LRU MGLRU -------------------------------- 1 31639423 5987136 36 23441521 5753224 71 26067110 6101780 106 25619448 5782919 141 26842088 6234264 176 29200021 5980292 200 62193924 6413125 This patchset respects the type selected by positive_ctrl_err(), which uses swappiness as its gain. It does so by running aging when the preferred type has few or no reclaimable folios, allowing more folios of that type to become reclaimable. For balanced swappiness values near the middle (for example, 60~140), the swappiness bias is less of a concern. We still avoid aggressive aging and allow fallback to reduce any potential aging overhead. In other words, this patch strengthens reclaim type preference for extreme swappiness values while preserving the existing MGLRU behavior for balanced swappiness values. With this patchset, swappiness starts to behave similarly to the active/inactive LRU. pgsteal_file Swappiness LRU MGLRU MGLRU+Patch ------------------------------------------------- 1 10567455 763612 1938714 36 990706 480205 427934 71 688170 415848 373450 106 446294 386164 368160 141 286307 359196 334467 176 201733 351686 293716 200 0 330093 25 pgsteal_anon Swappiness LRU MGLRU MGLRU+Patch ------------------------------------------------- 1 4410548 2726362 3284272 36 2465268 2762859 3315112 71 2677908 2885124 2942357 106 2737227 2841796 2941288 141 2984276 3035015 3345933 176 3381338 2938302 3409531 200 13116359 3113499 14414151 pgscan_file Swappiness LRU MGLRU MGLRU+Patch ------------------------------------------------- 1 17997223 923094 2612649 36 1325674 539571 514506 71 852345 464222 423155 106 538207 464477 436573 141 357253 412277 389644 176 217536 399446 333973 200 0 375902 25 pgscan_anon Swappiness LRU MGLRU MGLRU+Patch ------------------------------------------------- 1 31639423 5987136 6191482 36 23441521 5753224 6097925 71 26067110 6101780 6157755 106 25619448 5782919 6203221 141 26842088 6234264 6599502 176 29200021 5980292 6783074 200 62193924 6413125 22814377 Barry Song (Xiaomi) (4): mm: mglru: prevent min_seq[type] from pointing to an empty generation mm: mglru: let scan_folios() scan both reclaimable generations mm: mglru: improve scan_folios() exhaustion detection mm: mglru: run aging if the preferred type has no folios in reclaimable gens Ridong Chen (1): mm/mglru: improve readability of isolate_folios() lyugaofei (1): mm: mglru: run aging when pages are severely imbalanced across gens include/linux/mmzone.h | 6 +- mm/vmscan.c | 145 +++++++++++++++++++++++++++++++---------- 2 files changed, 112 insertions(+), 39 deletions(-) -- 2.34.1