From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEAB6606A33B for ; Thu, 3 Dec 2026 08:40:25 +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=Rkn71+HC Received: by kanga.kvack.org (Postfix) id 723F96B05B2; Thu, 3 Dec 2026 03:40:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D3E56B05B3; Thu, 3 Dec 2026 03:40:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E9956B05B4; Thu, 3 Dec 2026 03:40:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 35AD26B05B2 for ; Thu, 3 Dec 2026 03:40:24 -0500 (EST) Received: from smtpin03.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7102112016E for ; Thu, 3 Dec 2026 08:40:22 +0000 (UTC) X-FDA: 85502025084.03.A1F3BB0 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf03.hostedemail.com (Postfix) with ESMTP id 9750D20009 for ; Thu, 3 Dec 2026 08:40:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Rkn71+HC; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of baohua@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=baohua@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796287220; b=0uR2SjIv6cf9yB6kC0bn2mOlAz1fvDqxr2/x/oZp8LCMYoMRvNbiEilWO3jcHgOF+2mSlS bqLhO6bSedqiFh8NgNr1LXLYgL3sBeHh76kVsD6QSpNPRukIAwCXZGMtCgBes7GMyPFANG HzRWqBt4pDfiFsSC9FqLkBntctbvwjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796287220; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=M4rvTwHaWif51SXBkeNFHieCjJEo+Mk/HDSJqtkzHHQ=; b=cj+2vn6oyXCcslp/froU6wxOG2KKZQQOro1ozG69KBlNf0C8uf8z7t8wbacA3vdkDOwQNP V/0qUUcpUksneph+0iJTrAM/P7YNO141rb38w/yi+sb0pwGpNMuz8a5oPsOP2Jx0/zqT0l rfLv/Dftt4FgWlFn/z3OYWQtFjvVma4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Rkn71+HC; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of baohua@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=baohua@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 13E9E60219; Thu, 3 Dec 2026 08:40:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 145D01F00896; Thu, 3 Dec 2026 08:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796287219; bh=M4rvTwHaWif51SXBkeNFHieCjJEo+Mk/HDSJqtkzHHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Rkn71+HCOsKZKIDHAQQ4zL0p5UpsOkD2dNadMs6qynFnpOg0KXiKQPDOKRADIC0oj XG72MZ+V8ohh5QQEn8uhE8rLvGX/KBULjDCpYTOWSGjbKeuSYr9LBgMnmgReu/Oogv eHPN1/nORXGD104wUgnmzqlrKpMuUlnzqUkF2gX1lMl9Dtb0Qvy1BLY0u9IgqrUoGv ipd/f3HtiXjACsBYEnNj9qrx/2njZ0jjt/yo87Kkxdzh8CxTe7xRd7pOHVGunVuRSF uaY9PEy/w3ylQgM1Mn+kd8BrGRgjpLkEBhmq5SgtPas3TClprUWEmRHjPjUVp8N6ro bwlF7XZ3RSJsA== From: Barry Song To: qi.zheng@linux.dev Cc: akpm@linux-foundation.org, axelrasmussen@google.com, baohua@kernel.org, baolin.wang@linux.alibaba.com, baoquan.he@linux.dev, corbet@lwn.net, david@kernel.org, hanchuanhua802@gmail.com, hanchuanhua@xiaomi.com, kasong@tencent.com, liam@infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, rdunlap@infradead.org, rppt@kernel.org, shakeel.butt@linux.dev, skhan@linuxfoundation.org, vbabka@kernel.org, weixugc@google.com, yuanchu@google.com Subject: Re: [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command Date: Thu, 3 Dec 2026 16:40:13 +0800 Message-Id: <20261203084013.13396-1-baohua@kernel.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: References: X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: o83c6jktgf9ek4t8yo3wwkdcnxhiqpax X-Rspamd-Queue-Id: 9750D20009 X-Rspamd-Server: rspam10 X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Rspam-User: X-HE-Tag: 1796287220-613103 X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0PGOrJ8x8cr14CtvSWSk1QFkofIyQk9LAEpvafd38N3YW71rgdV/deNXX7uBzltGIJoKtN/sg5annzaGbBovM5EOuynBj8J7S3kt5cdXFd5uHLZlw+kYtZRJR6wJlSUUIME47oDiwhoJiKdxSzVaauyL4X8/zEP/JlQLTLEhYED1pYjBV9iAfRrN4vNJRV9Di15qMVBC9b9puhr1vgY1dXV8w5NhetmXsCOkRevBp5HzZyleKxz3tJrQq3X+VlSzJnwiTWUvBIgID1ZHn/sqPcdvz5o+ZPYZO5b6nXuLVFMrjuQsXVR3EBxMbDU8HW/ooEejmy2CUs/zA7DPJV6qCoGFeRqrNazadddEV2EMQpKLjpggyOX9wQbNHmW/woqS+sTlas6AF9a1TjoUpiWo+HHWdlb7fVqZHToKgRK1EEWps2f35SIRhdnwNSswMzx+rJiKdZQbo8ypckTa871xaTxRCw+2EIhXGJd9bTJQfTF7RWVVn4A57VpHTnEea+EgkP6HqUXIFQ8MXtMKyw== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, Dec 3, 2026 at 2:43 PM Qi Zheng wrote: > > Hi Chuanhua, > > On 12/3/26 12:00 PM, Chuanhua Han wrote: > > From: Chuanhua Han > > > > The fourth field of the aging command in /sys/kernel/debug/lru_gen is > > documented as can_swap, but lru_gen_seq_write() parses it as a > > swappiness value, the same as for the eviction command. > > Commit b40599930f00 ("mm: add max swappiness arg to lru_gen for > > anonymous memory only") added "max" to this field, but documented it > > only for eviction. > > > > For aging, the value decides which VMAs the page table walk scans: 0 > > skips anon and shmem VMAs, "max" skips file VMAs other than shmem, and > > any value in [1, 200] scans both. Document the field as swappiness. > > > > Signed-off-by: Chuanhua Han > > --- > > v1 -> v2: > >   - Reword the subject to make it clear this is a doc fix (Barry) > >   - Say "VMAs" instead of "pages" and mention shmem VMAs (Barry) > >   - Fix the From/Signed-off-by mismatch (Barry) > >   - Drop the test notes (Barry) > > v1: https://lore.kernel.org/linux-mm/20261202121419.4026587-1-hanchuanhua@xiaomi.com/ > > > >   Documentation/admin-guide/mm/multigen_lru.rst | 9 ++++++--- > >   1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst > > index 9cb54b4ff5d9..7c2c6af61fe0 100644 > > --- a/Documentation/admin-guide/mm/multigen_lru.rst > > +++ b/Documentation/admin-guide/mm/multigen_lru.rst > > @@ -122,10 +122,13 @@ the former is the largest and that of the latter is the smallest. > >   Users can write the following command to ``lru_gen`` to create a new > >   generation ``max_gen_nr+1``: > >   > > -    ``+ memcg_id node_id max_gen_nr [can_swap [force_scan]]`` > > +    ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]`` > >   > > -``can_swap`` defaults to the swap setting and, if it is set to ``1``, > > -it forces the scan of anon pages when swap is off, and vice versa. > > +``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness`` > > Or could this also be `memcg->swappiness` under cgroup v1? Good catch. Currently, the documentation only mentions /proc/sys/vm/swappiness for both the eviction and aging paths. However, we actually override either vm_swappiness or memcg->swappiness in cgroup v1. static int run_cmd(char cmd, u64 memcg_id, int nid, unsigned long seq,                    struct scan_control *sc, int swappiness, unsigned long opt) {         ...           if (swappiness < MIN_SWAPPINESS)                 swappiness = get_swappiness(lruvec, sc);         else if (swappiness > SWAPPINESS_ANON_ONLY)                 goto done;         ..           return err; } I guess we can put some words for both "Proactive reclaim" and "aging" path with the below incremental changes? >From 36deb839afb2c1a3421a54889c1e43bdea438016 Mon Sep 17 00:00:00 2001 From: Barry Song Date: Thu, 3 Dec 2026 16:33:50 +0800 Subject: [PATCH] Fix-mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch Also mention that the swappiness override can override the memcg's swappiness in cgroup v1. Suggested-by: Qi Zheng Signed-off-by: Barry Song --- Documentation/admin-guide/mm/multigen_lru.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst index e59621fb052f..cfb208430411 100644 --- a/Documentation/admin-guide/mm/multigen_lru.rst +++ b/Documentation/admin-guide/mm/multigen_lru.rst @@ -125,10 +125,11 @@ generation ``max_gen_nr+1``: ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]`` ``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness`` -and the valid range is [0-200, max]. If it is set to ``0``, the page -table walk skips anon and shmem VMAs; if it is set to ``max``, it skips -file VMAs other than shmem; otherwise, it scans both. For any nonzero -value, anon and shmem VMAs are scanned even when swap is off. +or ``memory.swappiness`` in cgroup v1. The valid range is [0-200, max]. +If it is set to ``0``, the page table walk skips anon and shmem VMAs; +if it is set to ``max``, it skips file VMAs other than shmem; otherwise, +it scans both. For any nonzero value, anon and shmem VMAs are scanned +even when swap is off. ``force_scan`` defaults to ``1`` and, if it is set to ``0``, it employs heuristics to reduce the overhead, which is likely to reduce the coverage as well. @@ -153,10 +154,11 @@ generations less than or equal to ``min_gen_nr``. ``min_gen_nr`` should be less than ``max_gen_nr-1``, since ``max_gen_nr`` and ``max_gen_nr-1`` are not fully aged and therefore -cannot be evicted. ``swappiness`` -overrides the default value in ``/proc/sys/vm/swappiness`` and the valid -range is [0-200, max], with max being exclusively used for the reclamation -of anonymous memory. ``nr_to_reclaim`` limits the number of pages to evict. +cannot be evicted. ``swappiness`` overrides the default value in +``/proc/sys/vm/swappiness`` or ``memory.swappiness`` in cgroup v1. +The valid range is [0-200, max], with ``max`` being used exclusively +for the reclamation of anonymous memory. ``nr_to_reclaim`` limits +the number of pages to evict. A typical use case is that a job scheduler runs this command before it tries to land a new job on a server. If it fails to materialize enough -- 2.39.3 (Apple Git-146) > > > +and the valid range is [0-200, max]. If it is set to ``0``, the page > > +table walk skips anon and shmem VMAs; if it is set to ``max``, it skips > > +file VMAs other than shmem; otherwise, it scans both. For any nonzero > > +value, anon and shmem VMAs are scanned even when swap is off. > > It reads a bit odd at first glance. > > Maybe add a note on why we still need to scan here — e.g. to update the > stats? Demotion could also be a case? The context is already clear that we're talking about aging: "Users can write the following command to ``lru_gen`` to create a new generation ``max_gen_nr+1``." So it should already be clear that the scan is for aging, right? Thanks, Barry