From: Vincent Whitchurch <vincent.whitchurch@axis.com>
To: <catalin.marinas@arm.com>, <will@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>, <kernel@axis.com>,
Vincent Whitchurch <vincent.whitchurch@axis.com>
Subject: [PATCH] arm64: Make ARCH_DMA_MINALIGN configurable
Date: Mon, 17 May 2021 09:43:32 +0200 [thread overview]
Message-ID: <20210517074332.28280-1-vincent.whitchurch@axis.com> (raw)
ARCH_DMA_MINALIGN is hardcoded to 128, but this wastes memory if the
kernel is only intended to be run on platforms with cache line sizes of
64 bytes.
Make this configurable (hidden under CONFIG_EXPERT). Setting this to 64
bytes reduces the slab memory usage of my Cortex-A53-based system by
~6%, measured right after startup.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
arch/arm64/Kconfig | 10 ++++++++++
arch/arm64/include/asm/cache.h | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 9f1d8566bbf9..c8716aa18001 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -274,6 +274,16 @@ config ARCH_MMAP_RND_COMPAT_BITS_MIN
config ARCH_MMAP_RND_COMPAT_BITS_MAX
default 16
+config ARM64_DMA_MINALIGN
+ int "DMA alignment for slab buffers" if EXPERT
+ default 128
+ help
+ Set the number of bytes to which buffers allocated with kmalloc()
+ need to be aligned to ensure that they will be usable for DMA
+ (ARCH_DMA_MINALIGN). Lower values may save memory on platforms with
+ smaller cache line sizes, but may also make the kernel non-functional
+ on platforms with cache line sizes larger than the chosen value.
+
config NO_IOPORT_MAP
def_bool y if !PCI
diff --git a/arch/arm64/include/asm/cache.h b/arch/arm64/include/asm/cache.h
index a074459f8f2f..5fa68820ff57 100644
--- a/arch/arm64/include/asm/cache.h
+++ b/arch/arm64/include/asm/cache.h
@@ -47,7 +47,7 @@
* cache before the transfer is done, causing old data to be seen by
* the CPU.
*/
-#define ARCH_DMA_MINALIGN (128)
+#define ARCH_DMA_MINALIGN (CONFIG_ARM64_DMA_MINALIGN)
#ifdef CONFIG_KASAN_SW_TAGS
#define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT)
--
2.28.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2021-05-17 7:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 7:43 Vincent Whitchurch [this message]
2021-05-17 11:04 ` [PATCH] arm64: Make ARCH_DMA_MINALIGN configurable Catalin Marinas
2021-05-17 12:01 ` Ard Biesheuvel
2021-05-17 13:35 ` Arnd Bergmann
2021-05-17 14:20 ` Catalin Marinas
2021-05-17 14:15 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210517074332.28280-1-vincent.whitchurch@axis.com \
--to=vincent.whitchurch@axis.com \
--cc=catalin.marinas@arm.com \
--cc=kernel@axis.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox