Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp408235rwe; Fri, 14 Apr 2023 04:56:56 -0700 (PDT) X-Google-Smtp-Source: AKy350a61DevNLr3KiOcFDQ++UsSmyGwz2xv9BSd/BculnPUHCOjZevKxkPuTHusSzMUcNP4hhlz X-Received: by 2002:a05:6a00:710:b0:627:e677:bc70 with SMTP id 16-20020a056a00071000b00627e677bc70mr9746672pfl.14.1681473416225; Fri, 14 Apr 2023 04:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681473416; cv=none; d=google.com; s=arc-20160816; b=J6Z5FyAr3kla2qFw3/bG69uYlfrROB1sY4e/suMZuVL/peQsH6kPxfZBdjOjk+pCTo 9lFhA5SYt4Ek7+ah3voB5Be3txAYLf+/gqFhM9YFW20/lwzVZCJYuDMtpsl9zK2aMEt+ rUPP5yJKaSCmzO6/kJdfxsgE0N+eOUHO6ECq7u6FxnaN1Od+r33nZhT71C6SzTXt54+u BxYkb7e9DBglsf0vdUQTL0TpoF7+gacFFrYYXxqgDU7tNcLdl+DmAHsqA745L6rSpHYM Tm/bK7KjLBrs2hteqh11JeRbOkKEph0kHm5D96XmLowEv02paeBplBfrFANd2G3SMVEK f9xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1QbQZyBpCccryuJHNSvnyRV3ru9TEu3OHIeUpExBVXQ=; b=TOxILxL1FPlDtU9UPXTy5LSbOk1aXbRCKwYJlLhToqusRptlhtolYZDB2S/d/Ztio5 M7wtOnMqr2OJWeYFn0jowgcFQwW1cUiSY7IEQwG14gbjwdKTATdbN8sgzEDYjPwvYNWv GpiD4ChZszzeN/6kO+8xfpX1bf8fJS8+J+EH8+0cWRYTOHI3mFs7bdofOHu3qMeV3AbU 62ixmOyCZv2ib8uFsmC9OI2BsinFad/gLupDIZuBTrfbDKdWSjuptIcfsqiBPc6dx2Ld 5hfirQFP5yMMPzSDF9T4tvry9wTDD5rgIjD0L18yl9qX/+ItA6WdZacb6BofegRbEHyd +fKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@8bytes.org header.s=default header.b=Gt2PMMyv; 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 a63-20020a639042000000b0051b71aa53c3si1425812pge.659.2023.04.14.04.56.42; Fri, 14 Apr 2023 04:56:56 -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=@8bytes.org header.s=default header.b=Gt2PMMyv; 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 S229791AbjDNLpj (ORCPT + 99 others); Fri, 14 Apr 2023 07:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjDNLpi (ORCPT ); Fri, 14 Apr 2023 07:45:38 -0400 Received: from mail.8bytes.org (mail.8bytes.org [85.214.250.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF23B7D81 for ; Fri, 14 Apr 2023 04:45:36 -0700 (PDT) Received: from 8bytes.org (p200300c27714bc0086ad4f9d2505dd0d.dip0.t-ipconnect.de [IPv6:2003:c2:7714:bc00:86ad:4f9d:2505:dd0d]) (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 mail.8bytes.org (Postfix) with ESMTPSA id 4A29E242CE1; Fri, 14 Apr 2023 13:45:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=8bytes.org; s=default; t=1681472735; bh=Rbco+sFb8PjqXEyjlEsE2vSIHvetlKyP+am8t7R90Kk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Gt2PMMyvzwLBhIzu/JznWfYR2sYWbtDLncg5hr7L1SviqwT4MsBXniSQMBKJRL/jr if4sRAlSmlCXBe8WbtUpQfMGOxGoDDDEOu7PzI6wo75W+jw/U7VWdV0z3FDl0MrXO8 JnTlAyxx93mAdTmezsBH7PanWyE4HDr1aVLE0e5Z2hV4+jZmhSuUza83Hdk9Unfxaz uHAbB2c39xfgEZtYEzR7w0zBZmn6kf0TKUUE9xYplpnrN7Cw7NpZyy9wPg13PHi3bm LJnH7tY0vdXshZ33QNsT5EisERWbo/uT2ObYgpRorRgR1Ew7+DNTkbTsNQlxMyXVig 3HLi6ssps8RsQ== Date: Fri, 14 Apr 2023 13:45:34 +0200 From: Joerg Roedel To: Robin Murphy Cc: will@kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Linus Torvalds , Jakub Kicinski , John Garry Subject: Re: [PATCH v4] iommu: Optimise PCI SAC address trick Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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_NONE,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 Hi Robin, On Thu, Apr 13, 2023 at 02:40:25PM +0100, Robin Murphy wrote: > Per the reasoning in commit 4bf7fda4dce2 ("iommu/dma: Add config for > PCI SAC address trick") and its subsequent revert, this mechanism no > longer serves its original purpose, but now only works around broken > hardware/drivers in a way that is unfortunately too impactful to remove. > > This does not, however, prevent us from solving the performance impact > which that workaround has on large-scale systems that don't need it. > Once the 32-bit IOVA space fills up and a workload starts allocating and > freeing on both sides of the boundary, the opportunistic SAC allocation > can then end up spending significant time hunting down scattered > fragments of free 32-bit space, or just reestablishing max32_alloc_size. > This can easily be exacerbated by a change in allocation pattern, such > as by changing the network MTU, which can increase pressure on the > 32-bit space by leaving a large quantity of cached IOVAs which are now > the wrong size to be recycled, but also won't be freed since the > non-opportunistic allocations can still be satisfied from the whole > 64-bit space without triggering the reclaim path. > > However, in the context of a workaround where smaller DMA addresses > aren't simply a preference but a necessity, if we get to that point at > all then in fact it's already the endgame. The nature of the allocator > is currently such that the first IOVA we give to a device after the > 32-bit space runs out will be the highest possible address for that > device, ever. If that works, then great, we know we can optimise for > speed by always allocating from the full range. And if it doesn't, then > the worst has already happened and any brokenness is now showing, so > there's little point in continuing to try to hide it. > > To that end, implement a flag to refine the SAC business into a > per-device policy that can automatically get itself out of the way if > and when it stops being useful. Thanks for working on this, I think this is good to go. But given the issues we had with last attempt I'd like to have this in linux-next for a few weeks before sending it upstream. Therefore I will defer this patch and merge it early in the next cycle. Regards, Joerg