Initial implementation of jemalloc-style arenas for the hardened malloc implementation:
github.com/AndroidHardeni
There's an independent slab region per arena, with threads statically assigned to an arena for now. It determines arena from address on free, just like size class.
Conversation
There are fully independent slab allocators for each size class, so locking is now per-size-class-per-arena. It's relatively fine grained. Each slab allocator uses an independent CSPRNG seeded from getrandom to avoid additional synchronization from extensive usage of randomness.
1
This is the function mapping from an allocation address to the arena and size class:
github.com/AndroidHardeni
It will need to be optimized by making ARENA_SIZE into a power of 2, similar to how REAL_CLASS_REGION_SIZE is already a power of 2 with the default configuration values.
