* [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters
@ 2026-11-20 8:37 Zhan Xusheng
2026-11-20 8:37 ` [PATCH v2 2/2] mm/slab: don't queue the page cache work under krcp->lock Zhan Xusheng
2026-11-23 14:19 ` [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters Harry Yoo (Meta)
0 siblings, 2 replies; 4+ messages in thread
From: Zhan Xusheng @ 2026-11-20 8:37 UTC (permalink / raw)
To: vbabka, harry
Cc: urezki, paulmck, qiang.zhang, akpm, hao.li, cl, rientjes,
roman.gushchin, linux-mm, rcu, linux-kernel, zhanxusheng, stable
From: Zhan Xusheng <zhanxusheng@xiaomi.com>
The move of kvfree_rcu() to mm/slab_common.c dropped the "rcutree."
MODULE_PARAM_PREFIX, so rcu_min_cached_objs and
rcu_delay_page_cache_fill_msec became slab_common.* and the documented
rcutree.* names are silently ignored. Restore the prefix; the
slab_common.* names, never documented, stop working.
Fixes: bbe658d65802 ("mm/slab: Move kvfree_rcu() into SLAB")
Cc: stable@vger.kernel.org
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Reviewed-by: Harry Yoo (Meta) <harry@kernel.org>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Reviewed-by: Hao Li <hao.li@linux.dev>
---
v2: as in slab/for-next-fixes.
mm/slab_common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 01c64ef661e7..41dea01a8c1f 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1367,6 +1367,10 @@ void __init kvfree_rcu_init(void)
#else /* CONFIG_KVFREE_RCU_BATCHED */
+/* Keep the prefix inherited from RCU */
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "rcutree."
+
/*
* This rcu parameter is runtime-read-only. It reflects
* a minimum allowed number of objects which can be cached
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] mm/slab: don't queue the page cache work under krcp->lock 2026-11-20 8:37 [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters Zhan Xusheng @ 2026-11-20 8:37 ` Zhan Xusheng 2026-11-22 15:45 ` Uladzislau Rezki 2026-11-23 14:19 ` [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters Harry Yoo (Meta) 1 sibling, 1 reply; 4+ messages in thread From: Zhan Xusheng @ 2026-11-20 8:37 UTC (permalink / raw) To: vbabka, harry Cc: urezki, paulmck, qiang.zhang, akpm, hao.li, cl, rientjes, roman.gushchin, linux-mm, rcu, linux-kernel, zhanxusheng, stable From: Zhan Xusheng <zhanxusheng@xiaomi.com> Commit 56292e8609e3 ("rcu/tree: Defer kvfree_rcu() allocation to a clean context") deferred page allocations to a workqueue. To avoid deadlocks with the scheduler, it used hrtimer to queue the work instead of queueing it directly. Commit d0bfa8b3c411 ("kvfree_rcu: Release a page cache under memory pressure") later added a backoff mechanism under memory pressure, but did not consider that queue_delayed_work() with delay = 0 immediately queues the work and introduced the deadlock commit 56292e8609e3 tried to avoid. run_page_cache_worker() runs under krcp->lock, from kvfree_call_rcu() callers that may hold more, such as set_cpus_allowed_force() under pi_lock, so it kicks the refill work from an hrtimer. Under memory pressure it instead queues the work with a delay of rcutree.rcu_delay_page_cache_fill_msec, which may be 0, and a zero delay queues it at once, taking pool->lock under krcp->lock. With the delay set to 0, calling kvfree_rcu() on vmalloc memory under pi_lock after a drop_caches makes lockdep report: Chain exists of: &pool->lock --> &p->pi_lock --> krc.lock A zero delay also defeats the backoff, which is there to defer the refill under memory pressure. Clamp the delay to [1:100000] ms, so that queue_delayed_work() always arms a timer, and update the documented range. Fixes: d0bfa8b3c411 ("kvfree_rcu: Release a page cache under memory pressure") Cc: stable@vger.kernel.org Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com> --- v2: clamp the delay to [1:100000] ms instead of using the hrtimer for a zero delay (Uladzislau). The changelog is Harry's version from slab/for-next-fixes, with the last paragraph rewritten. The Reviewed-by tags of Vlastimil and Hao on v1 are not carried over, as the code changed. Tested in a VM on v7.4-rc1 with lockdep: with rcutree.rcu_delay_page_cache_fill_msec=0, patch 1 alone reports the circular dependency above; with this patch the boot log says "Adjusting rcutree.rcu_delay_page_cache_fill_msec to 1 ms." and lockdep stays quiet. v1: https://lore.kernel.org/all/20261028134647.3176080-1-zhanxusheng1024@gmail.com/ Documentation/admin-guide/kernel-parameters.txt | 2 +- mm/slab_common.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0b3c140babd9..0d1d76a6af70 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5763,7 +5763,7 @@ Kernel parameters rcutree.rcu_delay_page_cache_fill_msec= [KNL] Set the page-cache refill delay (in milliseconds) in response to low-memory conditions. The range - of permitted values is in the range 0:100000. + of permitted values is in the range 1:100000. rcutree.rcu_divisor= [KNL] Set the shift-right count to use to compute diff --git a/mm/slab_common.c b/mm/slab_common.c index 41dea01a8c1f..6fb453118641 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -2262,12 +2262,12 @@ void __init kvfree_rcu_init(void) WQ_UNBOUND | WQ_MEM_RECLAIM, 0); WARN_ON(!rcu_reclaim_wq); - /* Clamp it to [0:100] seconds interval. */ - if (rcu_delay_page_cache_fill_msec < 0 || + /* Clamp it to [1:100000] milliseconds interval. */ + if (rcu_delay_page_cache_fill_msec < 1 || rcu_delay_page_cache_fill_msec > 100 * MSEC_PER_SEC) { rcu_delay_page_cache_fill_msec = - clamp(rcu_delay_page_cache_fill_msec, 0, + clamp(rcu_delay_page_cache_fill_msec, 1, (int) (100 * MSEC_PER_SEC)); pr_info("Adjusting rcutree.rcu_delay_page_cache_fill_msec to %d ms.\n", -- 2.43.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] mm/slab: don't queue the page cache work under krcp->lock 2026-11-20 8:37 ` [PATCH v2 2/2] mm/slab: don't queue the page cache work under krcp->lock Zhan Xusheng @ 2026-11-22 15:45 ` Uladzislau Rezki 0 siblings, 0 replies; 4+ messages in thread From: Uladzislau Rezki @ 2026-11-22 15:45 UTC (permalink / raw) To: Zhan Xusheng Cc: vbabka, harry, urezki, paulmck, qiang.zhang, akpm, hao.li, cl, rientjes, roman.gushchin, linux-mm, rcu, linux-kernel, zhanxusheng, stable On Fri, Nov 20, 2026 at 04:37:07PM +0800, Zhan Xusheng wrote: > From: Zhan Xusheng <zhanxusheng@xiaomi.com> > > Commit 56292e8609e3 ("rcu/tree: Defer kvfree_rcu() allocation to a > clean context") deferred page allocations to a workqueue. To avoid > deadlocks with the scheduler, it used hrtimer to queue the work instead > of queueing it directly. > > Commit d0bfa8b3c411 ("kvfree_rcu: Release a page cache under memory > pressure") later added a backoff mechanism under memory pressure, but > did not consider that queue_delayed_work() with delay = 0 immediately > queues the work and introduced the deadlock commit 56292e8609e3 tried to > avoid. > > run_page_cache_worker() runs under krcp->lock, from kvfree_call_rcu() > callers that may hold more, such as set_cpus_allowed_force() under > pi_lock, so it kicks the refill work from an hrtimer. Under memory > pressure it instead queues the work with a delay of > rcutree.rcu_delay_page_cache_fill_msec, which may be 0, and a zero delay > queues it at once, taking pool->lock under krcp->lock. > > With the delay set to 0, calling kvfree_rcu() on vmalloc memory under > pi_lock after a drop_caches makes lockdep report: > > Chain exists of: > &pool->lock --> &p->pi_lock --> krc.lock > > A zero delay also defeats the backoff, which is there to defer the > refill under memory pressure. Clamp the delay to [1:100000] ms, so that > queue_delayed_work() always arms a timer, and update the documented > range. > > Fixes: d0bfa8b3c411 ("kvfree_rcu: Release a page cache under memory pressure") > Cc: stable@vger.kernel.org > Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com> > --- > v2: clamp the delay to [1:100000] ms instead of using the hrtimer for a > zero delay (Uladzislau). The changelog is Harry's version from > slab/for-next-fixes, with the last paragraph rewritten. The > Reviewed-by tags of Vlastimil and Hao on v1 are not carried over, as > the code changed. > > Tested in a VM on v7.4-rc1 with lockdep: with > rcutree.rcu_delay_page_cache_fill_msec=0, patch 1 alone reports the > circular dependency above; with this patch the boot log says "Adjusting > rcutree.rcu_delay_page_cache_fill_msec to 1 ms." and lockdep stays > quiet. > > v1: https://lore.kernel.org/all/20261028134647.3176080-1-zhanxusheng1024@gmail.com/ > > Documentation/admin-guide/kernel-parameters.txt | 2 +- > mm/slab_common.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 0b3c140babd9..0d1d76a6af70 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -5763,7 +5763,7 @@ Kernel parameters > rcutree.rcu_delay_page_cache_fill_msec= [KNL] > Set the page-cache refill delay (in milliseconds) > in response to low-memory conditions. The range > - of permitted values is in the range 0:100000. > + of permitted values is in the range 1:100000. > > rcutree.rcu_divisor= [KNL] > Set the shift-right count to use to compute > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 41dea01a8c1f..6fb453118641 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -2262,12 +2262,12 @@ void __init kvfree_rcu_init(void) > WQ_UNBOUND | WQ_MEM_RECLAIM, 0); > WARN_ON(!rcu_reclaim_wq); > > - /* Clamp it to [0:100] seconds interval. */ > - if (rcu_delay_page_cache_fill_msec < 0 || > + /* Clamp it to [1:100000] milliseconds interval. */ > + if (rcu_delay_page_cache_fill_msec < 1 || > rcu_delay_page_cache_fill_msec > 100 * MSEC_PER_SEC) { > > rcu_delay_page_cache_fill_msec = > - clamp(rcu_delay_page_cache_fill_msec, 0, > + clamp(rcu_delay_page_cache_fill_msec, 1, > (int) (100 * MSEC_PER_SEC)); > > pr_info("Adjusting rcutree.rcu_delay_page_cache_fill_msec to %d ms.\n", > -- > 2.43.0 > Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com> Thank you! -- Uladzislau Rezki ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters 2026-11-20 8:37 [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters Zhan Xusheng 2026-11-20 8:37 ` [PATCH v2 2/2] mm/slab: don't queue the page cache work under krcp->lock Zhan Xusheng @ 2026-11-23 14:19 ` Harry Yoo (Meta) 1 sibling, 0 replies; 4+ messages in thread From: Harry Yoo (Meta) @ 2026-11-23 14:19 UTC (permalink / raw) To: vbabka, Zhan Xusheng Cc: kernel-team, urezki, paulmck, qiang.zhang, akpm, hao.li, cl, rientjes, roman.gushchin, linux-mm, rcu, linux-kernel, zhanxusheng, stable On Fri, 20 Nov 2026 16:37:06 +0800, Zhan Xusheng wrote: > The move of kvfree_rcu() to mm/slab_common.c dropped the "rcutree." > MODULE_PARAM_PREFIX, so rcu_min_cached_objs and > rcu_delay_page_cache_fill_msec became slab_common.* and the documented > rcutree.* names are silently ignored. Restore the prefix; the > slab_common.* names, never documented, stop working. > > > [...] Applied to mm/slab.git slab/for-next-fixes, thanks! [1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters commit: 2197ea27ed0ff25cb294a3e6656ae6e0a23c8efd [2/2] mm/slab: don't queue the page cache work under krcp->lock commit: 0983f88e2d6d734dc35cd9ba4f4c3b4082555024 -- Cheers, Harry / Hyeonggon ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 14:19 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-20 8:37 [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters Zhan Xusheng 2026-11-20 8:37 ` [PATCH v2 2/2] mm/slab: don't queue the page cache work under krcp->lock Zhan Xusheng 2026-11-22 15:45 ` Uladzislau Rezki 2026-11-23 14:19 ` [PATCH v2 1/2] mm/slab: restore the rcutree. prefix of the kvfree_rcu parameters Harry Yoo (Meta)
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.