Message ID | 20180718133620.6205-4-vbabka@suse.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Jul 18, 2018 at 03:36:16PM +0200, Vlastimil Babka wrote: > In SLAB, OFF_SLAB caches allocate management structures (currently just the > freelist) from kmalloc caches when placement in a slab page together with > objects would lead to suboptimal memory usage. For SLAB_RECLAIM_ACCOUNT caches, > we can allocate the freelists from the newly introduced reclaimable kmalloc > caches, because shrinking the OFF_SLAB cache will in general result to freeing > of the freelists as well. This should improve accounting and anti-fragmentation > a bit. > > Signed-off-by: Vlastimil Babka <vbabka@suse.cz> I'm not quite convinced by this one. The freelist cache is tied to the lifetime of the slab and not the objects. A single freelist can be reclaimed eventually but for caches with many objects per slab, it could take a lot of shrinking random objects to reclaim one freelist. Functionally the patch appears to be fine.
On 07/19/2018 10:35 AM, Mel Gorman wrote: > On Wed, Jul 18, 2018 at 03:36:16PM +0200, Vlastimil Babka wrote: >> In SLAB, OFF_SLAB caches allocate management structures (currently just the >> freelist) from kmalloc caches when placement in a slab page together with >> objects would lead to suboptimal memory usage. For SLAB_RECLAIM_ACCOUNT caches, >> we can allocate the freelists from the newly introduced reclaimable kmalloc >> caches, because shrinking the OFF_SLAB cache will in general result to freeing >> of the freelists as well. This should improve accounting and anti-fragmentation >> a bit. >> >> Signed-off-by: Vlastimil Babka <vbabka@suse.cz> > > I'm not quite convinced by this one. The freelist cache is tied to the > lifetime of the slab and not the objects. A single freelist can be reclaimed > eventually but for caches with many objects per slab, it could take a lot > of shrinking random objects to reclaim one freelist. Functionally the > patch appears to be fine. Hm you're right that the reclaimability of freelist is maybe too much detached, and could do more harm than good for the reclaimable caches. I will probably drop it unless I can measure it's an improvement. Thanks.
On Wed, 18 Jul 2018, Vlastimil Babka wrote: > In SLAB, OFF_SLAB caches allocate management structures (currently just the > freelist) from kmalloc caches when placement in a slab page together with > objects would lead to suboptimal memory usage. For SLAB_RECLAIM_ACCOUNT caches, > we can allocate the freelists from the newly introduced reclaimable kmalloc > caches, because shrinking the OFF_SLAB cache will in general result to freeing > of the freelists as well. This should improve accounting and anti-fragmentation > a bit. Acked-by: Christoph Lameter <cl@linux.com>
diff --git a/mm/slab.c b/mm/slab.c index 9515798f37b2..99d779ba2b92 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2140,8 +2140,13 @@ int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags) #endif if (OFF_SLAB(cachep)) { + /* + * If this cache is reclaimable, allocate also freelists from + * a reclaimable kmalloc cache. + */ cachep->freelist_cache = - kmalloc_slab(cachep->freelist_size, 0u); + kmalloc_slab(cachep->freelist_size, + cachep->allocflags & __GFP_RECLAIMABLE); } err = setup_cpu_cache(cachep, gfp);
In SLAB, OFF_SLAB caches allocate management structures (currently just the freelist) from kmalloc caches when placement in a slab page together with objects would lead to suboptimal memory usage. For SLAB_RECLAIM_ACCOUNT caches, we can allocate the freelists from the newly introduced reclaimable kmalloc caches, because shrinking the OFF_SLAB cache will in general result to freeing of the freelists as well. This should improve accounting and anti-fragmentation a bit. Signed-off-by: Vlastimil Babka <vbabka@suse.cz> --- mm/slab.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)