Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2474121pxb; Mon, 18 Jan 2021 20:25:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeFWbuP/jPxAtemfFwMcgLspyG3MjMH3Yaz769/mbWQn9eMKkSO3lwT48enYD/GI7s45gz X-Received: by 2002:a50:b905:: with SMTP id m5mr1868765ede.292.1611030338132; Mon, 18 Jan 2021 20:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611030338; cv=none; d=google.com; s=arc-20160816; b=p9ZIk6jKkqXvscF3EZyrccoiJHcsFv0bghvdj6IHWDzWfWLQuurkHf24/uIg8adYzx kO2vA8p80u/fG9Rl5pUD9CsSS7y9U5H+ruLwTp8CxQXm9EBjozJQXYhcq0JcY8SzLR68 SRtW8Q1B8ptseoaEC5X80LB0+5GhDxVesSnDpCYYojNKdIcIsZz5idtz/fRdud7SjKf+ wzJIrYykqFNWaPFgdYPSi/nBcv6zaZAi4lWTMuRWMeWBHIHMV+vWPT8Z8TdK0TiYV+jQ WotF3GqahDgk8HnMgwuYIxLdWGJazxXNi7IK2fmrvJLDUEEk7LqtNkVpsPyFnF3wXEaJ NEOA== 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 :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=bRV0g7CJ1PS0RZXQXOYcVNzPBQ2BCF0y/UYGQJoAUEA=; b=IZOdIxqZDcx1H+RlcNkVpWoJhnefP/pCWuVF6TfvOogkiP/ToIjOiNOfdvaHE9LBWu 4XBkLAuD9EzZ3KErfK5n3KcbG32bKb8ZMUN2U6MnD4tGvMT1jdt5g+US00HEUY1YEbIT ilUBwZGvULs+XWGBZVUSObVoWcZlONBvtEPjx/sJS2OIJfpsL6mW9+5X9F03SrbSwW9A /3hhabitmh0wUGk+g6rMLXumPz1dPlVLTnL6+93e5+IvTYk2k278p8EStjf689bvmixC 14QpR25IrAV4kBru5ekHD7QHTTmlm3GlsIWZWr0jVT59e5GrPU7IHlHr6lZVzQ/tsqFX +XkA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si8072232eji.387.2021.01.18.20.25.07; Mon, 18 Jan 2021 20:25:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392489AbhARNwL (ORCPT + 99 others); Mon, 18 Jan 2021 08:52:11 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:11403 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392338AbhARNf3 (ORCPT ); Mon, 18 Jan 2021 08:35:29 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DKCRT3Mnqz7Wql; Mon, 18 Jan 2021 21:33:41 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Mon, 18 Jan 2021 21:34:38 +0800 Subject: Re: [PATCH 3/6] vfio/iommu_type1: Initially set the pinned_page_dirty_scope To: Alex Williamson References: <20210107044401.19828-1-zhukeqian1@huawei.com> <20210107044401.19828-4-zhukeqian1@huawei.com> <20210115163041.704a4e9d@omen.home.shazbot.org> 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 , , From: Keqian Zhu Message-ID: Date: Mon, 18 Jan 2021 21:34:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20210115163041.704a4e9d@omen.home.shazbot.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/1/16 7:30, Alex Williamson wrote: > 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, > Sure, I will do that, thanks. Keqian. > Alex > > . >