From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6C7229113 for ; Wed, 17 May 2023 06:57:05 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 713536732A; Wed, 17 May 2023 08:56:53 +0200 (CEST) Date: Wed, 17 May 2023 08:56:53 +0200 From: Christoph Hellwig To: Petr =?utf-8?B?VGVzYcWZw61r?= Cc: Catalin Marinas , Christoph Hellwig , "Michael Kelley (LINUX)" , Petr Tesarik , Jonathan Corbet , Greg Kroah-Hartman , "Rafael J. Wysocki" , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Marek Szyprowski , Robin Murphy , "Paul E. McKenney" , Borislav Petkov , Randy Dunlap , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Andy Shevchenko , Hans de Goede , Jason Gunthorpe , Kees Cook , Thomas Gleixner , "open list:DOCUMENTATION" , open list , "open list:DRM DRIVERS" , "open list:DMA MAPPING HELPERS" , Roberto Sassu , Kefeng Wang Subject: Re: [PATCH v2 RESEND 4/7] swiotlb: Dynamically allocated bounce buffers Message-ID: <20230517065653.GA25016@lst.de> References: <346abecdb13b565820c414ecf3267275577dbbf3.1683623618.git.petr.tesarik.ext@huawei.com> <20230516061309.GA7219@lst.de> <20230516083942.0303b5fb@meshulam.tesarici.cz> <20230517083510.0cd7fa1a@meshulam.tesarici.cz> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230517083510.0cd7fa1a@meshulam.tesarici.cz> User-Agent: Mutt/1.5.17 (2007-11-01) Just thinking out loud: - what if we always way overallocate the swiotlb buffer - and then mark the second half / two thirds / slots as used, and make that region available through a special CMA mechanism as ZONE_MOVABLE (but not allowing other CMA allocations to dip into it). This allows us to have a single slot management for the entire area, but allow reclaiming from it. We'd probably also need to make this CMA variant irq safe. This could still be combined with more aggressive use of per-device swiotlb area, which is probably a good idea based on some hints. E.g. device could hint an amount of inflight DMA to the DMA layer, and if there are addressing limitations and the amout is large enough that could cause the allocation of a per-device swiotlb area.