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 6D5CEC77B7A for ; Thu, 25 May 2023 14:32:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C730D6B0074; Thu, 25 May 2023 10:32:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C2260900002; Thu, 25 May 2023 10:32:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE9A26B0078; Thu, 25 May 2023 10:32:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9D6E06B0074 for ; Thu, 25 May 2023 10:32:12 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 66B8080A99 for ; Thu, 25 May 2023 14:32:12 +0000 (UTC) X-FDA: 80829017304.12.50E9B38 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 4CDF120025 for ; Thu, 25 May 2023 14:31:42 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf13.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685025103; 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; bh=az95tDbTgQIWUNB4uE8EpVTik2Ccxrx2OEaKbpLI+M4=; b=Q4lN0c7YhJ+UlaY4bqr1aB+CfJjsZlVZuK6ET6jRKV06opRCxr3vkgVIAnoIs0nAefSbrh tByd5tNg31hiGjTSnrfSPLleK/fyWCraXKuoQ8aZJBj9VRLR65yM9qY4elQgxcpfRjijKS Hm/ZPTruhRHDP5mmVT+kL/EQQtTGRzg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf13.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685025103; a=rsa-sha256; cv=none; b=xEulE5IrE134If4s8GTyDDl5p7oHCnvRCjt2kb3A/vRkthjk+CeZJywX12JBzLxsvqlIvL nI0NrAhpS+1U+bIIMdQk+mTTgUfO99lpAXau8DVxDyzK5YvCBIkAwbIN95WR1aei5MqZSR mx1f7pi/N42vCsuP6oGO6AJVonV4jxA= 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230525133138.000014b4@Huawei.com> X-Rspamd-Queue-Id: 4CDF120025 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9r1aiosqfhqzgfimtqmzso6xj5rn8xer X-HE-Tag: 1685025102-533450 X-HE-Meta: U2FsdGVkX1/WNkfvLNgAH6TDb6uNBgFsFDymWj0gwMQXttEunJnagEF2J7MZ1wMdQ5P9JBp3LQqiKY7Ywabh65as7PZlJsU6liQ/AUdbw6FJDAYlx8e9oMIgTYBnVnas93Qri8QqTz6J2daFECvnEhhpRUSI18qiuoaZ9llorNokptlS0C/cDr9WEY/xkLpGiTrnWxbIicHM+lveBRvjopxXCA98s9waJ+FbZXf6s9Wyl0RGnSnKWasFAOjl1dUkCv9z1OThZmycoFbXKT7j9AJ0B+HV01mC6OMI3kodhYk2jKqYGiKmlQLTk+LESXmYRlonlBMAW+sj+mYlDS4fPgTW5sYFzYbfkfhviLlMjD06dNTi0ZlrnFdKahqhRut1AkDTFy6ABSN7BFlpRKGsKLmlaptypqwtpLIuSmv84bBqxOu8VGyp0lBdAQoSSrhvvJVQnaBvokHap4WK/urgxhN7JfP+Fqr+za8Kn66k/nErEBtuWMUaFBIeDc1j7EnTpYIympUiyUEUhQUASB/5nPnRDAzLJ9MMF9uhxhpkKOXZZDzlDk1sy1VQP6376WdrfR1IpWBhLh5Exc5wxW+nx1Pv5X5Dzq7aYY+OoiYWDCkuQB4benpUa83EZ+krNcun+7q94y56loSoxIGWK+ivQZHshxF/Ye4sPZoBO3Uph4CFwERheXxQkM/EipccSmCZcX7N/QOWXLRXvxbCS8U/5OO2ziChexWCcuUIb4ystrI89KUqLDFaH2+M1VWllh+LrkIR6adA0l2ax5V+uWWabkQ3/wiOhI5Nbyc19NKjRbYNjA3ERh4wZMTlAX9Bj8QkPGfHVVd7fl1baxfKLDyrZAiiAAzScatURDG79e07PVBVfXUGROdvTYXJM0XmOSafq0+FW5E1BlOUnm/l/892cRRXW2mxYYugdRDczPoICyA04uVvt3wfpRhM83WrhB3yeCQZEaoDqFgI5Cd6Baj OURXXMQj thXPC1vkKWVkE7/+aFCWa/4M13dMRHAXndQU1OSjKq4tuUy6WXzOL3zRnEKb+b5FodO2+k9UN6WVUnBYpdxpg1XgqgguEZ8Tc9oWunJXY0MvQIEAFkjjHlV+TPGKKaZzmjS5Dtd3vPiEs3F7wavfTGOqfpThH7pPCVBU38tN87fSo6D9o9R6dbSmkMIWkHPO7EN2HXicaNrEqWub0CDuEip6GRFDP1hw8oOnRdOcDBd6DRk/C5oYY0On8uogKJFTlRnU2pyz/XVixYidz8ROrj4vJlbPpsDYiDreYb4UhRzNBsQb/zNq7oHNPdevm1RBOzg6lljuVbd2ZB4MzxdS+bq0ey4DkosNAbNLF9tf1tkOFZOmLt73GYJHFuYxC7aTZBnUrS3U41qlXp/xKb7o7aL3hRXo2ZebV51i99BZkZdTkq0B3AzXO+e4tJqosk94Dp4sh36oMBHISCQw/ZTmF7NpjDAL8FGC2QrAZFUHuAgDHCCWXs1uXD0gbOPhmZRezLQP0PgIF0eqgVws= 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 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