Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp642568pxj; Thu, 13 May 2021 13:21:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHMU6ZrF3+b7jbig95KHQbvhBlOk9q203yOEvaqLyp1xPFWOldzw4OQYjNxVza5cJ7qAYM X-Received: by 2002:aa7:c499:: with SMTP id m25mr5560969edq.109.1620937284103; Thu, 13 May 2021 13:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620937284; cv=none; d=google.com; s=arc-20160816; b=gsp3VYhwhxNEH5QZX+B+sn7VvYP8DJJW8sJAUZ+Eag1s7pdPu1VsoomPJCILoJL8aZ LwqxMuIAIcNkECLlJ8rpLwjfMIaO7MYT8lx1WRygr0od3XT6st9S7NjrSA5RRZX1c4q4 FPK3ozOzsVdZsjvJ4mtv2vmKCT7Ycxhcy5gb0kRiIwoWw2BGFXGtOvEHtCAnOpKwO8/c +B9WOsOSBK201mCJN1wBaqLpOizQeq7l/Xb/EC6Yg5dguaY3z0aUTCWlq0UR5oA3uo7p xutj+wNj0qUS8UISpnIxFM7GmwufdOqfZC2oSOQR23KjOJ7a4gf8hmNuwwbhEAlANhxc OB7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:cc:ironport-sdr:ironport-sdr; bh=7HOGqb63Kjs3XWAGUZ0c6e9kc1pGYEMPFiNrZ3TgoBA=; b=CCrirgIV9hEr/mlfoYextp/dNzgU9Ue8aW3yvKr/Xd+C6G0twNH2l6OaX5Ykc6ycrt rUpXwh5ch+nNrUw5LL3pui1MZLNWyrzVzAC7hu8KZyhjvxWX/H/25jt6mIdIlLpX1EDm 2Eoo0NLKVMBcH3kU/S/Wm1JQyjE9M3dezVTW/RmrVdTuCaU8kGiU7+p8GkdQs/eAU9H/ QD7W90RR3edH940ebCac5h/vWDcMzn1h39VzoFOAoss6bJFKWv3Vt8BaHYJHDnNJ7wCW OZkeldah1Tmf65fJQvrk+AmAP0/FDwg0PZXqbqOpM6y6FJsJwKWAhSrxXj9baVYvsknY ezWw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si3887676edc.185.2021.05.13.13.19.26; Thu, 13 May 2021 13:21:24 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233268AbhEMMEy (ORCPT + 99 others); Thu, 13 May 2021 08:04:54 -0400 Received: from mga12.intel.com ([192.55.52.136]:4723 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232375AbhEMMEw (ORCPT ); Thu, 13 May 2021 08:04:52 -0400 IronPort-SDR: bH396fdq8Dn5R63Qu5F5fAY0leNQUR4pxUQho0+9G5IbTpI4te89bfpzoefE1EsNW5gVa7bGkM lr0qGSo0EiSg== X-IronPort-AV: E=McAfee;i="6200,9189,9982"; a="179523248" X-IronPort-AV: E=Sophos;i="5.82,296,1613462400"; d="scan'208";a="179523248" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2021 05:03:42 -0700 IronPort-SDR: kfUiTvJZ1XRAiMzDD85xQ4AZvc2CoPqWLiApWLsfmMyUNBoR8072rQ7CR5yJeVvPvATmhq6UKP U7hk43vai35A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,296,1613462400"; d="scan'208";a="623600415" Received: from allen-box.sh.intel.com (HELO [10.239.159.128]) ([10.239.159.128]) by fmsmga006.fm.intel.com with ESMTP; 13 May 2021 05:03:35 -0700 Cc: baolu.lu@linux.intel.com, Alex Williamson , Kirti Wankhede , Cornelia Huck , Jonathan Cameron , wanghaibin.wang@huawei.com, jiangkunkun@huawei.com, yuzenghui@huawei.com, lushenming@huawei.com Subject: Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework To: Keqian Zhu , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, 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> From: Lu Baolu Message-ID: Date: Thu, 13 May 2021 20:02:47 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() Not a strong opinion anyway. Best regards, baolu