linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Christoph Lameter <cl@linux.com>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Pekka Enberg <penberg@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Matthew Wilcox <willy@infradead.org>,
	patches@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 06/12] mm, slub: don't create kmalloc-rcl caches with CONFIG_SLUB_TINY
Date: Thu, 24 Nov 2022 13:12:13 +0100	[thread overview]
Message-ID: <4fb214a4-0535-2d4a-fcde-bc2ab71329e3@suse.cz> (raw)
In-Reply-To: <Y39eLaW0mDNrHI6i@hyeyoo>

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 :/



  reply	other threads:[~2022-11-24 12:12 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 17:11 [PATCH 00/12] Introduce CONFIG_SLUB_TINY and deprecate SLOB Vlastimil Babka
2022-11-21 17:11 ` [PATCH 01/12] mm, slab: ignore hardened usercopy parameters when disabled Vlastimil Babka
2022-11-21 21:35   ` Kees Cook
2022-11-23 14:23     ` Vlastimil Babka
2022-11-24 11:16       ` Hyeonggon Yoo
2022-11-24 11:26         ` Vlastimil Babka
2022-11-24 12:33       ` Hyeonggon Yoo
2022-11-21 17:11 ` [PATCH 02/12] mm, slub: add CONFIG_SLUB_TINY Vlastimil Babka
2022-11-24  1:08   ` Roman Gushchin
2022-11-24 11:33   ` Hyeonggon Yoo
2022-11-25  7:55     ` Vlastimil Babka
2022-11-21 17:11 ` [PATCH 03/12] mm, slub: disable SYSFS support with CONFIG_SLUB_TINY Vlastimil Babka
2022-11-24  1:12   ` Roman Gushchin
2022-11-24  9:00     ` Vlastimil Babka
2022-11-21 17:11 ` [PATCH 04/12] mm, slub: retain no free slabs on partial list " Vlastimil Babka
2022-11-24  1:12   ` Roman Gushchin
2022-11-24 11:38   ` Hyeonggon Yoo
2022-11-21 17:11 ` [PATCH 05/12] mm, slub: lower the default slub_max_order " Vlastimil Babka
2022-11-24  1:16   ` Roman Gushchin
2022-11-24 11:40   ` Hyeonggon Yoo
2022-11-21 17:11 ` [PATCH 06/12] mm, slub: don't create kmalloc-rcl caches " Vlastimil Babka
2022-11-23 13:53   ` Vlastimil Babka
2022-11-24 12:06     ` Hyeonggon Yoo
2022-11-24 12:12       ` Vlastimil Babka [this message]
2022-11-24 12:55         ` Hyeonggon Yoo
2022-11-24 13:23     ` Hyeonggon Yoo
2022-11-24 14:25       ` Hyeonggon Yoo
2022-11-21 17:11 ` [PATCH 07/12] mm, slab: ignore SLAB_RECLAIM_ACCOUNT " Vlastimil Babka
2022-11-24  1:20   ` Roman Gushchin
2022-11-24  9:09     ` Vlastimil Babka
2022-11-24  9:21       ` Christoph Lameter
2022-11-27 23:11   ` Vlastimil Babka
2022-11-21 17:11 ` [PATCH 08/12] mm, slub: refactor free debug processing Vlastimil Babka
2022-11-27 10:18   ` Hyeonggon Yoo
2022-11-21 17:11 ` [PATCH 09/12] mm, slub: split out allocations from pre/post hooks Vlastimil Babka
2022-11-27 10:54   ` Hyeonggon Yoo
2022-11-27 23:01     ` Vlastimil Babka
2022-11-28 13:06       ` Hyeonggon Yoo
2022-11-21 17:12 ` [PATCH 10/12] mm, slub: remove percpu slabs with CONFIG_SLUB_TINY Vlastimil Babka
2022-11-27 11:05   ` Hyeonggon Yoo
2022-12-12 10:54     ` Vlastimil Babka
2022-12-12 13:11       ` Dennis Zhou
2022-12-13  3:04         ` Baoquan He
2022-12-13 14:02           ` Hyeonggon Yoo
2022-12-18 10:16   ` Hyeonggon Yoo
2022-11-21 17:12 ` [PATCH 11/12] mm, slub: don't aggressively inline " Vlastimil Babka
2022-11-28 13:19   ` Hyeonggon Yoo
2022-11-21 17:12 ` [PATCH 12/12] mm, slob: rename CONFIG_SLOB to CONFIG_SLOB_DEPRECATED Vlastimil Babka
2022-11-21 18:41   ` Aaro Koskinen
2022-11-21 19:42   ` Vlastimil Babka
2022-11-22  6:47   ` Damien Le Moal
2022-11-22 16:08   ` Arnd Bergmann
2022-11-24  1:21   ` Roman Gushchin
2022-12-02 17:59   ` Palmer Dabbelt
2022-12-05 12:25     ` Damien Le Moal
2022-12-13 13:41   ` Hyeonggon Yoo
2022-11-22 16:33 ` [PATCH 00/12] Introduce CONFIG_SLUB_TINY and deprecate SLOB Arnd Bergmann
2022-11-22 16:59   ` Vlastimil Babka
2022-11-22 17:15     ` Arnd Bergmann
2022-11-24 20:30 ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4fb214a4-0535-2d4a-fcde-bc2ab71329e3@suse.cz \
    --to=vbabka@suse.cz \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=patches@lists.linux.dev \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox