From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3559C43334 for ; Tue, 21 Jun 2022 22:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354574AbiFUWqL (ORCPT ); Tue, 21 Jun 2022 18:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbiFUWqK (ORCPT ); Tue, 21 Jun 2022 18:46:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0848C3206F for ; Tue, 21 Jun 2022 15:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655851568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=AyRJcZIekxYC76QJjRkzyo7H6zsDdELYhefvVWlhYiyOXa9dJXi5a+8JCAhjUQQZKVbGFc Gsu3/DQCk2Db4Kpg8yawNgBSkv3LriWupYki7UIkzhb+K7SwRGwdJMG75ZYAU01beixfH2 MMllBSRbmiiWKemHxO3w6pMaknU6HiE= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-220-DofyRqwCPNO_PJ2u9sfmrA-1; Tue, 21 Jun 2022 18:46:06 -0400 X-MC-Unique: DofyRqwCPNO_PJ2u9sfmrA-1 Received: by mail-il1-f198.google.com with SMTP id w7-20020a056e021c8700b002d3bc8e95cbso10056605ill.3 for ; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=vDY8BOPazGBipeOqYJ2hjx+63rsMuUDKIlv9wNgzSLcjZPHMic1rqu8xc9B++Vp3wc 6+w5ftF/xLGw/qzA4rJfbIyJJ+uPYZHCrh5sdUBvAx2UhZ7c7g2+b/V+Af/ajqLHvuYL 0ifNHQ2pR9ZZcROnFhL00op7gWiZ5lFRWEK7PCKV/E9CghFRFte/bqrfNulUkIHMeH1R ZW3xcPrM73wghT64uoNKdlMujU4jsEK3CFm8p4BAFL5xFKtLKPBGP0gS+HAEFW2Arwla EE12ycV7QW9xz5QbwhrUBm7JY2BHMAwwyIS6xHxfhEpK6gXqWFX/TfvCLdpKH+eosYtJ b9yw== X-Gm-Message-State: AJIora9T9ih4PLVQi8rJeUIt024xpO/K2XEthEg8RLPenY5uMXXjQk6b yQ7v5t+bspACeeJOg5fB1hchZi6E3EDIfH6wd6kPLZXrqDZptKR+C1pFvtKBcOPfGV+WDnqyw8e E6sXn7LD2ASeAIpidK7HvsYs= X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192947iof.125.1655851566101; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCBBV2lQEfTtXWwkhfe9gHC1iihjOMaGFwTYEcz2D9BCipjXjT/6swp6lkrYHefJSlpm5AwA== X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192927iof.125.1655851565803; Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id m3-20020a056638224300b00339c015fd84sm2073679jas.59.2022.06.21.15.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Date: Tue, 21 Jun 2022 16:46:02 -0600 From: Alex Williamson To: Nicolin Chen Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v2 2/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency Message-ID: <20220621164602.4079bf43.alex.williamson@redhat.com> In-Reply-To: <20220616000304.23890-3-nicolinc@nvidia.com> References: <20220616000304.23890-1-nicolinc@nvidia.com> <20220616000304.23890-3-nicolinc@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On Wed, 15 Jun 2022 17:03:01 -0700 Nicolin Chen wrote: > From: Jason Gunthorpe > > The KVM mechanism for controlling wbinvd is based on OR of the coherency > property of all devices attached to a guest, no matter those devices are > attached to a single domain or multiple domains. > > So, there is no value in trying to push a device that could do enforced > cache coherency to a dedicated domain vs re-using an existing domain > which is non-coherent since KVM won't be able to take advantage of it. > This just wastes domain memory. > > Simplify this code and eliminate the test. This removes the only logic > that needed to have a dummy domain attached prior to searching for a > matching domain and simplifies the next patches. > > It's unclear whether we want to further optimize the Intel driver to > update the domain coherency after a device is detached from it, at > least not before KVM can be verified to handle such dynamics in related > emulation paths (wbinvd, vcpu load, write_cr0, ept, etc.). In reality > we don't see an usage requiring such optimization as the only device > which imposes such non-coherency is Intel GPU which even doesn't > support hotplug/hot remove. The 2nd paragraph above is quite misleading in this respect. I think it would be more accurate to explain that the benefit to using separate domains was that devices attached to domains supporting enforced cache coherency always mapped with the attributes necessary to provide that feature, therefore if a non-enforced domain was dropped, the associated group removal would re-trigger an evaluation by KVM. We can then go on to discuss that in practice the only known cases of such mixed domains included an Intel IGD device behind an IOMMU lacking snoop control, where such devices do not support hotplug, therefore this scenario lacks testing and is not considered sufficiently relevant to support. Thanks, Alex > > Signed-off-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/vfio/vfio_iommu_type1.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index c13b9290e357..f4e3b423a453 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -2285,9 +2285,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > * testing if they're on the same bus_type. > */ > list_for_each_entry(d, &iommu->domain_list, next) { > - if (d->domain->ops == domain->domain->ops && > - d->enforce_cache_coherency == > - domain->enforce_cache_coherency) { > + if (d->domain->ops == domain->domain->ops) { > iommu_detach_group(domain->domain, group->iommu_group); > if (!iommu_attach_group(d->domain, > group->iommu_group)) { From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 897EBC43334 for ; Tue, 21 Jun 2022 22:46:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0183E40C21; Tue, 21 Jun 2022 22:46:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0183E40C21 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AyRJcZIe X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qcjQNVX1MDyM; Tue, 21 Jun 2022 22:46:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 68E2C4056C; Tue, 21 Jun 2022 22:46:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 68E2C4056C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3882AC0039; Tue, 21 Jun 2022 22:46:12 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5E9D7C002D for ; Tue, 21 Jun 2022 22:46:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 347C340A38 for ; Tue, 21 Jun 2022 22:46:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 347C340A38 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hTgw-a_NtWPS for ; Tue, 21 Jun 2022 22:46:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 38D254011A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 38D254011A for ; Tue, 21 Jun 2022 22:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655851568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=AyRJcZIekxYC76QJjRkzyo7H6zsDdELYhefvVWlhYiyOXa9dJXi5a+8JCAhjUQQZKVbGFc Gsu3/DQCk2Db4Kpg8yawNgBSkv3LriWupYki7UIkzhb+K7SwRGwdJMG75ZYAU01beixfH2 MMllBSRbmiiWKemHxO3w6pMaknU6HiE= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-LgByjRwuNcO01RUjOwuUSg-1; Tue, 21 Jun 2022 18:46:06 -0400 X-MC-Unique: LgByjRwuNcO01RUjOwuUSg-1 Received: by mail-io1-f70.google.com with SMTP id x13-20020a0566022c4d00b0065491fa5614so8297295iov.9 for ; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=78IPwrrNT3AwXze+Fp0mOYDa0nBODw7bAFlr9J6u0vKWEEHoSFd9CwZPQ6vv0ZnAYa I8JsvfBRCl7NC/rbKrG4XeVgqIOvaG96lG4+mIuZx/qnK43tOKBeH85zvlMyViX8xDxw q1MXLCQL+9PRvBKDjJCiNYuaqfIBJMXm/4B9mR/bS+cSl38YUAit6y7BHEkAn6hOlTTN j2W9U3Wn79HdBb7kf8CMu68tU+YhuMHBXLwrYEL22IbirHM2eCKVuGPOdGc7MW91uuqL t6mhGuCjpgrOcMD9jG8eQyXz9jfJU3oD8Za8VIYAzuZE8Hk2PQhWgZ8WoyFa5tzvU7H/ U3xQ== X-Gm-Message-State: AJIora9ClfuGCKALXOzG5mZpoid5SJfpGfomEr3v0pf/lYefqiW8sicG KNyKFD3QQxUkxLirsDNT6zqk4VsyZ6kYB8OWvfq/la8y/CvfltFKL9MDitohnYbDD9AQN9LNE1S 44WV6eDamEt1LbsaJc6iNsPbR1yU3Ew== X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192957iof.125.1655851566099; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCBBV2lQEfTtXWwkhfe9gHC1iihjOMaGFwTYEcz2D9BCipjXjT/6swp6lkrYHefJSlpm5AwA== X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192927iof.125.1655851565803; Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id m3-20020a056638224300b00339c015fd84sm2073679jas.59.2022.06.21.15.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Date: Tue, 21 Jun 2022 16:46:02 -0600 From: Alex Williamson To: Nicolin Chen Subject: Re: [PATCH v2 2/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency Message-ID: <20220621164602.4079bf43.alex.williamson@redhat.com> In-Reply-To: <20220616000304.23890-3-nicolinc@nvidia.com> References: <20220616000304.23890-1-nicolinc@nvidia.com> <20220616000304.23890-3-nicolinc@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=alex.williamson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: linux-s390@vger.kernel.org, cohuck@redhat.com, jordan@cosmicpenguin.net, linux-tegra@vger.kernel.org, thierry.reding@gmail.com, will@kernel.org, alyssa@rosenzweig.io, jean-philippe@linaro.org, saiprakash.ranjan@codeaurora.org, kvm@vger.kernel.org, zhang.lyra@gmail.com, iommu@lists.linux-foundation.org, jonathanh@nvidia.com, linux-arm-kernel@lists.infradead.org, jgg@nvidia.com, yangyingliang@huawei.com, orsonzhai@gmail.com, gerald.schaefer@linux.ibm.com, kevin.tian@intel.com, linux-arm-msm@vger.kernel.org, christophe.jaillet@wanadoo.fr, matthias.bgg@gmail.com, tglx@linutronix.de, virtualization@lists.linux-foundation.org, isaacm@codeaurora.org, dwmw2@infradead.org, marcan@marcan.st, linux-kernel@vger.kernel.org, baolin.wang7@gmail.com, linux-mediatek@lists.infradead.org, robin.murphy@arm.com X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Wed, 15 Jun 2022 17:03:01 -0700 Nicolin Chen wrote: > From: Jason Gunthorpe > > The KVM mechanism for controlling wbinvd is based on OR of the coherency > property of all devices attached to a guest, no matter those devices are > attached to a single domain or multiple domains. > > So, there is no value in trying to push a device that could do enforced > cache coherency to a dedicated domain vs re-using an existing domain > which is non-coherent since KVM won't be able to take advantage of it. > This just wastes domain memory. > > Simplify this code and eliminate the test. This removes the only logic > that needed to have a dummy domain attached prior to searching for a > matching domain and simplifies the next patches. > > It's unclear whether we want to further optimize the Intel driver to > update the domain coherency after a device is detached from it, at > least not before KVM can be verified to handle such dynamics in related > emulation paths (wbinvd, vcpu load, write_cr0, ept, etc.). In reality > we don't see an usage requiring such optimization as the only device > which imposes such non-coherency is Intel GPU which even doesn't > support hotplug/hot remove. The 2nd paragraph above is quite misleading in this respect. I think it would be more accurate to explain that the benefit to using separate domains was that devices attached to domains supporting enforced cache coherency always mapped with the attributes necessary to provide that feature, therefore if a non-enforced domain was dropped, the associated group removal would re-trigger an evaluation by KVM. We can then go on to discuss that in practice the only known cases of such mixed domains included an Intel IGD device behind an IOMMU lacking snoop control, where such devices do not support hotplug, therefore this scenario lacks testing and is not considered sufficiently relevant to support. Thanks, Alex > > Signed-off-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/vfio/vfio_iommu_type1.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index c13b9290e357..f4e3b423a453 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -2285,9 +2285,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > * testing if they're on the same bus_type. > */ > list_for_each_entry(d, &iommu->domain_list, next) { > - if (d->domain->ops == domain->domain->ops && > - d->enforce_cache_coherency == > - domain->enforce_cache_coherency) { > + if (d->domain->ops == domain->domain->ops) { > iommu_detach_group(domain->domain, group->iommu_group); > if (!iommu_attach_group(d->domain, > group->iommu_group)) { _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2628CCA47E for ; Tue, 21 Jun 2022 22:46:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4EEBC610CA; Tue, 21 Jun 2022 22:46:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4EEBC610CA Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AyRJcZIe X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DDkjPASKDcun; Tue, 21 Jun 2022 22:46:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id B2FB3610E7; Tue, 21 Jun 2022 22:46:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B2FB3610E7 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8D884C0039; Tue, 21 Jun 2022 22:46:13 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7CEBCC002D for ; Tue, 21 Jun 2022 22:46:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 49E454011A for ; Tue, 21 Jun 2022 22:46:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 49E454011A Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AyRJcZIe X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rSnWhP1LzR67 for ; Tue, 21 Jun 2022 22:46:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 38D534056C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 38D534056C for ; Tue, 21 Jun 2022 22:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655851568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=AyRJcZIekxYC76QJjRkzyo7H6zsDdELYhefvVWlhYiyOXa9dJXi5a+8JCAhjUQQZKVbGFc Gsu3/DQCk2Db4Kpg8yawNgBSkv3LriWupYki7UIkzhb+K7SwRGwdJMG75ZYAU01beixfH2 MMllBSRbmiiWKemHxO3w6pMaknU6HiE= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-xiATe0QWPiqij4GE9TeR8A-1; Tue, 21 Jun 2022 18:46:06 -0400 X-MC-Unique: xiATe0QWPiqij4GE9TeR8A-1 Received: by mail-io1-f71.google.com with SMTP id q13-20020a5d9f0d000000b00669c03397f7so8279055iot.10 for ; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=W9GE6TWABkRx4oO1gL2wpR2GevbzzkAJVsFyW8z/JtK6q7sIV+YGOSAxJ0iGv+Ujm2 Cf3ZvRZ2DoJGH8Km1WsBX0e4fhwzSM7o5UC13anDybIol7k4EFmvfd+dcpkW4J+7ZH9v uaIdxYeyI7xsg1xQXVgrgp9SSvoyQOQSPr3nZ8v/X0mLY/pXV+3w2A6b7/gNHTzv77Ij Vx0XtzgyV5LTJbw3C6VHNw68Fl7l29dGUTHzl6zzdu/ilTk+0tgB6Y77PNQTMkDlnx3E W2C03jpFn/tXtxz4oUmP+MK25nH0oxE/ppis8FsEnPEzQ2Yab2x4KJZnpijO4iUd09ca /Y9g== X-Gm-Message-State: AJIora8lXW1W3U1ezrRTKfWuE+lI0kbi40zVHS3zAhjKpx4RcrQvaob5 WBh7/Fv/J4Xx+Ma+E68C5TE9qfgjq7JxvUg/BgDmIY3nd3QqVOuwlfZ++vYVrj6xAim8vF6ANGd 1IeqmcdtG6oTmYuNlM634Fn7lQLdhi4Iz1xFOOpb5hQ== X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192965iof.125.1655851566102; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCBBV2lQEfTtXWwkhfe9gHC1iihjOMaGFwTYEcz2D9BCipjXjT/6swp6lkrYHefJSlpm5AwA== X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192927iof.125.1655851565803; Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id m3-20020a056638224300b00339c015fd84sm2073679jas.59.2022.06.21.15.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Date: Tue, 21 Jun 2022 16:46:02 -0600 From: Alex Williamson To: Nicolin Chen Subject: Re: [PATCH v2 2/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency Message-ID: <20220621164602.4079bf43.alex.williamson@redhat.com> In-Reply-To: <20220616000304.23890-3-nicolinc@nvidia.com> References: <20220616000304.23890-1-nicolinc@nvidia.com> <20220616000304.23890-3-nicolinc@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=alex.williamson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: linux-s390@vger.kernel.org, cohuck@redhat.com, mjrosato@linux.ibm.com, jordan@cosmicpenguin.net, linux-tegra@vger.kernel.org, thierry.reding@gmail.com, will@kernel.org, alyssa@rosenzweig.io, jean-philippe@linaro.org, saiprakash.ranjan@codeaurora.org, kvm@vger.kernel.org, zhang.lyra@gmail.com, joro@8bytes.org, iommu@lists.linux-foundation.org, jonathanh@nvidia.com, linux-arm-kernel@lists.infradead.org, jgg@nvidia.com, yangyingliang@huawei.com, orsonzhai@gmail.com, gerald.schaefer@linux.ibm.com, sven@svenpeter.dev, linux-arm-msm@vger.kernel.org, john.garry@huawei.com, vdumpa@nvidia.com, christophe.jaillet@wanadoo.fr, thunder.leizhen@huawei.com, matthias.bgg@gmail.com, tglx@linutronix.de, virtualization@lists.linux-foundation.org, yong.wu@mediatek.com, isaacm@codeaurora.org, chenxiang66@hisilicon.com, dwmw2@infradead.org, marcan@marcan.st, linux-kernel@vger.kernel.org, robdclark@gmail.com, suravee.suthikulpanit@amd.com, baolin.wang7@gmail.com, linux-mediatek@lists.infradead.org, robin.murphy@arm.com, baolu.lu@linux.intel.com X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Wed, 15 Jun 2022 17:03:01 -0700 Nicolin Chen wrote: > From: Jason Gunthorpe > > The KVM mechanism for controlling wbinvd is based on OR of the coherency > property of all devices attached to a guest, no matter those devices are > attached to a single domain or multiple domains. > > So, there is no value in trying to push a device that could do enforced > cache coherency to a dedicated domain vs re-using an existing domain > which is non-coherent since KVM won't be able to take advantage of it. > This just wastes domain memory. > > Simplify this code and eliminate the test. This removes the only logic > that needed to have a dummy domain attached prior to searching for a > matching domain and simplifies the next patches. > > It's unclear whether we want to further optimize the Intel driver to > update the domain coherency after a device is detached from it, at > least not before KVM can be verified to handle such dynamics in related > emulation paths (wbinvd, vcpu load, write_cr0, ept, etc.). In reality > we don't see an usage requiring such optimization as the only device > which imposes such non-coherency is Intel GPU which even doesn't > support hotplug/hot remove. The 2nd paragraph above is quite misleading in this respect. I think it would be more accurate to explain that the benefit to using separate domains was that devices attached to domains supporting enforced cache coherency always mapped with the attributes necessary to provide that feature, therefore if a non-enforced domain was dropped, the associated group removal would re-trigger an evaluation by KVM. We can then go on to discuss that in practice the only known cases of such mixed domains included an Intel IGD device behind an IOMMU lacking snoop control, where such devices do not support hotplug, therefore this scenario lacks testing and is not considered sufficiently relevant to support. Thanks, Alex > > Signed-off-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/vfio/vfio_iommu_type1.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index c13b9290e357..f4e3b423a453 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -2285,9 +2285,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > * testing if they're on the same bus_type. > */ > list_for_each_entry(d, &iommu->domain_list, next) { > - if (d->domain->ops == domain->domain->ops && > - d->enforce_cache_coherency == > - domain->enforce_cache_coherency) { > + if (d->domain->ops == domain->domain->ops) { > iommu_detach_group(domain->domain, group->iommu_group); > if (!iommu_attach_group(d->domain, > group->iommu_group)) { _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 993C2C43334 for ; Tue, 21 Jun 2022 22:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nWuDYdXgqv3iXmRmhq1kGhaflaVVlWO9SEMBS7h4lgw=; b=QkYBmRJstcN7SR 7KZwC1N3mzf1srX7NLm7Zv/DJCN0AhfQntv8FfD3vrSTChkb3yMwV+1/KdNQtIAU/iFPj3Fc3mTrK ggcmK1X8bakC9XmzP8RVpV654+fuCJ83CBUJXekuxG2Ah4TlAea/tEM2oWbJ/MAvn3BVXnagrq+e3 G1GVrUHc1LH0TcQZhDoJrODJhSPfpi1KHaVuuHW0+y/la+XZme2dE0wGqahgPEGfk8nF2FiZnzMmu JZl+L6cC+2XILhGjJy52DUCf/2n3OFophJVN6zUQSP4+gshNcQdrFcVWvZglIZiw2q1BJnuDzWm0n oy4CM3Uicq/A5xN5Dfaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3mdV-007XGr-FE; Tue, 21 Jun 2022 22:46:17 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3mdR-007XF8-F6 for linux-arm-kernel@lists.infradead.org; Tue, 21 Jun 2022 22:46:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655851567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=Xig8AL7bKmoYrVt3KaOD6ZubfTjvJ95Z/iKKaeu4FmsD6e4BRA0kk5O6toWz43616jEavp 31pZ6D4Czl9IS0ucpR8VD7XG2jarpF94jm6yftW88mjROVNgZs8jKwdA+dYZhWQRvtMgDz MxgTgFzZdt1QuRURiLBcmwfgs0p1puA= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-uwhQKKYqNdCujPApFMrGPg-1; Tue, 21 Jun 2022 18:46:06 -0400 X-MC-Unique: uwhQKKYqNdCujPApFMrGPg-1 Received: by mail-io1-f70.google.com with SMTP id r76-20020a6b2b4f000000b00669b75529e5so8268466ior.16 for ; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=f/+1/Xy/oMl85EwlznQPMBlg4SJKLxQKry9nxTTQZbw=; b=NM7TYuHcwSD1DJAIC+XY/ACaVoO3KdfAyTi2UsJwa6FDX/1ZCLh7MxCIFLwD4Oy79i M2+oRSRLSM7k9UXvkUJYUiy9wX1XHl8ZRzDwloVvWHQteim8wgcoPwVlsZI6ezk9VteT PzyDlumL/XfEh2ZqrIH/2lUsRpGTUMMflP7kqJofJhMoI7C++d00gOTv/oKhAsJ3wT8k vTs4kASjd2UXXnQ98XaQyKHX8dpgfnKBBDGGUmy6e6EBG8pQgoqBcWB7A73dnWF13ls1 zdSRme/tJ48jwj9qMPwQwMh7S3HawLUyx8PXsbIMF2Ig+QabbZzXPSvEe0NXmQcM13oU +vOg== X-Gm-Message-State: AJIora/5GfWLaSVReoe9EWSpHlOhuuy1jaQLv3i7Jui89GEWldfvyWax IU0FQA7Jzm9gjfUMva4Tr1j3SbiDu+FypJXZy7Hv3t0ECawDaThK4EWucLHsimsecAsK+MnuCi4 dJq+FFvfPrTFfOXhRsQp/P+NH6/nPjh8qD1U= X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192978iof.125.1655851566144; Tue, 21 Jun 2022 15:46:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCBBV2lQEfTtXWwkhfe9gHC1iihjOMaGFwTYEcz2D9BCipjXjT/6swp6lkrYHefJSlpm5AwA== X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192927iof.125.1655851565803; Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id m3-20020a056638224300b00339c015fd84sm2073679jas.59.2022.06.21.15.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 15:46:05 -0700 (PDT) Date: Tue, 21 Jun 2022 16:46:02 -0600 From: Alex Williamson To: Nicolin Chen Subject: Re: [PATCH v2 2/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency Message-ID: <20220621164602.4079bf43.alex.williamson@redhat.com> In-Reply-To: <20220616000304.23890-3-nicolinc@nvidia.com> References: <20220616000304.23890-1-nicolinc@nvidia.com> <20220616000304.23890-3-nicolinc@nvidia.com> Organization: Red Hat MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=alex.williamson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220621_154613_718505_A8DA6DF5 X-CRM114-Status: GOOD ( 29.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, cohuck@redhat.com, mjrosato@linux.ibm.com, jordan@cosmicpenguin.net, linux-tegra@vger.kernel.org, thierry.reding@gmail.com, will@kernel.org, alyssa@rosenzweig.io, jean-philippe@linaro.org, saiprakash.ranjan@codeaurora.org, kvm@vger.kernel.org, zhang.lyra@gmail.com, joro@8bytes.org, iommu@lists.linux-foundation.org, jonathanh@nvidia.com, linux-arm-kernel@lists.infradead.org, jgg@nvidia.com, yangyingliang@huawei.com, orsonzhai@gmail.com, gerald.schaefer@linux.ibm.com, kevin.tian@intel.com, sven@svenpeter.dev, linux-arm-msm@vger.kernel.org, john.garry@huawei.com, christophe.jaillet@wanadoo.fr, thunder.leizhen@huawei.com, matthias.bgg@gmail.com, tglx@linutronix.de, virtualization@lists.linux-foundation.org, yong.wu@mediatek.com, isaacm@codeaurora.org, chenxiang66@hisilicon.com, dwmw2@infradead.org, marcan@marcan.st, linux-kernel@vger.kernel.org, robdclark@gmail.com, suravee.suthikulpanit@amd.com, baolin.wang7@gmail.com, linux-mediatek@lists.infradead.org, robin.murphy@arm.com, baolu.lu@linux.intel.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 15 Jun 2022 17:03:01 -0700 Nicolin Chen wrote: > From: Jason Gunthorpe > > The KVM mechanism for controlling wbinvd is based on OR of the coherency > property of all devices attached to a guest, no matter those devices are > attached to a single domain or multiple domains. > > So, there is no value in trying to push a device that could do enforced > cache coherency to a dedicated domain vs re-using an existing domain > which is non-coherent since KVM won't be able to take advantage of it. > This just wastes domain memory. > > Simplify this code and eliminate the test. This removes the only logic > that needed to have a dummy domain attached prior to searching for a > matching domain and simplifies the next patches. > > It's unclear whether we want to further optimize the Intel driver to > update the domain coherency after a device is detached from it, at > least not before KVM can be verified to handle such dynamics in related > emulation paths (wbinvd, vcpu load, write_cr0, ept, etc.). In reality > we don't see an usage requiring such optimization as the only device > which imposes such non-coherency is Intel GPU which even doesn't > support hotplug/hot remove. The 2nd paragraph above is quite misleading in this respect. I think it would be more accurate to explain that the benefit to using separate domains was that devices attached to domains supporting enforced cache coherency always mapped with the attributes necessary to provide that feature, therefore if a non-enforced domain was dropped, the associated group removal would re-trigger an evaluation by KVM. We can then go on to discuss that in practice the only known cases of such mixed domains included an Intel IGD device behind an IOMMU lacking snoop control, where such devices do not support hotplug, therefore this scenario lacks testing and is not considered sufficiently relevant to support. Thanks, Alex > > Signed-off-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/vfio/vfio_iommu_type1.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index c13b9290e357..f4e3b423a453 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -2285,9 +2285,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > * testing if they're on the same bus_type. > */ > list_for_each_entry(d, &iommu->domain_list, next) { > - if (d->domain->ops == domain->domain->ops && > - d->enforce_cache_coherency == > - domain->enforce_cache_coherency) { > + if (d->domain->ops == domain->domain->ops) { > iommu_detach_group(domain->domain, group->iommu_group); > if (!iommu_attach_group(d->domain, > group->iommu_group)) { _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel