Re: [PATCH for-next v3 8/9] mm/slab: introduce struct kfree_rcu_head and use in kfree_rcu_nolock()

From: sashiko-bot

Date: Mon Jun 15 2026 - 07:24:53 EST


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unbounded iteration over deferred RCU objects in the workqueue lacks `cond_resched()`, risking soft lockups.
--

commit 300f5714ccdf41bb1175c5f608a81c4624b37553
Author: Harry Yoo (Oracle) <harry@xxxxxxxxxx>

mm/slab: introduce struct kfree_rcu_head and use in kfree_rcu_nolock()

This commit introduces struct kfree_rcu_head to reduce memory overhead for
kfree_rcu_nolock(). It adds a global fallback list and a deferred workqueue
to handle cases where trylock fails or no empty sheaves are available.

> diff --git a/mm/slub.c b/mm/slub.c
> index 19018a979445e..853430c7fbe06 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
[ ... ]
> @@ -6431,12 +6435,50 @@ static void deferred_percpu_work_fn(struct irq_work *work)
[ ... ]
> +static void deferred_work_fn(struct work_struct *w)
> +{
> + struct llist_node *llnode, *pos, *t;
> +
> + llnode = llist_del_all(&deferred_free_by_rcu);
> + if (!llnode)
> + return;
> +
> + synchronize_rcu();
>
> - llnode = llist_del_all(objs_by_rcu);
> llist_for_each_safe(pos, t, llnode) {
> - struct rcu_head *head = (struct rcu_head *)pos;
> + void *obj = object_start_address(pos);
>
> - call_rcu(head, kvfree_rcu_cb);
> + kfree(obj);
> }
> }

[Severity: Medium]
Could this loop cause soft lockups on kernels without preemption?

Since deferred_free_by_rcu is a global list aggregating objects from all
CPUs when the fallback path is taken, it could potentially grow very large.
Executing kfree() on an unbounded number of objects in a single continuous
loop without yielding the CPU might trigger soft lockup warnings.

Would it be safer to add cond_resched() inside this loop to prevent hogging
the CPU?

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260615-kfree_rcu_nolock-v3-0-70a54f3775bb@xxxxxxxxxx?part=8