Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1739632rwd; Wed, 17 May 2023 00:10:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6NZYv1wtX8GjAzVSIU5byE4/HqcMd5AXg4KzSGkIXocEsdggUNhryk/YHN+C6YidKo4/Ir X-Received: by 2002:a17:90b:2289:b0:247:1233:9b28 with SMTP id kx9-20020a17090b228900b0024712339b28mr39186844pjb.17.1684307405498; Wed, 17 May 2023 00:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684307405; cv=none; d=google.com; s=arc-20160816; b=sIRT4Bf1h0+M8HyfS1J5Bqnt9MUy4lu+DT5aB4OI++zmbprhz2odFBep9jkassToeL PrDTK7Rjk+xMoPldB0MzkJAsLF1bjAniCKkLd2WlIalSfTMjiBF7EuPjMLdSSWYoQZEl pxWncKFDzp8ofNBZGVH2KZVKtSx1ZUO44maHmgIvIjR7RIt5Kax3ik7Ig/htFK1djq6p zVWBKsdZ8ffFFq0oewVKVH58lQp7P/JfcM0f3kCZT2LYBSHqJcZqWDDDgNcjNv4ZIuuL vuEMdnmZ+bUrdyzAhtsJsSBekFGdKRbJqX3868QhZ8qNTkpvGrIoL+O6MaUzkLArkkjS CFJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Arce7hsWsgXS3gfyzcaHRnVUwYMILQq/MtISdAB53RI=; b=Joen4cz/EnkeB4/Ydhb/oMQpyhYmE3O2dBnGpj3Bp9qkjHIm47RqVLLzpslJEEwEqV hE5O4m+ncB/VyVMfBDSqH9w9KVEeEBQ8e+ToTBAqHEEY8d9GLREt2gKl5XCjCvufA6hA /O6yvNf+usYsAgpH/bf8QY4Cg0Lm850uqWAQluXFywDOIVylK+yOkbTki8nAAaoqQusN 1EZJhYVXuSYeiyGfeD8YPXndrdZhreqYKznzxyfvFmrLGkSVY1kE1bSpLSU4BXirApmU +8XOCuHpN3rinNTVkHFYIK2H2yQeu7nH6+CXPV9rIjpLZy1Bcyp+xYt3aqyOfgZ/ksz6 6Aww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020a17090ad81600b002470ea7f67fsi1206830pjv.3.2023.05.17.00.09.50; Wed, 17 May 2023 00:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjEQG5E (ORCPT + 99 others); Wed, 17 May 2023 02:57:04 -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) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.