]> 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)
committerVlastimil Babka <vbabka@suse.cz>
Wed, 5 Feb 2025 09:45:29 +0000 (10:45 +0100)
commit49d5377b38aa127451cf5dc6d6ea5d9da7f465a4
tree17a62857f3da10d61ae128b1245154db55996461
parent7f4b19ef3129e1f2e1856b3ee475a02c0be34891
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