On Wed, Jul 23, 2025 at 06:19:45PM +0900, Harry Yoo wrote:
The subject is a bit misleading. I think it should be something like
"alloc_tag: add an option to disable slab object accounting".
On Wed, Jul 23, 2025 at 04:03:28PM +0800, Zhenhua Huang wrote:
Mem profiling feature tracks both "alloc_slab_page"(page level) and slub
object level allocations. To track object level allocations,
slabobj_ext consumes 16 bytes per object for profiling slub object if
CONFIG_MEMCG is set.
Based on the data I've collected, this overhead accounts for approximately
5.7% of slub memory usage — a considerable cost.
w/ noslub slub_debug=-
Slab: 87520 kB
w/o noslub slub_debug=-
Slab: 92812 kB
Yes, the cost is not small and I hate that we have to pay 16 bytes of
memory overhead for each slab object when both memcg and memory profiling
are enabled.
I believe we did something about this for page_obj_ext; the exact
pointer compression scheme we went with escapes me at the moment.
We did it for page and not slab because page_obj_ext is a large fixed
size overhead and the page allocator is slower anyways, but it's
conceivable we could do the same for slub if the memory overhead vs. cpu
overhead tradeoff is worth it.
And - pointer compression is a valuable technique in general; coming up
with some fast general purpose code (perhaps involving virtual mappings,
we're not so limited on virtual address space as we used to be) might be
worth someone's time exploring.