Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2011692rwd; Wed, 17 May 2023 04:43:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+Um+ahblDQi0L/7JcsYJAtIzm82otfY71jec5PqJcJe6Qrssj+4qNuSrPB1RB7JrnBlI4 X-Received: by 2002:a17:90a:d18d:b0:23a:ad68:25a7 with SMTP id fu13-20020a17090ad18d00b0023aad6825a7mr40798071pjb.2.1684323819635; Wed, 17 May 2023 04:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684323819; cv=none; d=google.com; s=arc-20160816; b=agJUBBC0QNkjeHUsZCs5Z3HR4vFt52WjkhceQoc8FIT8ujzs4rcvi9RyLZot3AxCfY 8ikUVn8tV7XUDMTdm3IZehspDSln7LE+GzaAHEE5mo8fvqDVkMLgBLYHdcGeovmziGQ8 wdxrk0m5LDW3ZSexGSm4l8eWuet9jeKPWr7qwqn5ukQvS18ka7ji8Yrna8yxMspmdPIi qX1PwBERR7enw7o/k1/WJIRJ3QGW4/PnibhEBNOzVWsCDmxO5sAkf/cDIQPppBwzHs6X ntVFP4z/y5veb2f1K9xj4hBOC9sJjDt1AfiIE/xKEp5DPyRDHOFwNIho7bllzcN1AOva QcFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=iAhSxGfe0maADmCWvSD0fNulJwuFazSi9OhOrRyLC70=; b=Qnlfoi5LxyfhO51Y/RyNXM5YDU9mZR2r/xJP4phq01Mu3ek05Osn+A7b0ToEZheq2B w4DATReWwzo69VWkSoiv4NUl/X2HOdZQlxz8M4i5hRIdt//cfa3B6XusdOzHVj/1BMvE 1dzJvoEgMUNLUnvx4+XCzmfBZeWAjQn0WFwmWIbqBpHbRoCHA9pjWxzbnEn6IyBqZ3DT 1px5fD6+zFHkgq1ZwPbBJ5KeReUBC5URv57b7W9qmefekWx8aEpO8fLWQTuHQe8b7+GY Y8HAbI4kQpJVuDly+n6sFzq3USVSC0qNaIp89gg/v7GDF/SCoT08ZbUq8v7DyYItvJL+ /H6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=al7Qx7SK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a170902e88100b0019ea8e6213esi1302734plg.102.2023.05.17.04.43.25; Wed, 17 May 2023 04:43:39 -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; dkim=pass header.i=@tesarici.cz header.s=mail header.b=al7Qx7SK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tesarici.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbjEQL16 (ORCPT + 99 others); Wed, 17 May 2023 07:27:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbjEQL14 (ORCPT ); Wed, 17 May 2023 07:27:56 -0400 Received: from bee.tesarici.cz (bee.tesarici.cz [IPv6:2a03:3b40:fe:2d4::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0B52D5D; Wed, 17 May 2023 04:27:54 -0700 (PDT) Received: from meshulam.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-4427-cc85-6706-c595.ipv6.o2.cz [IPv6:2a00:1028:83b8:1e7a:4427:cc85:6706:c595]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id 6892E164C27; Wed, 17 May 2023 13:27:50 +0200 (CEST) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=none dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tesarici.cz; s=mail; t=1684322870; bh=iAhSxGfe0maADmCWvSD0fNulJwuFazSi9OhOrRyLC70=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=al7Qx7SKAg8fypBvu192OYqvg3980UMzo23P4WbZZN5EH2Yw4wRAap8mWWUALVxFp Ld9iruYxHjHhoyaIPKx2HUg0dydQbdVS12ZL0jyYUGr3tDFcv5/z65sQdd1U2JFjgI e7/qI6Ork7Npu45/P4aVMlRF9pptXCj3La2E3EyRurgA7axUGz5d9oXSshFFXkebKu Pj5grUALyE+UOygXAj/VRLvXCG/vWfmQHU8QKCjZKf6Uyl2/QAa838OQ2wjNr+YakU +DzAURBbFZBr3jMSoA8l8hBZ/QWhg1MEmBBiQcb38sRUvMVQb3y6cfnFw6MpWhSMvJ j3jzPImJmhVjA== Date: Wed, 17 May 2023 13:27:48 +0200 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Catalin Marinas Cc: 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: <20230517132748.2e250f9c@meshulam.tesarici.cz> In-Reply-To: <20230517083510.0cd7fa1a@meshulam.tesarici.cz> References: <346abecdb13b565820c414ecf3267275577dbbf3.1683623618.git.petr.tesarik.ext@huawei.com> <20230516061309.GA7219@lst.de> <20230516083942.0303b5fb@meshulam.tesarici.cz> <20230517083510.0cd7fa1a@meshulam.tesarici.cz> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Wed, 17 May 2023 08:35:10 +0200 Petr Tesa=C5=99=C3=ADk wrote: >[...] > Anyway, my greatest objection to allocating additional swiotlb chunks is > that _all_ of them must be searched to determine that the physical > address does _not_ belong to a swiotlb, incurring performance penalty I thought about this part again, and I overlooked one option. We can track only the _active_ swiotlbs for each device. If a device never needs a swiotlb, there is no active swiotlb, and is_swiotlb_buffer() short-circuits to false. This should avoid all collateral damage to innocent devices. We would also maintain a (global) list of all allocated swiotlbs, used by swiotlb_map() to find free slots and add the respective swiotlb to the per-device active list. One potential advantage is that we could use mapping size and alignment to choose a swiotlb cleverly and minimize internal fragmentation... OK, I'm dreaming. Let's agree on the general approach first. Petr T