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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19654C77B7D for ; Wed, 17 May 2023 06:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbjEQG5D (ORCPT ); Wed, 17 May 2023 02:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjEQG5C (ORCPT ); Wed, 17 May 2023 02:57:02 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A809319B3; Tue, 16 May 2023 23:57:01 -0700 (PDT) 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> 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) Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org 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.