Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp365406pxb; Fri, 15 Jan 2021 15:33:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqT0HPBP16BDJL4ePYuet9HVFRVzzC9BMoS80ktOb4kaO6BJZTza/6UL0XaWwNuNP7vijM X-Received: by 2002:a17:906:780c:: with SMTP id u12mr10433547ejm.125.1610753608819; Fri, 15 Jan 2021 15:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610753608; cv=none; d=google.com; s=arc-20160816; b=OWMq10V4r2iFFS8ZuvxQQH71YNDbM9wj5rKheSlcrTwCr0inTjKWvs36vukAp9p+m5 duzlBRc+RhQZ74L6lz4YNE+HYbwKlmYfqGmBRHnSu/PSUzJO8XY5MqruYVKkOCs/GCHZ FrGcaJn1rSadrGdOt77nNJB8Bg+erGb+mtsORiH5ilP4fFnJ97P5yyKxT51jV7YMNW35 3oSvfF1b758TtDR8YT1AlO2YNXWnTdZi4mDr5t7TkitGUkiK+FpkfrQWqxfayJJhCGrr Yk+pWPIXi6EBwkYuKC3qBIpA8/b93QoFXgI6/BdzPGYCSMsi3wHc2+Uvk6jc5/ottBau qXCA== 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=ZcqGdAWvT6/fidF7kC53r5O0Fwn58WR7GKMoHqohBAc=; b=BOhIYPDR9UcZg73kls95xF2HqD4F+52W0eajM84aue7p02Zz9dP3biWxXHBHm6zRO9 b+9OCnFL+Iftd3HelYm/xXeHTQ1/FHkXNVUM1pBNwjIuDhNFcxak67Dk1F4DLIxOVyqK rc3KYAPRTjnG4lj//3nV/ag+hdZ4Mfsn9yNMrN7cHZSwUGkrtOrrZWcwXXrDjYfxsG+L LLDteN9Xfl5vChIpCroYRZG2FIaZ+ab054xNiexSMIwnBlWDN84P8vIlP8GeCfkrnug8 7CJpQ08/0ehTXk1YRvtMhw2QMM0sZzI2jFzQNacXUNOnUJ0bJOarDZ1cziIsxv5NXHmW s68Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PqNGSO1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si4414051ejb.632.2021.01.15.15.33.05; Fri, 15 Jan 2021 15:33:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PqNGSO1a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbhAOXcR (ORCPT + 99 others); Fri, 15 Jan 2021 18:32:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22856 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbhAOXcQ (ORCPT ); Fri, 15 Jan 2021 18:32:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610753450; 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=ZcqGdAWvT6/fidF7kC53r5O0Fwn58WR7GKMoHqohBAc=; b=PqNGSO1apcingLTq1MDr1/754xN/XwuYsVDohHh62tmO7QPDJhEYeeUfDc9uCwAPukpB7U bErHXuegRujGaNNLYobdjnKJpIiBmfqiA7HU1JR3n4oNgNQ0mmkJo9oLwL1B0dxNp7Xq6J 1ZRCZJJWR++T4+7JKKjkdcpG75mKEgI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-MbQGIl4pMwCRKRrqXq0k5Q-1; Fri, 15 Jan 2021 18:30:46 -0500 X-MC-Unique: MbQGIl4pMwCRKRrqXq0k5Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 290C2180A092; Fri, 15 Jan 2021 23:30:43 +0000 (UTC) Received: from omen.home.shazbot.org (ovpn-112-255.phx2.redhat.com [10.3.112.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E3D66F7EF; Fri, 15 Jan 2021 23:30:41 +0000 (UTC) Date: Fri, 15 Jan 2021 16:30:41 -0700 From: Alex Williamson To: Keqian Zhu Cc: , , , , , Cornelia Huck , Will Deacon , "Marc Zyngier" , Catalin Marinas , Mark Rutland , James Morse , Robin Murphy , Joerg Roedel , "Daniel Lezcano" , Thomas Gleixner , Suzuki K Poulose , Julien Thierry , Andrew Morton , Alexios Zavras , , Subject: Re: [PATCH 3/6] vfio/iommu_type1: Initially set the pinned_page_dirty_scope Message-ID: <20210115163041.704a4e9d@omen.home.shazbot.org> In-Reply-To: <20210107044401.19828-4-zhukeqian1@huawei.com> References: <20210107044401.19828-1-zhukeqian1@huawei.com> <20210107044401.19828-4-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Jan 2021 12:43:58 +0800 Keqian Zhu wrote: > For now there are 3 ways to promote the pinned_page_dirty_scope > status of vfio_iommu: > > 1. Through vfio pin interface. > 2. Detach a group without pinned_dirty_scope. > 3. Attach a group with pinned_dirty_scope. > > For point 3, the only chance to promote the pinned_page_dirty_scope > status is when vfio_iommu is newly created. As we can safely set > empty vfio_iommu to be at pinned status, then the point 3 can be > removed to reduce operations. > > Signed-off-by: Keqian Zhu > --- > 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 110ada24ee91..b596c482487b 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -2045,11 +2045,8 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > * Non-iommu backed group cannot dirty memory directly, > * it can only use interfaces that provide dirty > * tracking. > - * The iommu scope can only be promoted with the > - * addition of a dirty tracking group. > */ > group->pinned_page_dirty_scope = true; > - promote_pinned_page_dirty_scope(iommu); > mutex_unlock(&iommu->lock); > > return 0; > @@ -2436,6 +2433,7 @@ static void *vfio_iommu_type1_open(unsigned long arg) > INIT_LIST_HEAD(&iommu->iova_list); > iommu->dma_list = RB_ROOT; > iommu->dma_avail = dma_entry_limit; > + iommu->pinned_page_dirty_scope = true; > mutex_init(&iommu->lock); > BLOCKING_INIT_NOTIFIER_HEAD(&iommu->notifier); > This would be resolved automatically if we used the counter approach I mentioned on the previous patch, adding a pinned-page scope group simply wouldn't increment the iommu counter, which would initially be zero indicating no "all-dma" groups. Thanks, Alex