Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp8087pxf; Tue, 16 Mar 2021 20:16:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfZqMBRV0i8jvYWC1oCRCp2g9RWIUvOIfncAn5aR8w3ltAOrT78FU6p/tthWUE/GUdlMzL X-Received: by 2002:a17:906:9243:: with SMTP id c3mr34139746ejx.388.1615950993832; Tue, 16 Mar 2021 20:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615950993; cv=none; d=google.com; s=arc-20160816; b=stFF426iZRKg+CkUqIsYFIefQB2vZ0ix9t8BcF36c1V2HI/sUMofWM6w8mrWLF901W jGvSTwgRX0bbU6BQbjLx8NhbGYDYnmOVHj54x/iwJn91tzOy/kJ4Rf1QZdeBEkF2DBDq 9qMas3JwI5kFDoh4l7VUzqTV7Q9qSwzfaYgkf5T9v8w7tJnKKog+OdDzpl+TMUjWagge I9otBSP2rlSg2sDq0DMlbRJiwvOEiVUYoPty42hjzbeA9rOBIj2I+2hvCaYudVRh4h4d YMPvE7lBXGZHiwT+TsI6yGvFt357eHX5N7Km4d5lL+eiAnptkL0TN5n3ozS9GdUCTe5O T7zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=+tgtm+mqF+cVYTc8heU6ug4H2W6UXhGWPjj8frq8ja8=; b=aBMlDXOErauiFvNGCvTZHj/iyEnBpMxIWbLBpGG0efBBh0wszRSiX9OVye23Dml7ya VlI620430gg9vwZ4YIG6EtQJ0sjlhoY/P1pdf+G6SSIrnY7hdObaaD/r9IXFvD9KwExE AKfTVYFevCB8FXi7VMzKwJ/TNhgGjpy+qd2hqRM2o6S+oV80Rpser5HlxEfjIcJ3hqlc 62H2gW4xuErlfLuiSXb/aTbFXDcGJ4p0aMGk+fWaFu6ZoWr5StxEbU1Z89VehmrO5WPQ /epvY9TsxX88D6bbML3OxRfTq0cz6HnnCSfHy3QS781sQGRTt4lA+I5k71XAQXwNSNxN cy7Q== 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 o15si14548519ejh.542.2021.03.16.20.16.10; Tue, 16 Mar 2021 20:16:33 -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 S229590AbhCQDND (ORCPT + 99 others); Tue, 16 Mar 2021 23:13:03 -0400 Received: from mga07.intel.com ([134.134.136.100]:37302 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhCQDMf (ORCPT ); Tue, 16 Mar 2021 23:12:35 -0400 IronPort-SDR: ZXDem6dF/ks7xu1j5A49bNN2Qt/fDFS+TrpuIg67NxNllK7e5qofbr6qoatNbWo8wrxbJHWEJu 9Y84vNHsuqwQ== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="253391219" X-IronPort-AV: E=Sophos;i="5.81,254,1610438400"; d="scan'208";a="253391219" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 20:12:35 -0700 IronPort-SDR: FSv7+WVPIfSeBOm8IDU3guGi4HRgtprZGvblH9S2KmesztcKJG0kwooyKi/3v5SdkuRddznjkE 4JWo7jkqjy5A== X-IronPort-AV: E=Sophos;i="5.81,254,1610438400"; d="scan'208";a="412475709" Received: from yisun1-ubuntu.bj.intel.com (HELO yi.y.sun) ([10.238.156.116]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA256; 16 Mar 2021 20:12:29 -0700 Date: Wed, 17 Mar 2021 11:06:44 +0800 From: Yi Sun To: Keqian Zhu Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, Alex Williamson , Robin Murphy , Will Deacon , Kirti Wankhede , Cornelia Huck , Marc Zyngier , Catalin Marinas , Mark Rutland , James Morse , Suzuki K Poulose , wanghaibin.wang@huawei.com, jiangkunkun@huawei.com, yuzenghui@huawei.com, lushenming@huawei.com Subject: Re: [PATCH v2 04/11] iommu/arm-smmu-v3: Split block descriptor when start dirty log Message-ID: <20210317030644.GO28580@yi.y.sun> References: <20210310090614.26668-1-zhukeqian1@huawei.com> <20210310090614.26668-5-zhukeqian1@huawei.com> <20210316091751.GN28580@yi.y.sun> <84cef87c-af82-8564-fc23-654042448d05@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <84cef87c-af82-8564-fc23-654042448d05@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-03-16 19:39:47, Keqian Zhu wrote: > Hi Yi, > > On 2021/3/16 17:17, Yi Sun wrote: > > On 21-03-10 17:06:07, Keqian Zhu wrote: > >> From: jiangkunkun > >> > >> Block descriptor is not a proper granule for dirty log tracking. > >> Take an extreme example, if DMA writes one byte, under 1G mapping, > >> the dirty amount reported to userspace is 1G, but under 4K mapping, > >> the dirty amount is just 4K. > >> > >> This adds a new interface named start_dirty_log in iommu layer and > >> arm smmuv3 implements it, which splits block descriptor to an span > >> of page descriptors. Other types of IOMMU will perform architecture > >> specific actions to start dirty log. > >> > >> To allow code reuse, the split_block operation is realized as an > >> iommu_ops too. We flush all iotlbs after the whole procedure is > >> completed to ease the pressure of iommu, as we will hanle a huge > >> range of mapping in general. > >> > >> Spliting block does not simultaneously work with other pgtable ops, > >> as the only designed user is vfio, which always hold a lock, so race > >> condition is not considered in the pgtable ops. > >> > >> Co-developed-by: Keqian Zhu > >> Signed-off-by: Kunkun Jiang > >> --- > >> > >> changelog: > >> > >> v2: > >> - Change the return type of split_block(). size_t -> int. > >> - Change commit message to properly describe race condition. (Robin) > >> - Change commit message to properly describe the need of split block. > >> - Add a new interface named start_dirty_log(). (Sun Yi) > >> - Change commit message to explain the realtionship of split_block() and start_dirty_log(). > >> > >> --- > >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 52 +++++++++ > >> drivers/iommu/io-pgtable-arm.c | 122 ++++++++++++++++++++ > >> drivers/iommu/iommu.c | 48 ++++++++ > >> include/linux/io-pgtable.h | 2 + > >> include/linux/iommu.h | 24 ++++ > >> 5 files changed, 248 insertions(+) > >> > > Could you please split iommu common interface to a separate patch? > > This may make review and comments easier. > Yup, good suggestion. > > > > > IMHO, I think the start/stop interfaces could be merged into one, e.g: > > int iommu_domain_set_hwdbm(struct iommu_domain *domain, bool enable, > > unsigned long iova, size_t size, > > int prot); > Looks good, this reduces some code. but I have a concern that this causes loss of flexibility, > as we must pass same arguments when start|stop dirty log. What's your opinion about this? > Per current design, start/stop interfaces have similar arguments. So I think it is ok for now. For future extension, we may think to define a structure to pass these arguments. > > > > Same comments to patch 5. > OK. Thanks. > > > > > BRs, > > Yi Sun > > > >> -- > >> 2.19.1 > > . > Thanks, > Keqian BRs, Yi Sun