Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3289075pxj; Tue, 11 May 2021 00:41:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx98BB6ezbWF6EfZ3EXJRZ+2IoQcx8Be2ddJn3gq6KoNZjDZ6QOcHz3bgFHtDqme96ECrIY X-Received: by 2002:a05:6e02:def:: with SMTP id m15mr25573187ilj.12.1620718873366; Tue, 11 May 2021 00:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620718873; cv=none; d=google.com; s=arc-20160816; b=GDHfrBfkQTuVXKctjHLzECaIpwM+Lgg4ihqOF2xqmG6IgrsDUquUswgkLOoROYpeX3 /GS0ucNvWLTNII+Mpp0icI+8b+hEts4Hq/4fNFDX3/fGIRa1d9au4vjpYWD3AawTdEW+ hC8zcpuiA09MHoIOyF2bCvIIFayTFA5N1/qHeE/6ksppDtB15f28rZISqA9lhJccxk8s T9NCpqsVUDIQPAnNywt+pBrMubVp4zCTWF4KlP26IwdsHtRDZ5/F42KTR6UztwxAAnw5 4edYrbw4SfTxqBX6xQqKdXcpkTXdBKnuYPOZo0F/WSynnA5hNbEHIsFGacMBbKRjnuSW jX+g== 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=GThl92Avyc0OeAwSpMsAM1PqrAc9nNmG3fdh6RHSdCU=; b=GzNjdmx6Cn6yii4ersXt35PrCyPYYm/cLDtvL7tr0wg+39g+YxZ8L0cWl0J6gQTZ9b OMx3CVDrj2+QLvhtw4zvjiaqQqO7sjXeUUnEGG6jDRChYvPTmeXL7GtZyCSnpxsoFf2a vKV1Hr5lduW5QmHSEZ82Tf7tHtna9TDbxQItySUQ4y6NWWp1LlFsPwi4weRofQb16PhI K44GN6MmAyU100U/veiyDD4jfuLBqEo41/ylvT7oplSQd3KwrktgUXk0Nx5otrhDXDTZ Ow6leFghpIx7Kt8OTDeGof7RdvFe6iosptIMPfC8QKfj/lEPwdGwdtziLGsk9+4vyLI0 E7EQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si18542314ilv.5.2021.05.11.00.41.00; Tue, 11 May 2021 00:41:13 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbhEKHlX (ORCPT + 99 others); Tue, 11 May 2021 03:41:23 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:2052 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbhEKHlW (ORCPT ); Tue, 11 May 2021 03:41:22 -0400 Received: from dggeml764-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FfV8c1LbKzWhXN; Tue, 11 May 2021 15:36:00 +0800 (CST) Received: from dggpemm000003.china.huawei.com (7.185.36.128) by dggeml764-chm.china.huawei.com (10.1.199.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 11 May 2021 15:40:13 +0800 Received: from [10.174.187.224] (10.174.187.224) by dggpemm000003.china.huawei.com (7.185.36.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 11 May 2021 15:40:13 +0800 Subject: Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework To: Lu Baolu , , , , Robin Murphy , Will Deacon , "Joerg Roedel" , Jean-Philippe Brucker , Yi Sun , Tian Kevin References: <20210507102211.8836-1-zhukeqian1@huawei.com> <20210507102211.8836-2-zhukeqian1@huawei.com> <18ac787a-179e-71f7-728b-c43feda80a16@huawei.com> <55fda826-9ab6-a3a0-b17e-a4d4879f00bc@linux.intel.com> CC: Alex Williamson , Kirti Wankhede , Cornelia Huck , Jonathan Cameron , , , , From: Keqian Zhu Message-ID: <60182a35-e151-7150-3708-4e58dd8e78da@huawei.com> Date: Tue, 11 May 2021 15:40:12 +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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.224] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm000003.china.huawei.com (7.185.36.128) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Baolu, On 2021/5/11 11:12, Lu Baolu wrote: > Hi Keqian, > > On 5/10/21 7:07 PM, Keqian Zhu wrote: >>>>> I suppose this interface is to ask the vendor IOMMU driver to check >>>>> whether each device/iommu in the domain supports dirty bit tracking. >>>>> But what will happen if new devices with different tracking capability >>>>> are added afterward? >>>> Yep, this is considered in the vfio part. We will query again after attaching or >>>> detaching devices from the domain. When the domain becomes capable, we enable >>>> dirty log for it. When it becomes not capable, we disable dirty log for it. >>> If that's the case, why not putting this logic in the iommu subsystem so >>> that it doesn't need to be duplicate in different upper layers? >>> >>> For example, add something like dirty_page_trackable in the struct of >>> iommu_domain and ask the vendor iommu driver to update it once any >>> device is added/removed to/from the domain. It's also better to disallow >> If we do it, the upper layer still needs to query the capability from domain and switch >> dirty log tracking for it. Or do you mean the domain can switch dirty log tracking automatically >> when its capability change? If so, I think we're lack of some flexibility. The upper layer >> may have it's own policy, such as only enable dirty log tracking when all domains are capable, >> and disable dirty log tracking when just one domain is not capable. > > I may not get you. > > Assume that dirty_page_trackable is an attribution of an iommu_domain. > This attribution might be changed once a new device (with different > capability) added or removed. So it should be updated every time a new > device is attached or detached. This work could be done by the vendor > iommu driver on the path of dev_attach/dev_detach callback. Yes, this is what I understand you. > > For upper layers, before starting page tracking, they check the > dirty_page_trackable attribution of the domain and start it only it's > capable. Once the page tracking is switched on the vendor iommu driver > (or iommu core) should block further device attach/detach operations > until page tracking is stopped. But when a domain becomes capable after detaching a device, the upper layer still needs to query it and enable dirty log for it... To make things coordinated, maybe the upper layer can register a notifier, when the domain's capability change, the upper layer do not need to query, instead they just need to realize a callback, and do their specific policy in the callback. What do you think? > >> >>> any domain attach/detach once the dirty page tracking is on. >> Yep, this can greatly simplify our code logic, but I don't know whether our maintainers >> agree that, as they may think that IOMMU dirty logging should not change original domain >> behaviors. > > The maintainer owns the last word, but we need to work out a generic and > self-contained API set. OK, I see. Thanks, Keqian