Re: [PATCH v2 2/2] SLUB: Mark merged slab caches in /proc/slabinfo

David Rientjes
2010-09-15T00:02:48Z

On Wed, 15 Sep 2010, Pekka Enberg wrote:

> > > In my not-so-humble opinion, either the merging needs to go away
> > > entirely, or the misleading output needs to be fixed.
> > Cache merging may have been advertised as a bigger performance improvement
> > than it actually is, and I don't do it in my own slab allocator for other
> > reasons, but it does lead to more effective memory use by reducing slab
> > fragmentation. On one of my benchmarking servers, over 60% of caches are
> > merged and /sys/kernel/slab/.../partial reports roughly the same percent
> > of fewer total partial slabs over the system in comparison to
> > slub_nomerge.
> Last time I checked (and it's been a while), it did reduce _internal
> fragmentation_ for the naive "memory used after boot" scenario. I don't think
> I ever advertised it as a performance improvement. Dunno if somebody else did.
>

I believe that cache merging was advertised as being both a small
cacheline optimization and a method for reducing slab fragmentation by
filling up partial slabs. Regardless, I measured the latter to be much
more significant and found only a very slight improvement for netperf
TCP_RR on machines with large cpu counts in comparison to slub_nomerge.

I don't believe that we need to remove cache merging and allocate more
memory by default to be able to identify a particular cache using an
egregious amount of slab when troubleshooting a problem. That amount of
memory (probably 4-8MB) is significant without kmem_cache_shrink() since,
using my example where 60% of caches were merged into others, the partial
list won't shrink below min_partial slabs for those ~120 caches.

I prefer my suggestion of using the unique ids of each cache in
/proc/slabinfo since it won't unfairly attribute slab to caches that
didn't allocate it. Sure, /proc/slabinfo can't tell you which cache is at
fault without booting with slub_nomerge, enabling tracing, using
SLAB_TRACE, or kmemleak, but I think that's better than sacrificing the
slab fragmentation by default.