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 6866EC43334 for ; Tue, 21 Jun 2022 22:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354829AbiFUWqQ (ORCPT ); Tue, 21 Jun 2022 18:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353562AbiFUWqQ (ORCPT ); Tue, 21 Jun 2022 18:46:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 12F4832073 for ; Tue, 21 Jun 2022 15:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655851573; 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=Q6EgHwfJgZlfTH4nHyXJzUb537WddlI24XuoDAWvAzUeWeNVDZxSrzfXiOTNz9kEP1iLSg 7FkqcVKGn8hs6h9zTa2nxhR48b8/OCmWZbGbDUId983u8ev3ebhVX6PKvO/VWFmUYekuz/ X/LJxUnKAePi6Wo7DSEl8zhoo6Od8Fo= Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-381-4HDxisRLNJ2x9xqtyAS3jw-1; Tue, 21 Jun 2022 18:46:06 -0400 X-MC-Unique: 4HDxisRLNJ2x9xqtyAS3jw-1 Received: by mail-il1-f197.google.com with SMTP id 3-20020a056e0220c300b002d3d7ebdfdeso10008721ilq.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=kweg1DvmMue8+8AtWMST21vj1xVzRj53IIPDXPuuOst+zbSb+/KGR5nHr7K/61Oh+f bm+im9bAphXNVDnCYquYooTELBrmhG4q0qb+2CdfbM9xfQTei7pcfdv6EjaFgPWe8A9b J8f1R/I/fsCJrOMk0c+EYkElIm2a4g+VPItqH4c4WKRXXxZooG3snEi2N29pmv0wNzBB bRbLECu35teROGxbEW76o25HRDNUDZ8qkTCm10L7MaqJBi4Z2wdyga/eF2IxgB0MCbsq rOhUXtlPYE3c6ZvPy5z5GGycj/AVWN8ciqwuoE1CjjmQmCQK6H3F3lXnn2Lz1CReXMiC wn2g== X-Gm-Message-State: AJIora/9Xf/RJp5qFmTuP0/x8fPOg/Z2iRZ9VGmH2OwcUn2ZEjHk4MCb s/yKYcoOnWUrudM+NT6v94gNB51Jl1DHm4lK8TJ7YZni1dan+75MYfuZVj8kzI8Ye17NQwGYuly +2YoMFXiernKmsx++oI58jw== X-Received: by 2002:a6b:ba43:0:b0:669:a9b2:48fb with SMTP id k64-20020a6bba43000000b00669a9b248fbmr192956iof.125.1655851566105; 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-s390@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)) {