lkml.org 
[lkml]   [2022]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 06/12] mm, slub: don't create kmalloc-rcl caches with CONFIG_SLUB_TINY
On Thu, Nov 24, 2022 at 01:12:13PM +0100, Vlastimil Babka wrote:
> On 11/24/22 13:06, Hyeonggon Yoo wrote:
> > On Wed, Nov 23, 2022 at 02:53:43PM +0100, Vlastimil Babka wrote:
> >> On 11/21/22 18:11, Vlastimil Babka wrote:
> >> > Distinguishing kmalloc(__GFP_RECLAIMABLE) can help against fragmentation
> >> > by grouping pages by mobility, but on tiny systems the extra memory
> >> > overhead of separate set of kmalloc-rcl caches will probably be worse,
> >> > and mobility grouping likely disabled anyway.
> >> >
> >> > Thus with CONFIG_SLUB_TINY, don't create kmalloc-rcl caches and use the
> >> > regular ones.
> >> >
> >> > Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> >>
> >> Fixed up in response to lkp report for a MEMCG_KMEM+SLUB_TINY combo:
> >> ---8<---
> >> From c1ec0b924850a2863d061f316615d596176f15bb Mon Sep 17 00:00:00 2001
> >> From: Vlastimil Babka <vbabka@suse.cz>
> >> Date: Tue, 15 Nov 2022 18:19:28 +0100
> >> Subject: [PATCH 06/12] mm, slub: don't create kmalloc-rcl caches with
> >> CONFIG_SLUB_TINY
> >>
> >> Distinguishing kmalloc(__GFP_RECLAIMABLE) can help against fragmentation
> >> by grouping pages by mobility, but on tiny systems the extra memory
> >> overhead of separate set of kmalloc-rcl caches will probably be worse,
> >> and mobility grouping likely disabled anyway.
> >>
> >> Thus with CONFIG_SLUB_TINY, don't create kmalloc-rcl caches and use the
> >> regular ones.
> >>
> >> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> >> ---
> >> include/linux/slab.h | 9 +++++++--
> >> mm/slab_common.c | 10 ++++++++--
> >> 2 files changed, 15 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/include/linux/slab.h b/include/linux/slab.h
> >> index 45efc6c553b8..ae2d19ec8467 100644
> >> --- a/include/linux/slab.h
> >> +++ b/include/linux/slab.h
> >> @@ -336,12 +336,17 @@ enum kmalloc_cache_type {
> >> #endif
> >> #ifndef CONFIG_MEMCG_KMEM
> >> KMALLOC_CGROUP = KMALLOC_NORMAL,
> >> -#else
> >> - KMALLOC_CGROUP,
> >> #endif
> >> +#ifdef CONFIG_SLUB_TINY
> >> + KMALLOC_RECLAIM = KMALLOC_NORMAL,
> >> +#else
> >> KMALLOC_RECLAIM,
> >> +#endif
> >> #ifdef CONFIG_ZONE_DMA
> >> KMALLOC_DMA,
> >> +#endif
> >> +#ifdef CONFIG_MEMCG_KMEM
> >> + KMALLOC_CGROUP,
> >> #endif
> >> NR_KMALLOC_TYPES
> >> };
> >
> > Can you please elaborate what the lkp report was about
> > and how you fixed it? I'm not getting what the problem of previous
> > version is.
>
> Report here:
> https://lore.kernel.org/all/202211231949.nIyAWKam-lkp@intel.com/
>
> Problem is that if the preprocessing results in e.g.
> KMALLOC_NORMAL = 0,
> KMALLOC_DMA = KMALLOC_NORMAL
> KMALLOC_CGROUP,
> KMALLOC_RECLAIM = KMALLOC_NORMAL,
> NR_KMALLOC_TYPES
>
> then NR_KMALLOC_TYPES is not 2, but 1, because the enum's internal counter
> got reset to 0 by KMALLOC_RECLAIM = KMALLOC_NORMAL. A common gotcha :/

Thanks for quick and kind explanation :)
That was easy to be missed.

--
Thanks,
Hyeonggon

\
 
 \ /
  Last update: 2022-11-24 13:57    [W:0.076 / U:2.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site