Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1149762pxb; Wed, 6 Apr 2022 09:53:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtCilO1twUn19LyODAaTs4/PiFJq8h4uN7HIPLN3eZFM96x6PEarDjljxKeGtYbpYJPl09 X-Received: by 2002:a05:6a00:194c:b0:504:9ffe:7f82 with SMTP id s12-20020a056a00194c00b005049ffe7f82mr281865pfk.13.1649264006646; Wed, 06 Apr 2022 09:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649264006; cv=none; d=google.com; s=arc-20160816; b=cTfLqeQbSnCZ6v3KYEMZBrYVDdrIcytfiAC3hR4ToNdFZ1BaYEZt7O8EGcqiBh/K3g AKJPGd9aadAtlCnfu5qGe58qu2FR+2xdYdGnZw719rMvcQxYcDJl4y2FpfvnY99GqHWW jdq15BdiZq5AfSH/Qqdf1W0uSOCCA/TiJnXDlMAc48Qk4HLqhUC0zgGj5+TLCSeThYMP TbSfBEUENTKFj2jjMSgDoCzKn24ZJOwIPQ+O4DLfOPi5QO2zFfI0R/k1q3G3QI9C3aCi fyD//tH4NnLMAUmoCGyGobkYgghRdTW2rj0EDt4yDAR4vC/XfjI652Fsbl3wdNkjBAbM 4pVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=75VOFDIQUE7Y8EuvgMceZ6512gvedntzvKhBkmUAeBw=; b=hHtBLM/GakmEgWYtZSwnaX/5RGRqpG+uxOwMV7keGVdKDILfPXaY00XFOzgJgMYnNN JCsoF1SzVMiBE7douBCJK/HiYe8yPLloH8LEV/NEuTHnLEyrBKaKb946Gbm0G7Bd1G0F XCVdQqleaMwG9mzfeu7cxv5mRJXIlqFv3qcpDDdirac7jATK/ww/OEhwL34u2PeOfixo pEUX2aejqJPODIHAr1smCVBUDVoro9d6M9OLx43lbI89rIc6OGvDK8tWGS2XXuqiD/ZD WrnMXnNcp/OTb7uxcWpSRaejJ052RW4qQIOKcsXQwk/3Rm7beQGdZjDBIa6O+ysfw317 JYpg== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b13-20020a170902e94d00b00153b2d1656esi15909284pll.374.2022.04.06.09.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:53:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E5A9C2B4A50; Wed, 6 Apr 2022 09:06:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237274AbiDFQHa (ORCPT + 99 others); Wed, 6 Apr 2022 12:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237128AbiDFQGb (ORCPT ); Wed, 6 Apr 2022 12:06:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 60A6D24D985 for ; Wed, 6 Apr 2022 06:37:48 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D871F12FC; Wed, 6 Apr 2022 06:37:47 -0700 (PDT) Received: from [10.57.41.19] (unknown [10.57.41.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE9363F73B; Wed, 6 Apr 2022 06:37:45 -0700 (PDT) Message-ID: Date: Wed, 6 Apr 2022 14:37:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH RFC v2 03/11] iommu/sva: Add iommu_domain type for SVA Content-Language: en-GB To: Jason Gunthorpe Cc: "Tian, Kevin" , Lu Baolu , Joerg Roedel , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Jean-Philippe Brucker , Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" References: <20220329053800.3049561-1-baolu.lu@linux.intel.com> <20220329053800.3049561-4-baolu.lu@linux.intel.com> <20220330190201.GB2120790@nvidia.com> <20220402233210.GM2120790@nvidia.com> <20220406012334.GZ2120790@nvidia.com> <20220406130614.GC2120790@nvidia.com> From: Robin Murphy In-Reply-To: <20220406130614.GC2120790@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 2022-04-06 14:06, Jason Gunthorpe wrote: > On Wed, Apr 06, 2022 at 01:32:07PM +0100, Robin Murphy wrote: >> a particular IOMMU instance, and potentially allocate separate domains for >> separate devices to represent the same address space, much like >> vfio_iommu_type1_attach_group() does. > > I think this VFIO code also needs some more work, it currently assumes > that if the domain ops are the same then the domains are compatible, > and that is not true for ARM SMMU drivers. Well, strictly it uses the ops as a "negative" heuristic that the domains are not definitely incompatible, and only then consolidates domains if cross-attaching actually succeeds. So I don't think it's really so bad. > I've been thinking of adding a domain callback 'can device attach' and > replacing the ops compare with that instead. Previous comment notwithstanding, much as I do tend to prefer "just try the operation and see what happens" APIs, that might be more reliable in the long run than trying to encode specific "sorry, you'll need to allocate a separate domain for this device" vs. "this should have worked but something went wrong" semantics in the return value from attach. >> It's not really worth IOMMU drivers trying to support a domain spanning >> potentially-heterogeneous instances internally, since they can't reasonably >> know what matters in any particular situation. > > In the long run I think it will be worth optimizing. If the SMMU > instances can share IOPTE memory then we get two wins - memory > reduction and reduced work to read dirty bits. > > The dirty read in particular is very performance sensitive so if real > work loads have many SMMUs per VM it will become a pain point. In the ideal case though, the SVA domains are only there to logically bridge between an existing process pagetable and IOMMU instances at the API level, right? Surely if we're shadowing physical pagetables for SVA we've basically already lost the performance game? Robin.