Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp21873pxj; Thu, 13 May 2021 19:40:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwVWqRKIN/SHpGeEEkyEhXE+3/EXCiS1D8oK6kbS7tfHRwj3yao6ToU88EVGb4p0fNPTRn X-Received: by 2002:a02:5b85:: with SMTP id g127mr41141927jab.80.1620960020361; Thu, 13 May 2021 19:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620960020; cv=none; d=google.com; s=arc-20160816; b=Q+3cVRVOpdIGqjrY1IxhBN9lXPY6VY/nXWAaHDC20h+hTPx3BnHlRVWiMmuD7CixHy vBcB6t1XtRJdjNErG+6yWlLCaqlk5pe1XXNwReg/V2E1pl16yMXUS1pzzeeWl9Q+KC48 ixHgPECjnHVhH95jbMhaDIT6Tq3/5NRWeJ8aUHvn4RU862YtCal2BUO/iW89YKxAIy0e iU7tn0ehVrFJNHo4YwhFIwpAN/wUsURzqU/HnSQv28qxsPTkAxazWncFc8zEqeF1IxbR iqhN5Yvo57vFYNqXsmWe8QRyzmhY/6R0gZWnIERGShgEUlygtVvBFv+WPGjkUW/85Op5 eZuA== 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=pRV0JxAZSqftS3sQXHwoQdjfXQHyXTUMcdPd94EyZxA=; b=xBpLZwGqmIQrPisKdCWt4VienJXFV4zycXbpV/nxqDOplPm/AE3pSUWANOCNlY+pCp r+bt2eGrSJ7cpH3bJUiThoaxsDlkc5f7zNzBGpINLhmrK9kGz/9njHJkN8JUGlnixO0y e/qc3RgT7Qmr9dd9xFC39+86t37KtMb1vgUghFCfxhFxbQS9uqccTI/Nfuo5ZKv6sb81 qu+1Id3TQeQVqjDiAY3NpHZrwQOrunTw/y2IGcYzhnHpraIqahOpq1KuNgZMfpdqkSb+ 6Canr92z/IxwbCRT4pcs1fdWzA4xOGUs/0Hy0omFM35MbwuzbgjxaVkr2KMJfrahO5jY OhzQ== 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 u12si5579683jak.73.2021.05.13.19.40.08; Thu, 13 May 2021 19:40:20 -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 S230214AbhENCbg (ORCPT + 99 others); Thu, 13 May 2021 22:31:36 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3750 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbhENCbf (ORCPT ); Thu, 13 May 2021 22:31:35 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FhC8g5hHQzqTlk; Fri, 14 May 2021 10:26:59 +0800 (CST) Received: from [10.174.187.224] (10.174.187.224) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Fri, 14 May 2021 10:30:17 +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> <60182a35-e151-7150-3708-4e58dd8e78da@huawei.com> <36cc7267-6aa3-db54-b08c-c2dfc0bbacb6@linux.intel.com> <7fb678c7-509b-dbb5-d533-32c5ce2a0476@linux.intel.com> CC: Alex Williamson , Kirti Wankhede , Cornelia Huck , Jonathan Cameron , , , , From: Keqian Zhu Message-ID: <81d0731d-3331-a5f4-1867-5cc1f3f97a29@huawei.com> Date: Fri, 14 May 2021 10:30:17 +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-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/13 20:02, Lu Baolu wrote: > On 5/13/21 6:58 PM, Keqian Zhu wrote: >> >> >> On 2021/5/12 19:36, Lu Baolu wrote: >>> Hi keqian, >>> >>> On 5/12/21 4:44 PM, Keqian Zhu wrote: >>>> >>>> >>>> On 2021/5/12 11:20, Lu Baolu wrote: >>>>> On 5/11/21 3:40 PM, Keqian Zhu wrote: >>>>>>> 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? >>>>>> >>>>> >>>>> That might be an option. But why not checking domain's attribution every >>>>> time a new tracking period is about to start? >>>> Hi Baolu, >>>> >>>> I'll add an attribution in iommu_domain, and the vendor iommu driver will update >>>> the attribution when attach/detach devices. >>>> >>>> The attribute should be protected by a lock, so the upper layer shouldn't access >>>> the attribute directly. Then the iommu_domain_support_dirty_log() still should be >>>> retained. Does this design looks good to you? >>> >>> Yes, that's what I was thinking of. But I am not sure whether it worth >>> of a lock here. It seems not to be a valid behavior for upper layer to >>> attach or detach any device while doing the dirty page tracking. >> Hi Baolu, >> >> Right, if the "detach|attach" interfaces and "dirty tracking" interfaces can be called concurrently, >> a lock in iommu_domain_support_dirty_log() is still not enough. I will add another note for the dirty >> tracking interfaces. >> >> Do you have other suggestions? I will accelerate the progress, so I plan to send out v5 next week. > > No further comments expect below nit: > > "iommu_switch_dirty_log: Perform actions to start|stop dirty log tracking" > > How about splitting it into > - iommu_start_dirty_log() > - iommu_stop_dirty_log() Yeah, actually this is my original version, and the "switch" style is suggested by Yi Sun. Anyway, I think both is OK, and the "switch" style can reduce some code. Thanks, Keqian > > Not a strong opinion anyway. > > Best regards, > baolu > . >