Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20244500rwd; Wed, 28 Jun 2023 22:53:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IxyBL/4S7e0osRniSmSoqVIqTXKFl88QeFx7MhTNiKS+6xfNbqfHzI5zDz+ZjGRy96Mve X-Received: by 2002:a92:c60f:0:b0:345:a8d3:ab8c with SMTP id p15-20020a92c60f000000b00345a8d3ab8cmr10169707ilm.22.1688017993933; Wed, 28 Jun 2023 22:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688017993; cv=none; d=google.com; s=arc-20160816; b=gq9uCC5NHFP2j5npXE/KLQYLTffpSjBQVheyLyZPgYkcGmoHxIXDGN8QyYioEzU2ih nzzgQIS1u15yLL9HE+aIuJKUvB2JQk7Gg4uFqq37iaRd2afw7pdm+9hiY6pCTJZn9F98 P0TtmBj0iMsWmmwVacuyj6G6t+CJbBoatVmm893g0xnzMRMvYK00Q0OYGRgjIHKh20GI x9RV7UJZU3q9FuidtAwE16vWUirlvuEZZgigzUpysgp4VSTkJuZQujcyKSMzvbB+DYar aJKQyimTCuqWQMZ9KQWTV84F4PtEfqup5LZcE7C9vtHEQAdiRXWXtp89xjh3P9iQqGtu N7vA== 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=xborO1tvc0dRlfOjqwkAahe+gIZdli89mzQdaRUY4+k=; fh=AfFJErSeWUliuwwLJTvFA6YAkjVu0ur4KK6cz1UCFls=; b=DawP2u76dJXV9OteNrmdGVoGVg2tPIcm2C24VnOyTEEAdY5FjLNnCvfFoYRP9oYc5u 78ofE9vWdxlksgL4muesppdRs/lUwH+prFFsnBmeyct/HanvtZvpjinJOQxOcZIXUWPi Qho9Fb7eWpKl6jpls5XiFs8HY6a8fok4OaKRsfrit8QdPJZjX0XRTZyQmppnDl3/PlUe G0SCLKqGGGbeFkayaBkYSOrPGEuxkcBum55d7mJTocEHtLg1ai1Skna+Zv8X6DOezSeI +WwL0gYxnNYkLMezJL71wYVLl+Pu0PyBwgf5mSNFnlTZvWFuVXK0HgvcuvFxoYpRyAYw LapA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=zzA1cdGy; 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 y9-20020a634949000000b0053f4a814953si9807867pgk.870.2023.06.28.22.52.59; Wed, 28 Jun 2023 22:53:13 -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=zzA1cdGy; 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 S231208AbjF2FoR (ORCPT + 99 others); Thu, 29 Jun 2023 01:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjF2FoP (ORCPT ); Thu, 29 Jun 2023 01:44:15 -0400 Received: from bee.tesarici.cz (bee.tesarici.cz [77.93.223.253]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8BAF1FFA for ; Wed, 28 Jun 2023 22:44:13 -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 11B21A86A6; Thu, 29 Jun 2023 07:44:08 +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=1688017448; bh=xborO1tvc0dRlfOjqwkAahe+gIZdli89mzQdaRUY4+k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=zzA1cdGy/BGa6y89Fb2F6tVA9FyQRiR8PiFVAKF+6Bkaj9PlU8hfbCMY5lag5cQhq DThqOsVWFqdALnjYG9M7oZJddKgCHMEnyaIxF6gjTdiARYBMUqcTv6t8+dXTBgqqGd XB9hgux865KF/nk6LSqMvA2KEEOu+pscMKKmK/4OuyJfqgb1UfeU1WCp8/c88FyVB5 FDtfcQgYTh1tHTnr8B54ZbehNWHo8821acpMNQa3sik07IoAhB8UVkOFUvreLALdnE gEPATXGEaGqoWl2nK6DC43m1R4uiYbEBPEd3prk4QZw36G2DfLxq86vitOosUBS/Cq 02fxVaIIRaeXw== Date: Thu, 29 Jun 2023 07:44:03 +0200 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Christoph Hellwig Cc: Petr Tesarik , Marek Szyprowski , Robin Murphy , "open list:DMA MAPPING HELPERS" , open list , Roberto Sassu , Kefeng Wang Subject: Re: [PATCH v1 0/2] swiotlb: Fix a couple of bugs in sizing areas Message-ID: <20230629074403.7f8ed9d6@meshulam.tesarici.cz> In-Reply-To: <20230629051238.GB16654@lst.de> References: <20230626160725.5164ca74@meshulam.tesarici.cz> <20230629051238.GB16654@lst.de> 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 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 Thu, 29 Jun 2023 07:12:38 +0200 Christoph Hellwig wrote: > On Mon, Jun 26, 2023 at 04:07:25PM +0200, Petr Tesa=C5=99=C3=ADk wrote: > > As an aside (and not directly related to the bugfixes themselves), I > > wonder why the area size cannot be always equal to IO_TLB_SEGSIZE. Of > > course, we would (usually) end up with more areas, but that should be > > a good thing, shouldn't it? The area structure is quite small, so it > > cannot be because of memory consumption concerns. The overhead of > > taking an uncontended spinlock should also be negligible. =20 >=20 > What would be the benefit of this? For me, as a newcomer to this code, the existence of areas _and_ segments was confusing, especially since segments are not represented by a data structure. It took me more than one day to realize that slots are grouped into segments for allocation, but changes to the slot metadata are protected by area spinlocks. In my case, a segment crossed an area boundary, so the area spinlock protected only half of the allocated slots. I could also ask differently: What is the benefit of grouping slots into segments, and then again grouping segments into areas? Petr T