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

"Vlastimil Babka (SUSE)" <[email protected]>
Newsgroups org.kernel.vger.rcu,dev.linux.lists.linux-rt-devel,org.kernel.vger.bpf,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On 6/15/26 13:06, Harry Yoo (Oracle) wrote:
> struct rcu_head is overkill for kfree_rcu() because the callback
> function is always kfree() and thus there is no need for a function
> pointer.
> 
> It is enough to implement a linked list using a single pointer.
> Introduce a new struct called kfree_rcu_head (the name was suggested
> by Vlastimil Babka), which is similar to struct rcu_head but is only
> a single pointer. Use it only in kfree_rcu_nolock() for now.
> 
> It is intended that in most cases, kfree_rcu_nolock() goes through
> sheaves path and the field is not used at all. However, in the worst
> case where trylock fails or no empty sheaves are available, maintain
> a global list of objects that will later be freed after
> synchronize_rcu() in a workqueue. Since the fallback is intended to be
> the last resort, it focuses on minimizing complexity and memory usage.
> 
> To avoid crashing the kernel in a theoretical case where fallback path
> is taken before kmem_cache_init_late(), do not queue the work until
> the workqueue is actually allocated.
> 
> Factor out the logic that calculates object start address into
> object_start_address() from kvfree_rcu_cb() to avoid duplicating it.
> 
> Suggested-by: Alexei Starovoitov <[email protected]>
> Signed-off-by: Harry Yoo (Oracle) <[email protected]>

Looks reasonable, if it works fast enough in practice.
Acked-by: Vlastimil Babka (SUSE) <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.