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 X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46FC2C433E0 for ; Mon, 18 Jan 2021 14:01:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7964221FC for ; Mon, 18 Jan 2021 14:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392368AbhARNvU (ORCPT ); Mon, 18 Jan 2021 08:51:20 -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: kvm@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 > > . >