]> git.ipfire.org Git - thirdparty/bird.git/commit
Slab: Allowing concurrent allocations without locking
authorKaterina Kubecova <katerina.kubecova@nic.cz>
Wed, 18 Dec 2024 11:18:17 +0000 (12:18 +0100)
committerMaria Matejka <mq@ucw.cz>
Mon, 10 Mar 2025 10:51:28 +0000 (11:51 +0100)
commit5444a1c5df00defdcec3c5adb1c70e88d3c2f86a
tree9cdbe3777a64a1bfc50cbc4b32710945649664d2
parentdbc3d43ba365cd8fcdc202be1a55cbdcf60c3c11
Slab: Allowing concurrent allocations without locking

Every active thread now gets its own page from which it allocates
blocks. This enables concurrent allocations without much contention,
alleviating the need for mutex locking over Slab allocations,
effectively making Slab lock-free.

This adds some overhead in case every thread just allocates one item and
finishes, yet these situations should not happen too often and/or have
too large impact, so we don't need to care much. If something like this
happens, though, please cry. We'll cry with you, for sure.

Also there is a cleanup routine now which has to run often enough to
ensure that pages with some freed blocks get available for allocations.

This rework also changes the API of slabs, requiring an event list to
send cleanup events to, to be passed to sl_new().
24 files changed:
lib/bitmap.c
lib/bitmap.h
lib/bitmap_test.c
lib/fib.h
lib/netindex.c
lib/resource.h
lib/slab.c
lib/slab_test.c
nest/iface.c
nest/iface.h
nest/mpls.c
nest/neighbor.c
nest/rt-attr.c
nest/rt-fib.c
nest/rt-fib_test.c
nest/rt-table.c
proto/aggregator/aggregator.c
proto/babel/babel.c
proto/bfd/bfd.c
proto/bgp/attrs.c
proto/ospf/ospf.c
proto/ospf/topology.c
proto/radv/radv.c
proto/rip/rip.c