From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04B03C43217 for ; Thu, 24 Nov 2022 13:23:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90EDA6B0071; Thu, 24 Nov 2022 08:23:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BEFB6B0072; Thu, 24 Nov 2022 08:23:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 786486B0074; Thu, 24 Nov 2022 08:23:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 68F6E6B0071 for ; Thu, 24 Nov 2022 08:23:53 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 494DEABC40 for ; Thu, 24 Nov 2022 13:23:53 +0000 (UTC) X-FDA: 80168403546.09.3AC75E0 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf24.hostedemail.com (Postfix) with ESMTP id E161D18000B for ; Thu, 24 Nov 2022 13:23:51 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id 136so1578991pga.1 for ; Thu, 24 Nov 2022 05:23:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8y/808AEnHwi3gKJBM+uetYeo4u9vQ49H82jeAEWhHU=; b=V+QjrA/U7ScHxJ9ZYpE7O3RSWmSkzchs2ANjV8VzLrCCY/niTxtyQWGpPbyM9XkmyW WUZzaMIhKqFZFU8oxa222F3tpEq3Y1YS3msg7uTrIWc7lZ5zVT2Av3x39VFIhcPpBlAk G0hZmwyYAAjE6+KaJbFb3EiDMmTQzATe/MJ+UHCfocUWVLNcKAVFKgrP36sOAkUgFzeN HMPL3Zi3SO02hDye9/9wyECt8ctuhmRJx2U+jb9AdWcny/T0kfhMZgTavulYELFx/8oW VsVdiUQYGBOJ3nWlF4RTajvzflna4ZgeRJ+Q76rY2eJeasSHYJVyRRfSiXuq/KwD/6Ym Brfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8y/808AEnHwi3gKJBM+uetYeo4u9vQ49H82jeAEWhHU=; b=dafWuw4cVoyqX/gd/v8a34ckOZOi9U4ryIIhcSood6we5xRsbKN1vVECFvQ/ekyE+1 G8gf4B2dciANaZHv5wR9qAveHhrtX+hDHi5wTon8k4IgMl0K8Ceqy6LUYIJY4yxxJj07 Rcx9FtA24A/ECwk0ds8/ga+KjCnybBTMdw2mzEZSPrgHZ0e6h+W1fVIPKwyeifWgO7jI t0OYkjwOu4Sy41/Ep1PmYa2gK/uhcf7pLEXDg6NqRA/U99htEq8VQhFOGU4VsnihcKM6 JBimeT3yE5uzUReY0lklFL0gbRHtJPenBhaRmS0LSq/kyrLCymzWxwRicKSF0oFHc/fB B8Eg== X-Gm-Message-State: ANoB5pmlqNy9EjDz1YCR2Z2D/dYk1k89xTnNHurcxaJ+EsixqGPTR+WF bBAIismxYdzAOfryevcTla4= X-Google-Smtp-Source: AA0mqf4TyZNNwzl3rHjI/din13NVJjNuRxJ1olfSN/enVVVxr/ZPBliA6gHtprrBtvgwnZY7JQPUMg== X-Received: by 2002:a63:4c4b:0:b0:46f:f112:e782 with SMTP id m11-20020a634c4b000000b0046ff112e782mr11630314pgl.219.1669296230710; Thu, 24 Nov 2022 05:23:50 -0800 (PST) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id ik16-20020a170902ab1000b00172f6726d8esm1229687plb.277.2022.11.24.05.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 05:23:49 -0800 (PST) Date: Thu, 24 Nov 2022 22:23:44 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg , Roman Gushchin , Andrew Morton , Linus Torvalds , Matthew Wilcox , 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 Message-ID: References: <20221121171202.22080-1-vbabka@suse.cz> <20221121171202.22080-7-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="V+QjrA/U"; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669296231; a=rsa-sha256; cv=none; b=dC9W//f2uSPCc5iPkokqPwo0mR2I/ior1lWC46Dg29n3j8u6XVeciUfdjpyd+CPFugWYy4 p2Z8z2I5LOthdRrmm4h4uZ+acPI/TvnqjPpUQd14uOoZDr7hRTKGfNxxmT8rHXIp0tJv4U 6jWtlTZNM1f4jOXrddo4aMj0EcKjGi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669296231; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8y/808AEnHwi3gKJBM+uetYeo4u9vQ49H82jeAEWhHU=; b=skBbbr7084HR3gXiXgrh+Bnkkc4E4uoRaA+xuNocTijyUlUK7GUmz1BrNlES8O6+kyk4Qy Fy90vTqgxKmUhZfnI1RdKh6MmjRTm00HyuongGnEBFKXiQuK/xNCOrZeTMF8qyKwhhrNKf cQjQTtJBcZnq92GfJIZennCg52uStRk= X-Rspamd-Queue-Id: E161D18000B X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="V+QjrA/U"; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam06 X-Stat-Signature: id9m3yf9c8cde5ytmuejwt8e8e6xxkf4 X-HE-Tag: 1669296231-285850 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 > > 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 > 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 > --- > 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 > }; > diff --git a/mm/slab_common.c b/mm/slab_common.c > index a8cb5de255fc..907d52963806 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -770,10 +770,16 @@ EXPORT_SYMBOL(kmalloc_size_roundup); > #define KMALLOC_CGROUP_NAME(sz) > #endif > > +#ifndef CONFIG_SLUB_TINY > +#define KMALLOC_RCL_NAME(sz) .name[KMALLOC_RECLAIM] = "kmalloc-rcl-" #sz, > +#else > +#define KMALLOC_RCL_NAME(sz) > +#endif > + > #define INIT_KMALLOC_INFO(__size, __short_size) \ > { \ > .name[KMALLOC_NORMAL] = "kmalloc-" #__short_size, \ > - .name[KMALLOC_RECLAIM] = "kmalloc-rcl-" #__short_size, \ > + KMALLOC_RCL_NAME(__short_size) \ > KMALLOC_CGROUP_NAME(__short_size) \ > KMALLOC_DMA_NAME(__short_size) \ > .size = __size, \ > @@ -859,7 +865,7 @@ void __init setup_kmalloc_cache_index_table(void) > static void __init > new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) > { > - if (type == KMALLOC_RECLAIM) { > + if ((KMALLOC_RECLAIM != KMALLOC_NORMAL) && (type == KMALLOC_RECLAIM)) { for consistency this can be: if (IS_ENABLED(CONFIG_SLUB_TINY) && (type == KMALLOC_RECLAIM)) { But yeah, it's not a big deal. > flags |= SLAB_RECLAIM_ACCOUNT; > } else if (IS_ENABLED(CONFIG_MEMCG_KMEM) && (type == KMALLOC_CGROUP)) { > if (mem_cgroup_kmem_disabled()) { > -- > 2.38.1 > For either case: Looks good to me. Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> -- Thanks, Hyeonggon