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 2BF93C77B7A for ; Fri, 19 May 2023 11:01:14 +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=XQ+0JsdD/QHUq+joc1K1/01bvgbsrBMPvryU9VOdwJI=; b=unc03A6gA+WWti X4lwj+MZ3D5DBcZM8zv6Pi0NcRLuKErHYtLC4cn2KCDtcpgQXOjO55VRF9LK82nQSrqhpmQVfzl9e hmiXssvTYvpe3mvMHrhwQs5+txkqLI1L20Z6jLZI8R7sbDbxtkbKgrlefyXeJM65HcBD/xIl+fkB+ dBbQ/ib7okXiUYb2QQZdMPkr5V2ce8Z13t/RdiF/GsiUlLVm44BC1Js3x7Vh2zdwD2EPy+RNicxm7 b/Z6mos1dZQJ0oRR2rZdyUBUqTPxZfb3MFGKVDxALGQTX0a8Axl6LVnpji31fScSfuHJj+xuz8468 LMNoCOcse1UPwONuj1IQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pzxqr-00G2C2-1r; Fri, 19 May 2023 11:00:49 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pzxqo-00G2As-19 for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2023 11:00:47 +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 CA61265693; Fri, 19 May 2023 11:00:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5148C433EF; Fri, 19 May 2023 11:00:41 +0000 (UTC) Date: Fri, 19 May 2023 12:00:38 +0100 From: Catalin Marinas To: Linus Torvalds , Arnd Bergmann , Christoph Hellwig , Greg Kroah-Hartman Cc: Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Robin Murphy , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 14/15] mm: slab: Reduce the kmalloc() minimum alignment if DMA bouncing possible Message-ID: References: <20230518173403.1150549-1-catalin.marinas@arm.com> <20230518173403.1150549-15-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230518173403.1150549-15-catalin.marinas@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230519_040046_475979_7EB6C0B0 X-CRM114-Status: GOOD ( 26.47 ) 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, May 18, 2023 at 06:34:02PM +0100, Catalin Marinas wrote: > If an architecture opted in to DMA bouncing of unaligned kmalloc() > buffers (ARCH_WANT_KMALLOC_DMA_BOUNCE), reduce the minimum kmalloc() > cache alignment below cache-line size to ARCH_KMALLOC_MINALIGN. > > Signed-off-by: Catalin Marinas > Cc: Andrew Morton > Cc: Christoph Hellwig > Cc: Robin Murphy > --- > mm/slab_common.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 7c6475847fdf..84e5a5e435d6 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -865,7 +866,13 @@ void __init setup_kmalloc_cache_index_table(void) > > static unsigned int __kmalloc_minalign(void) > { > - return dma_get_cache_alignment(); > + int cache_align = dma_get_cache_alignment(); > + > + if (!IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) || > + io_tlb_default_mem.nslabs == 0) > + return cache_align; > + > + return ARCH_KMALLOC_MINALIGN; > } This gives a build error if the architecture doesn't select SWIOTLB (I had this done properly in v3 but for some reason I rewrote it here). The fixup is to add #ifdefs. I'll fold this in for v5: diff --git a/mm/slab_common.c b/mm/slab_common.c index 84e5a5e435d6..fe46459a8b77 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -864,16 +864,19 @@ void __init setup_kmalloc_cache_index_table(void) } } +#ifdef CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC static unsigned int __kmalloc_minalign(void) { - int cache_align = dma_get_cache_alignment(); - - if (!IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) || - io_tlb_default_mem.nslabs == 0) - return cache_align; - - return ARCH_KMALLOC_MINALIGN; + if (io_tlb_default_mem.nslabs) + return ARCH_KMALLOC_MINALIGN; + return dma_get_cache_alignment(); } +#else +static unsigned int __kmalloc_minalign(void) +{ + return dma_get_cache_alignment(); +} +#endif void __init new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel