From patchwork Wed May 31 15:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13262479 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 06121C77B7A for ; Wed, 31 May 2023 15:49:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 971A78E0001; Wed, 31 May 2023 11:49:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FA328E0007; Wed, 31 May 2023 11:49:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C26B8E0008; Wed, 31 May 2023 11:49:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6E03B8E0007 for ; Wed, 31 May 2023 11:49:51 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2FD01140289 for ; Wed, 31 May 2023 15:49:51 +0000 (UTC) X-FDA: 80850985782.15.B2CFD0C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 7E38714001E for ; Wed, 31 May 2023 15:49:49 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf26.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=1685548189; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RYwKwBbFVhKuYYjB0bZAfV9ae8PLZlXqN8QaXAdpqek=; b=rRZm+5QhuFfQup2AaSkuZy63rqw9cX+ZUCTNJ1y5MuKU8zVAmaM3qfZrgNh8lgwHY4wSQ5 P2B5u1/UJC01jWaRhX/e8rVtCo23bX0xZpXssmgC8fzBMphTXsFuKqqBxojeYq8R2786bg TWXaqJvL9eW3itzPun72M4GtiOdEeVA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf26.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=1685548189; a=rsa-sha256; cv=none; b=11qQ6Wsbw0OXqXzcyQQ2pjLAbBF45s1nzgQch092TLGjbkt2xqcP1tPuIRh4ELoAACWYGq uE/NYdnRAS7U7u4vxzhYfVP1kkaBUeaiZxhj0avf0WMD4ZtZmZQgIS41aYPS9+Kkw1FBG5 Kc6sRFNpqfh2WSavx18/UcGgeOBLuzc= 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 9568F6380B; Wed, 31 May 2023 15:49:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4278DC433AA; Wed, 31 May 2023 15:49:44 +0000 (UTC) From: Catalin Marinas To: Linus Torvalds , Christoph Hellwig , Robin Murphy Cc: 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" , Jonathan Cameron , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 16/17] mm: slab: Reduce the kmalloc() minimum alignment if DMA bouncing possible Date: Wed, 31 May 2023 16:48:35 +0100 Message-Id: <20230531154836.1366225-17-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531154836.1366225-1-catalin.marinas@arm.com> References: <20230531154836.1366225-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7E38714001E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 53o8o3y5fbz8exgi8er9biy48q59ciyo X-HE-Tag: 1685548189-5007 X-HE-Meta: U2FsdGVkX1+vOpXgb1GIzdwKFY4xc7oVx2EzwZdPdJxbbXo6QH8c7fG4VzJT++R+bdTIgIHPtqrX18xmRBGBII025S+V2+rQBfQUxt5+4KqRVq+iihJRf6GYE6JYw85dGZzGG3jt43eKwfmDmoEPJzzaRHLUzMkD2m7LqBu+70ZiBpHoqlYjyB3aQIVQnv4fKesk6KiZQIl0KudD1IpFyZKZqeNm0Y9M5M5icnWrZY68RK5+LDscx6hR6uz+Zmh849hmC4/ebbdUqHqq+u284OGkPlCamGMo0FpxxMxuMnhdFfDyfxYGPdOkZ5QXJWort05XJ5dzkJ89J8b0Hw0uh2YMwlvRMDp42+sOzLkijiV6UikKXNQmXYaAEZywfyV6Atw32MNQ0aoKlL1Uu/HRbN8mK/XQd7a4QEulYdGINvgHZWlMr8zQiBIJAW7PL0SROCUXyKmq9Iv/RFSwod4ObSFbotmWmUQcBjarKP6vPNDOZYxgI6J4RITIf+qedxiXrAVjb8yS/bCRgFYwhEteEknmpTc0Af+7TU0A8Mks48/BxLOFGyTHMLPvQiu3TGXDxpck+LRc8ymCv5rip7d9KNfj/PqD0t/ayBulgZ2j87x4cMTjUcEV1JbFjfJ3L6BdfKvaDIEXDgLP1wcxqf71SqnQWhiBYsF2YtrVhOwWcyTyVi5s0DMJayNo5ebCPo8l2qQVV/u31Pd0P/vNPqgIgO2p+RFc2C7p6XGZU9PMI5oO6rMWnLrRj+nupSMMI6pQ7oR3PedL/uEqMKPUXTAutMGxyFWCMoHDy3WrloLdqn9ZUws0idxB9x2/XOPJkzzLu2UdGjzTBvawEAEkYNI5PZELaQeFpfR00iDppNkHYs2416TTf43prbo4ZYkAtu1U6Ef4Rx5HV08n439xLXmLBHGhei/h0eckkiUUeLoBPVG65EbnmYy2U0eI72GzlJIwWOpEAxIoCACTeTSpWs4 +ZiqWDyg LEEVgnymETCAM7VCDSlS40+Ho7m+CdeR7v10u/ZNbP7zg9+yB3GecCglOOMiSKJ/ApZM6Z8NhPV7Qjdgm6+FBwfWDbcVUS/M2/ip3hi1M8DcBNSoXZCFnvuvzs+kPbmSwtm2lzDR4RjmL9EnrUtxrNDqGMRLKcUPBkDao35c61vrmUfB8GKB0lFPuEWCnw8Hr0AJXBbpS38cz7ivmvZPwqOaNkWsP9UrvIrMxJM5MJ0BDHODr1EuK5T2sKKYL7Ac+Itmfo3ArY7ctsgzKyH8m7kFmcccBfqr12+pvKGTm4AK5DsY1Sjj/rD+M9LjB8fS+/Xte5dEHhKa2mJlyypEQopbZxC8u7ZLOLNZqSsY+tuJIRnVMFjbgmNTa/3BYJS1w1PhydhFL0nsooJwtNogW+XSJ+YbjpoNsXoUObWC/cII7+xhyjaLj/epqEm2udKs7oatjJ/jRq8UIT/SOMQYrV0PtVKtRltrJeZBAoqfDMj2rZuYSwfCWY1vrRlfrvxyIgIPgtTKZE3IGhn90VlVVNvlTtA== 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: 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 Reviewed-by: Vlastimil Babka --- mm/slab_common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/slab_common.c b/mm/slab_common.c index 7c6475847fdf..fe46459a8b77 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -863,10 +864,19 @@ void __init setup_kmalloc_cache_index_table(void) } } +#ifdef CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC +static unsigned int __kmalloc_minalign(void) +{ + 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)