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 B218CC77B7A for ; Thu, 25 May 2023 14:32:08 +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=6w3/Fxs6fz9NmSQnwe9DR0dUlXt4OKBs5UpbWiLrJrg=; b=z9lRuriQMx/utV 704JU6hFASWQdtyagOrZWS7VHMSfXHfmb3oYfLX0GU4qbwP/xUQgyQOR0uC5XcgLv035f6uzWIaMg R68clzIzqPDJM/Uc0Bx2O7SIu4hYIAuN7e58l4JseUKyGDadENorEgXSwOm3tDEGfY4IjTaMGOZtZ lldG/xwSmoY607HwEJXRcRJaIN+bj4tgwcZS4EL+x1X3NrC7KoHmEqfzbn4kuLo6Gnk/LkOvyrhmj bG1bH2urpnrmcSAWdcYMuF88+wIOmYoyFWnQeZWe1p7f60Cpet23hysaUGUlUNhSOZlQmF0zPgPzi 2FWxV11Ey0xo8lU0ikMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2C0G-00GqST-2G; Thu, 25 May 2023 14:31:44 +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 1q2C0E-00GqS1-1M for linux-arm-kernel@lists.infradead.org; Thu, 25 May 2023 14:31:43 +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 BE645645DC; Thu, 25 May 2023 14:31:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9805DC433EF; Thu, 25 May 2023 14:31:37 +0000 (UTC) Date: Thu, 25 May 2023 15:31:34 +0100 From: Catalin Marinas To: Jonathan Cameron Cc: Linus Torvalds , Christoph Hellwig , Robin Murphy , Arnd Bergmann , Greg Kroah-Hartman , 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" , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 00/15] mm, dma, arm64: Reduce ARCH_KMALLOC_MINALIGN to 8 Message-ID: References: <20230524171904.3967031-1-catalin.marinas@arm.com> <20230525133138.000014b4@Huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230525133138.000014b4@Huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230525_073142_498303_FE7D06AC X-CRM114-Status: GOOD ( 23.08 ) 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 25, 2023 at 01:31:38PM +0100, Jonathan Cameron wrote: > On Wed, 24 May 2023 18:18:49 +0100 > Catalin Marinas wrote: > > Another version of the series reducing the kmalloc() minimum alignment > > on arm64 to 8 (from 128). Other architectures can easily opt in by > > defining ARCH_KMALLOC_MINALIGN as 8 and selecting > > DMA_BOUNCE_UNALIGNED_KMALLOC. > > > > The first 10 patches decouple ARCH_KMALLOC_MINALIGN from > > ARCH_DMA_MINALIGN and, for arm64, limit the kmalloc() caches to those > > aligned to the run-time probed cache_line_size(). On arm64 we gain the > > kmalloc-{64,192} caches. > > > > The subsequent patches (11 to 15) further reduce the kmalloc() caches to > > kmalloc-{8,16,32,96} if the default swiotlb is present by bouncing small > > buffers in the DMA API. > > I think IIO_DMA_MINALIGN needs to switch to ARCH_DMA_MINALIGN as well. > > It's used to force static alignement of buffers with larger structures, > to make them suitable for non coherent DMA, similar to your other cases. Ah, I forgot that you introduced that macro. However, at a quick grep, I don't think this forced alignment always works as intended (irrespective of this series). Let's take an example: struct ltc2496_driverdata { /* this must be the first member */ struct ltc2497core_driverdata common_ddata; struct spi_device *spi; /* * DMA (thus cache coherency maintenance) may require the * transfer buffers to live in their own cache lines. */ unsigned char rxbuf[3] __aligned(IIO_DMA_MINALIGN); unsigned char txbuf[3]; }; The rxbuf is aligned to IIO_DMA_MINALIGN, the structure and its size as well but txbuf is at an offset of 3 bytes from the aligned IIO_DMA_MINALIGN. So basically any cache maintenance on rxbuf would corrupt txbuf. You need rxbuf to be the only resident of a cache line, therefore the next member needs such alignment as well. With this series and SWIOTLB enabled, however, if you try to transfer 3 bytes, they will be bounced, so the missing alignment won't matter much. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel