Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4385713pxj; Wed, 12 May 2021 04:39:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGM89iL5YPNlROip8pUw2NeBoJzGsBfVqZp9wb/bn2JQ7+TNl6I9S8JTwcElNjGRSyV+JZ X-Received: by 2002:a5d:89c5:: with SMTP id a5mr26636152iot.172.1620819542675; Wed, 12 May 2021 04:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620819542; cv=none; d=google.com; s=arc-20160816; b=WxntGLpmBof1guS+67ytVDJ0iMAL0VpYpcBR4vMvODqd/q2Spo2bN44g3q1btFTPTm c7jwP613HrsH+ePrH842OWkBKx/0bAZ66S9DsMfV7uhElWI5KQlOKt4Lwx4AGUiOr0fm fSqc18hpwBhwuIyzIIW+DS1PjtNEsIxdjH12M6ZSQ8MEREUY7ld2cez3nAj2EEa5ZDGO 6KRrtjgtvSj7/UhzxLx+FNryjIoOS74pldh1q453s2NBk1I6M6b/KNRFZB6PGZN2Jl60 EUzlatNvYXQX/JSLSnl7ovGz6qlH2azIxijxcMTFFWtwLMHyYJNhIBozcmUHho+UUGkA cVqA== 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=HbXyZDe+veO9s10rI2l7v8S2WPqSXcxwbmWW9ZWrJuU=; b=IfpLTYO9ddfkjwmhgjVHZPK8f8ZLcpqXr3fEgc6IOazhW9hgMgkyXlzVUmEN6dvfpr K6BQooEr7Om3G3CzDg8lHOIXdTOs6VEMFCX9I12Ksg3aeoAluk6IvqLvFIu6ltDPDz/M mr8S2JIXr5pWhPmaaZASzCX1SuHxlH/dv4LUFmyTzsVzppnlZ3Ca5nePKs9A5XLHDkJa tFzk0sXcqftT5Lsw/QQodY8GQATwHZOnl94tLg/ZsXOviaRps6hbJkO6A4LUhg7kwYhl BFJAd/0yb4uvS2HphYNTjk1CwmyHNUbM0hys+Nc6acuilqcmSFaPEDL5jTkGo4WOHBK5 dh2Q== 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 d5si21534603ioq.28.2021.05.12.04.38.50; Wed, 12 May 2021 04:39:02 -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 S230213AbhELLiL (ORCPT + 99 others); Wed, 12 May 2021 07:38:11 -0400 Received: from mga05.intel.com ([192.55.52.43]:62179 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbhELLiK (ORCPT ); Wed, 12 May 2021 07:38:10 -0400 IronPort-SDR: wcvoJX32daI6q1ZfruXwNm0/Bsxz9zU81Bru11aPneC5Ie+hW/KBRrsnUorWlaJOsXM9d1hRGf oYIBANA8/8Bw== X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="285185306" X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="285185306" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2021 04:37:01 -0700 IronPort-SDR: /H5FLzSrZq+cwNz0Azt92onxkumHrnfiBrY3Lf5zJuvazIodXgHxSAY4WCiCCFCq8gbo3W8m6h rUxD+mRhMjiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="622372334" Received: from allen-box.sh.intel.com (HELO [10.239.159.128]) ([10.239.159.128]) by fmsmga006.fm.intel.com with ESMTP; 12 May 2021 04:36:57 -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> From: Lu Baolu Message-ID: <7fb678c7-509b-dbb5-d533-32c5ce2a0476@linux.intel.com> Date: Wed, 12 May 2021 19:36:10 +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 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. Best regards, baolu