]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rcu, slab: use a regular callback function for kvfree_rcu
authorVlastimil Babka <vbabka@suse.cz>
Mon, 3 Feb 2025 09:28:49 +0000 (10:28 +0100)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 4 Mar 2025 16:35:04 +0000 (11:35 -0500)
commit288ee48d7b6032ebce60b6997e6f0c3c47d76b3d
tree174df4b7354d7420af2d0a44dd96cb4d67b67efb
parent04af253201adac1c5a5d1eca922d09dfb316a2cb
rcu, slab: use a regular callback function for kvfree_rcu

RCU has been special-casing callback function pointers that are integers
lower than 4096 as offsets of rcu_head for kvfree() instead. The tree
RCU implementation no longer does that as the batched kvfree_rcu() is
not a simple call_rcu(). The tiny RCU still does, and the plan is also
to make tree RCU use call_rcu() for SLUB_TINY configurations.

Instead of teaching tree RCU again to special case the offsets, let's
remove the special casing completely. Since there's no SLOB anymore, it
is possible to create a callback function that can take a pointer to a
middle of slab object with unknown offset and determine the object's
pointer before freeing it, so implement that as kvfree_rcu_cb().

Large kmalloc and vmalloc allocations are handled simply by aligning
down to page size. For that we retain the requirement that the offset is
smaller than 4096. But we can remove __is_kvfree_rcu_offset() completely
and instead just opencode the condition in the BUILD_BUG_ON() check.

Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
include/linux/rcupdate.h
kernel/rcu/tiny.c
mm/slab.h
mm/slab_common.c
mm/slub.c