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: 12801570 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 4E815C433EF for ; Tue, 5 Apr 2022 14:08:22 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FfDMSKxpzqKyBNnhaSeYHy9+e0o+GkUQGf8G454PiL0=; b=l/D4mqkdhX7Gw5 o+ZLi7l9zcEVxyE26wfHFNyXKTJZ/iueg7RTF0ZGcO/3TkYEWbYrZJLNpsgVZjdLDMqk1YCWpkVy5 p4d0pxe+mtmaIdieVsBEJBefRKJpnssLK0/LMP5CxvBsuJg4JAMCS5RHMcFw8hOVjHITRdXH0FrZG uNXkjaC4pzvbveMhMuukgbH09lk5QCndRTYwo2xXeupEUfK95hs7/rkCZxQNfF/JU2Q63MsqnndXO F2vPJabjr0VhEVe2fJsVp9gdAtiR8nv9C9zi+oy801HmHuwRpXXjR89JYUMee2OhhLLUEDssqmcKF n3nwhAuQr4p2pThsChhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbjpl-001K92-R9; Tue, 05 Apr 2022 14:07:02 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbjhX-001G3m-82 for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2022 13:58:33 +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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220405_065831_581146_5D527012 X-CRM114-Status: GOOD ( 11.84 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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