From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.95 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796288918; b=yzJvEAUJXz+bgOVSmxDF6OvMwBZ/B3wWP207v08/98F67zFTx6TtnpPXZwb7pC8N2BB2 HIavFeiY36n7VMTPdfiMzBm6VjkJzTjQu/130HaFerEceyM/bA1lDbditP+4MzahTSxU2 VQ4DYP4n+KAUxaL/FW2E+3gaSOuXhlZdoujEcjl2dXtUcDo86oAJCDdEDGEctlUEEMrBk nVuIzx4mhZZeKhCY8BGNlN7FCDAZVO6YCEiim/mGD93nn+L0zURr4xcCZt8R9rwNAyq0Q ieuAQq8bJYg81hibx1X8GbaQfNcWj1wX8J7VjZTh1Ulh3SURwKjo0FIuoMHsLgw5q5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288918; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=jwy/whYNWVJfPKPeloPxRivGnt4MqE60jA0E7ErQdFs=; b=slgsNHJD/McoJq1K7zTHbSwDF/BSQ8x/XzFLcdnlwAtFF//dQgd5BJ71/FD2bRaTBueZ VExYfE5ZwD2dNcT1IB1cGZqo/ZfwCO81NP/cwS6BWVKTaHBzGD828kiBseghRO3bpcHLe lJFv2mKjiiOYSUb3dSRoGWCR5yrnecTCkXq1SA1rl5vJ/JMOa/D5sGJZwx+a+xiSWro/5 z5L6MXdROY4EysZswZR93a8vNndIa4x3U6aQMWUusnrXx2AX2ZzuwuQQuj8a5vzazlmVe cq38X8DhD1imgQBjOQ2T5rvXFkEIcBjyj6NNhfChdG+4oiblFPxo+Quj8YkBOiSItiQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=AIGIH9Xb; arc=none smtp.remote-ip=91.218.175.95 Received: from mta0.migadu.com (out-95.mta0.migadu.com [91.218.175.95]) (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 56730606A322 for ; Thu, 3 Dec 2026 09:08:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 56730606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=AIGIH9Xb X-Envelope-To: linux-doc@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=mHxMLy+mhblxlrAXfhL4M0yziNebmN55c4aAJXEVMuw=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796288915; v=1; x=1796893715; b=AIGIH9Xb6JSSp4cplNU5vCkWClHlG5+w/sYq7kv7JsomZnbhwzQ3egqN84BfpA84Zydfpr60 G+wcSuY1xa4b7VOKv+JuMRrmYJZ2w3O63gh/9ieKwbLxaSSfiumiZyWSt1Yk5kaN11EzstjHPA2 UyRFsDC41uvGHLE6Jzi9oF9s= X-Envelope-To: linux-doc@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 7a7830ed6a1789eb; Thu, 03 Dec 2026 09:08:34 +0000 X-Mizu-Trace-ID: 7a7830ed6a1789eb X-Migadu-Flow: FLOW_OUT Message-ID: <61b3e09b-4b60-4654-b612-c8cf24b2574d@linux.dev> Date: Thu, 3 Dec 2026 17:08:26 +0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command To: Barry Song Cc: akpm@linux-foundation.org, axelrasmussen@google.com, 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 References: <20261203084013.13396-1-baohua@kernel.org> From: Qi Zheng In-Reply-To: <20261203084013.13396-1-baohua@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Barry, On 12/3/26 4:40 PM, Barry Song wrote: > 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? LGTM! > > 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 > > > >> +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? Fair enough. It just seemed odd to me that we still scan anon pages in the swap-off case. That seems fine as is — the aging section covers the details of what actually happens. Thanks, Qi