From patchwork Tue Apr 5 13:57:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 12801558 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 51131C433F5 for ; Tue, 5 Apr 2022 14:03:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8649F8D000B; Tue, 5 Apr 2022 09:58:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 813BC8D0001; Tue, 5 Apr 2022 09:58:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BFC98D000B; Tue, 5 Apr 2022 09:58:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id 5CD5A8D0001 for ; Tue, 5 Apr 2022 09:58:42 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 150D2183BCD95 for ; Tue, 5 Apr 2022 13:58:32 +0000 (UTC) X-FDA: 79322980464.19.3F52928 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf22.hostedemail.com (Postfix) with ESMTP id 082D1C0037 for ; Tue, 5 Apr 2022 13:58:30 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id B19DEB81C9B; Tue, 5 Apr 2022 13:58:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7941AC385A6; Tue, 5 Apr 2022 13:58:26 +0000 (UTC) From: Catalin Marinas To: Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/10] arm64: Enable dynamic kmalloc() minimum alignment Date: Tue, 5 Apr 2022 14:57:58 +0100 Message-Id: <20220405135758.774016-11-catalin.marinas@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220405135758.774016-1-catalin.marinas@arm.com> References: <20220405135758.774016-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: fbjapg33yunztrsdan1st97zorbtjtpm Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf22.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Rspamd-Queue-Id: 082D1C0037 X-HE-Tag: 1649167110-331454 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: Define ARCH_KMALLOC_MINALIGN as 64 since this would be the minimum requirement across most arm64 SoCs. Define arch_kmalloc_minalign() returning cache_line_size() to set the minimum run-time kmalloc() alignment for those SoCs with bigger cache lines. Signed-off-by: Catalin Marinas Cc: Will Deacon --- arch/arm64/include/asm/cache.h | 1 + arch/arm64/kernel/cacheinfo.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm64/include/asm/cache.h b/arch/arm64/include/asm/cache.h index a074459f8f2f..0bec986c9d51 100644 --- a/arch/arm64/include/asm/cache.h +++ b/arch/arm64/include/asm/cache.h @@ -48,6 +48,7 @@ * the CPU. */ #define ARCH_DMA_MINALIGN (128) +#define ARCH_KMALLOC_MINALIGN (64) #ifdef CONFIG_KASAN_SW_TAGS #define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT) diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c index 587543c6c51c..61211cd597f7 100644 --- a/arch/arm64/kernel/cacheinfo.c +++ b/arch/arm64/kernel/cacheinfo.c @@ -97,3 +97,10 @@ int populate_cache_leaves(unsigned int cpu) } return 0; } + +#ifndef CONFIG_SLOB +unsigned int arch_kmalloc_minalign(void) +{ + return cache_line_size(); +} +#endif