From mboxrd@z Thu Jan 1 00:00:00 1970 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 6FB49E81E17 for ; Fri, 6 Oct 2023 16:46:26 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zhnybkvO+IE7N29Ocl6+1y34A6tPZwfhWcV4vUDY5rY=; b=iwzBK488j5w2op dTVjIvxLHWPTYXxtisBaEQO+zpH1LUPUoTEoVuL1bhXpv4ZExQykqQWuj4fVc9Rdm1gHfs1CGUCyC EpmF+wTz/HSodvTFAqrohpaMj3DxOSttqY0OlsZsg/rgRlJlMKFjMjO8yny5SVGngqcu/4JzuHwiw oaYlhFA81e1I2tUBWNT7qbw78Fa7ZrHFKDsFh4gn8vJQXokE7q24JxC0QO8rbGonh8ZPDW7sI6pBA CEXI5JyOnCWxLtyw04aJTt9eA/vNsp/xI/FGXDHRm0HVs0O1ZoTGzXw8fSJpGcvfuWQe4KrQnm3zQ S6Cdtg4gSq25bYoLoZhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qonxi-006D9m-1u; Fri, 06 Oct 2023 16:46:02 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qonxc-006D95-3D for linux-arm-kernel@lists.infradead.org; Fri, 06 Oct 2023 16:46:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 62611B82818; Fri, 6 Oct 2023 16:45:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4641C433C9; Fri, 6 Oct 2023 16:45:53 +0000 (UTC) Date: Fri, 6 Oct 2023 17:45:51 +0100 From: Catalin Marinas To: Robin Murphy Cc: linux-arm-kernel@lists.infradead.org, Ross Burton , Will Deacon Subject: Re: [PATCH] arm64: swiotlb: Reduce the default size if no ZONE_DMA bouncing needed Message-ID: References: <20231006153252.3162299-1-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231006_094557_182563_0ED6B56D X-CRM114-Status: GOOD ( 23.26 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 06, 2023 at 05:25:03PM +0100, Robin Murphy wrote: > On 2023-10-06 16:32, Catalin Marinas wrote: > > With CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC enabled, the arm64 kernel still > > allocates the default SWIOTLB buffer (64MB) even if ZONE_DMA is disabled > > or all the RAM fits into this zone. However, this potentially wastes a > > non-negligible amount of memory on platforms with little RAM. > > > > Reduce the SWIOTLB size to 1MB per 1GB of RAM if only needed for > > kmalloc() buffer bouncing. > > > > Signed-off-by: Catalin Marinas > > Suggested-by: Ross Burton > > Cc: Ross Burton > > Cc: Robin Murphy > > Cc: Will Deacon > > --- > > arch/arm64/mm/init.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > index 8a0f8604348b..54ee1a4868c2 100644 > > --- a/arch/arm64/mm/init.c > > +++ b/arch/arm64/mm/init.c > > @@ -493,8 +493,16 @@ void __init mem_init(void) > > { > > bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit); > > - if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC)) > > + 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 = > > + ALIGN(memblock_phys_mem_size(), SZ_1G) >> 10; > > Hmm, I wondered if DIV_ROUND_UP(memblock_phys_mem_size(), 1024) might be any > easier, but by the time I've typed it out it's still just as long :) It's not the same result as it's rounded up to the nearest KB rather than MB. But this may work as well. I just made up this number really. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel