From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [PATCH] arm64: mm: reduce swiotlb size when dynamic swiotlb enabled
Date: Wed, 8 May 2024 21:23:00 +0800 [thread overview]
Message-ID: <20240508132300.691518-1-wangkefeng.wang@huawei.com> (raw)
After commit a1e50a82256e ("arm64: Increase the swiotlb buffer size
64MB"), the swiotlb buffer size increased to 64M in case of 32-bit only
devices require many bounce buffering via swiotlb, but with the
CONFIG_SWIOTLB_DYNAMIC enabled, we could reduce swiotlb size from 64M to
4M(MAX_ORDER_NR_PAGES << PAGE_SHIFT) again since swiotlb buffer size could
be allocated danamicly, and this should save 60M for most platform which
don't require too much swiotlb buffer.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
arch/arm64/mm/init.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 9b5ab6818f7f..425222c13d97 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -370,18 +370,23 @@ void __init bootmem_init(void)
void __init mem_init(void)
{
bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit);
+ unsigned long size = 0;
if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) {
/*
* If no bouncing needed for ZONE_DMA, reduce the swiotlb
* buffer for kmalloc() bouncing to 1MB per 1GB of RAM.
*/
- unsigned long size =
- DIV_ROUND_UP(memblock_phys_mem_size(), 1024);
- swiotlb_adjust_size(min(swiotlb_size_or_default(), size));
+ size = DIV_ROUND_UP(memblock_phys_mem_size(), 1024);
swiotlb = true;
}
+ if (IS_ENABLED(CONFIG_SWIOTLB_DYNAMIC) && !size)
+ size = MAX_ORDER_NR_PAGES << PAGE_SHIFT;
+
+ if (size)
+ swiotlb_adjust_size(min(swiotlb_size_or_default(), size));
+
swiotlb_init(swiotlb, SWIOTLB_VERBOSE);
/* this will put all unused low memory onto the freelists */
--
2.27.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:[~2024-05-08 13:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-08 13:23 Kefeng Wang [this message]
2024-05-10 11:42 ` [PATCH] arm64: mm: reduce swiotlb size when dynamic swiotlb enabled Will Deacon
2024-05-11 7:45 ` Kefeng Wang
2024-05-13 4:35 ` Anshuman Khandual
2024-05-16 7:26 ` Kefeng Wang
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=20240508132300.691518-1-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=catalin.marinas@arm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).