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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88327C433F5 for ; Thu, 7 Apr 2022 09:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GrezhA1VrpF64ltEFwIjKI00X+6FNlE/kKyesmfKQOY=; b=Pir1+1RHY7aarV NMN3AsSP8Lt9yXwcVArYmhm8FBam/j33Xq9rxIh8URq+sKJ8+ooT5lOxTOFtLk0kvlzuEn2/xQD17 NA8/ymdWHefXieRVI5AanTbBZ5emLWWVO/4H1oE81G3pF1HZMLgvBlHBku1Gvr+lj3fHfSIFIzzNy sz6w58cwmWzmOEnk96udtHpvCtpcGszey1o2FBNSSd/RPBKcCAxyFKroeWT/4qAUtlPMNMYxzMmcd revLTCuw+rXKd6km1EFYeyZNpNl/nOslY9txh/yTBno5x+4dxfwF0UYDh8yZGOzCLDYt0OueNtT1f 3+gAbEQqgGJ0TTzju+2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncO9F-00Aib6-1g; Thu, 07 Apr 2022 09:09:49 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncNqY-00AZs4-6F for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 08:50:32 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4728C60CBA; Thu, 7 Apr 2022 08:50:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2175C385A0; Thu, 7 Apr 2022 08:50:26 +0000 (UTC) Date: Thu, 7 Apr 2022 09:50:23 +0100 From: Catalin Marinas To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/10] mm/slab: Allow dynamic kmalloc() minimum alignment Message-ID: References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-9-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_015030_330653_48A01341 X-CRM114-Status: GOOD ( 25.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 07, 2022 at 03:46:37AM +0000, Hyeonggon Yoo wrote: > On Tue, Apr 05, 2022 at 02:57:56PM +0100, Catalin Marinas wrote: > > --- a/mm/slab_common.c > > +++ b/mm/slab_common.c > > @@ -838,9 +838,18 @@ void __init setup_kmalloc_cache_index_table(void) > > } > > } > > > > -static void __init > > +unsigned int __weak arch_kmalloc_minalign(void) > > +{ > > + return ARCH_KMALLOC_MINALIGN; > > +} > > + > > As ARCH_KMALLOC_ALIGN and arch_kmalloc_minalign() may not be same after > patch 10, I think s/ARCH_KMALLOC_ALIGN/arch_kmalloc_minalign/g > for every user of it would be more correct? Not if the code currently using ARCH_KMALLOC_MINALIGN needs a constant. Yes, there probably are a few places where the code can cope with a dynamic arch_kmalloc_minalign() but there are two other cases where a constant is needed: 1. As a BUILD_BUG check because the code is storing some flags in the bottom bits of a pointer. A smaller ARCH_KMALLOC_MINALIGN works just fine here. 2. As a static alignment for DMA requirements. That's where the newly exposed ARCH_DMA_MINALIGN should be used. Note that this series doesn't make the situation any worse than before since ARCH_DMA_MINALIGN stays at 128 bytes for arm64. Current users can evolve to use a dynamic alignment in future patches. My main aim with this series is to be able to create kmalloc-64 caches on arm64. > > @@ -851,10 +860,17 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) > > flags |= SLAB_ACCOUNT; > > } > > > > - kmalloc_caches[type][idx] = create_kmalloc_cache( > > - kmalloc_info[idx].name[type], > > - kmalloc_info[idx].size, flags, 0, > > - kmalloc_info[idx].size); > > + if (minalign > ARCH_KMALLOC_MINALIGN) { > > + aligned_size = ALIGN(aligned_size, minalign); > > + aligned_idx = __kmalloc_index(aligned_size, false); > > + } > > + > > + if (!kmalloc_caches[type][aligned_idx]) > > + kmalloc_caches[type][aligned_idx] = create_kmalloc_cache( > > + kmalloc_info[aligned_idx].name[type], > > + aligned_size, flags, 0, aligned_size); > > + if (idx != aligned_idx) > > + kmalloc_caches[type][idx] = kmalloc_caches[type][aligned_idx]; > > I would prefer detecting minimum kmalloc size in create_kmalloc_caches() > in runtime instead of changing behavior of new_kmalloc_cache(). That was my initial attempt but we have a couple of create_kmalloc_cache() (not *_caches) calls directly, one of them in mm/slab.c kmem_cache_init(). So I wanted all the minalign logic in a single place, hence I replaced the explicit create_kmalloc_cache() call with new_kmalloc_cache(). See this patch and patch 9 for some clean-up. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel