Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp276488pxb; Thu, 7 Apr 2022 05:29:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7KzcO9ih0LTxp2g8bmNdV73N+8vOPyrzifyNDb/iImfPwa32E7KhNCTAEcT+kWgcUaqo3 X-Received: by 2002:a17:906:300f:b0:6e0:b38d:777d with SMTP id 15-20020a170906300f00b006e0b38d777dmr13208380ejz.189.1649334572856; Thu, 07 Apr 2022 05:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649334572; cv=none; d=google.com; s=arc-20160816; b=idB94x0fAMgyFMK1wGo9j/p2w5a73wUcSTRaCyVLCCmKChxiHZTU1yIbAi4YKWGL4m /00hCD5GDTSkCWe0bNbN5c0rGh8z0imnE3ycSEXh59b3tua4e1nLd4zvleZLFt4xwZYG Q1UwFc+MY0/Tr8Tzqr7bz/gQ6TEQ1PEFT0MQj3loNwFgm2ENsCNrGEbaNfqwssGxq0lf hHj11N+TfGDbhpUaIPBHaqPnROAhL8KMBeSzKRgE8VfGLIgFN/E44VsccqjLnx/lVBif QIwwLGH/gdxabuXRmIvD5+A37SIgVfyxhMDpdrnryeolY1ooL9oOqThEtEs8J8HcZiIs yg6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=j6UeoJy7dPalgMh0++7yxSLYJh2QIR2g0Djs6iIeAIk=; b=0tn3rvDDm3AaI+w2I9kHISVF50r+foy8OqRhvYxYjOcauj/VGuIwKUoVmXUyn3HmY0 mxQx6LQYgFVBaWJ294qfdvR/g03mAKdlvxoGQO5+YvrXdylOEQDuLDpr1xajYa1hW4hA /psyyOiXws4aNN8TJAr0Oc8trndhMAZvdqCpRtithVVh7Q/PGnlZsVgluq/veWzI1SD0 0BAC6oVSFncqNG2LAmPPJXy/KOZimhPs2ItMQxUIy52IyrXVxdMpbAmNa5Civta6Z+Mn rvUPi/oA70iXvDSDwUXg8m8iiKxOKIqCPNzQSiIz2btx6YsOB9hyTBbqRz7Rk3joujpR 4pww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a17090633ce00b006e820adb218si3523449eja.673.2022.04.07.05.29.04; Thu, 07 Apr 2022 05:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243829AbiDGJhM (ORCPT + 99 others); Thu, 7 Apr 2022 05:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233342AbiDGJhL (ORCPT ); Thu, 7 Apr 2022 05:37:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57CAF7939D for ; Thu, 7 Apr 2022 02:35:11 -0700 (PDT) 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 EA1C961AA9 for ; Thu, 7 Apr 2022 09:35:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56B8CC385A4; Thu, 7 Apr 2022 09:35:08 +0000 (UTC) Date: Thu, 7 Apr 2022 10:35:04 +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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 07, 2022 at 06:18:16PM +0900, Hyeonggon Yoo wrote: > On Thu, Apr 07, 2022 at 09:50:23AM +0100, Catalin Marinas wrote: > > 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. > > AFAIK there are bunch of drivers that directly calls kmalloc(). Well, lots of drivers call kmalloc() ;). > It becomes tricky when e.g.) a driver allocates just 32 bytes, > but architecture requires it to be 128-byte aligned. That's the current behaviour, a 32 byte allocation would return an object from kmalloc-128. I want to reduce this to at least kmalloc-64 (or smaller) if the CPU/SoC allows it. > That's why everything allocated from kmalloc() need to be aligned in > ARCH_DMA_MINALIGN. I don't get your conclusion here. Would you mind explaining? > So I'm yet skeptical on decoupling ARCH_DMA/KMALLOC_MINALIGN. Instead > of decoupling it, I'm more into dynamically decreasing it. The reason for decoupling is mostly that there are some static uses of ARCH_KMALLOC_MINALIGN as per point 1 above. The other is the __assume_kmalloc_alignment attribute. We shouldn't have such assumed alignment larger than what a dynamic kmalloc() would return. To me it makes a lot more sense for ARCH_KMALLOC_MINALIGN to be the minimum guaranteed in a kernel build but kmalloc() returning a larger alignment at run-time than the other way around. Thanks. -- Catalin