From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 018DFC433DB for ; Fri, 5 Feb 2021 03:32:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75B1061481 for ; Fri, 5 Feb 2021 03:32:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75B1061481 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=A8I7dxn3RjO5qQEvFpfyf6prdPXXOoHWRu1dEDxu4x0=; b=Ju1mZfn2jPagtPJlD1kZrqn8s HNi6luP9y8/8AV83GLv1Nvueo20/YPmSV+hYlm0nNEpEEOeIV4guaCpE7UHnhPWMRWo5VW0lwn3ut ztvd3PsCHHKGxGnnjqgCnZV2ih6hGTb4FZrmSENXNEZvZCRsL4sppLmqMLRZZ77BfckIrsJoYqGiw dKDhtncwmsGOZ/DwSzhHArJnjeEHHBByR1gkf8O7Ou1O4EbJzc36AzY8Z6SPLYs11SJEOu8xYgKC9 Ym5EBUPANmg5H4sRVSt5hCEIcyu3+3+HBuhJFARZiLV2kfvGJzWO9SDhAebd8xXjho3oxgWhO2uqF jVGICvVaQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7rpq-0003pn-8O; Fri, 05 Feb 2021 03:31:06 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7rpm-0003p4-69 for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2021 03:31:04 +0000 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DX19j3NZpzlGfQ; Fri, 5 Feb 2021 11:29:13 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Fri, 5 Feb 2021 11:30:47 +0800 Subject: Re: [RFC] Use SMMU HTTU for DMA dirty page tracking To: Jean-Philippe Brucker , "Tian, Kevin" References: <20200522171452.GC3453945@myrica> <897a84ac-0a71-ace7-e05b-3cc9f0b05c28@huawei.com> <20200527091428.GB265288@myrica> From: Keqian Zhu Message-ID: Date: Fri, 5 Feb 2021 11:30:47 +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: <20200527091428.GB265288@myrica> X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210204_223103_228716_8872F2C9 X-CRM114-Status: GOOD ( 23.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Zhao, Yan Y" , "maz@kernel.org" , "iommu@lists.linux-foundation.org" , Kirti Wankhede , "alex.williamson@redhat.com" , "prime.zeng@hisilicon.com" , Will Deacon , "kvmarm@lists.cs.columbia.edu" , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Jean and Kevin, FYI, I have send out the SMMUv3 HTTU support for DMA dirty tracking[1] a week ago. Thanks, Keqian [1] https://lore.kernel.org/linux-iommu/20210128151742.18840-1-zhukeqian1@huawei.com/ On 2020/5/27 17:14, Jean-Philippe Brucker wrote: > On Wed, May 27, 2020 at 08:40:47AM +0000, Tian, Kevin wrote: >>> From: Xiang Zheng >>> Sent: Wednesday, May 27, 2020 2:45 PM >>> >>> >>> On 2020/5/27 11:27, Tian, Kevin wrote: >>>>> From: Xiang Zheng >>>>> Sent: Monday, May 25, 2020 7:34 PM >>>>> >>>>> [+cc Kirti, Yan, Alex] >>>>> >>>>> On 2020/5/23 1:14, Jean-Philippe Brucker wrote: >>>>>> Hi, >>>>>> >>>>>> On Tue, May 19, 2020 at 05:42:55PM +0800, Xiang Zheng wrote: >>>>>>> Hi all, >>>>>>> >>>>>>> Is there any plan for enabling SMMU HTTU? >>>>>> >>>>>> Not outside of SVA, as far as I know. >>>>>> >>>>> >>>>>>> I have seen the patch locates in the SVA series patch, which adds >>>>>>> support for HTTU: >>>>>>> https://www.spinics.net/lists/arm-kernel/msg798694.html >>>>>>> >>>>>>> HTTU reduces the number of access faults on SMMU fault queue >>>>>>> (permission faults also benifit from it). >>>>>>> >>>>>>> Besides reducing the faults, HTTU also helps to track dirty pages for >>>>>>> device DMA. Is it feasible to utilize HTTU to get dirty pages on device >>>>>>> DMA during VFIO live migration? >>>>>> >>>>>> As you know there is a VFIO interface for this under discussion: >>>>>> https://lore.kernel.org/kvm/1589781397-28368-1-git-send-email- >>>>> kwankhede@nvidia.com/ >>>>>> It doesn't implement an internal API to communicate with the IOMMU >>>>> driver >>>>>> about dirty pages. >>>> >>>> We plan to add such API later, e.g. to utilize A/D bit in VT-d 2nd-level >>>> page tables (Rev 3.0). >>>> >>> >>> Thank you, Kevin. >>> >>> When will you send this series patches? Maybe(Hope) we can also support >>> hardware-based dirty pages tracking via common APIs based on your >>> patches. :) >> >> Yan is working with Kirti on basic live migration support now. After that >> part is done, we will start working on A/D bit support. Yes, common APIs >> are definitely the goal here. >> >>> >>>>> >>>>>> >>>>>>> If SMMU can track dirty pages, devices are not required to implement >>>>>>> additional dirty pages tracking to support VFIO live migration. >>>>>> >>>>>> It seems feasible, though tracking it in the device might be more >>>>>> efficient. I might have misunderstood but I think for live migration of >>>>>> the Intel NIC they trap guest accesses to the device and introspect its >>>>>> state to figure out which pages it is accessing. >>>> >>>> Does HTTU implement A/D-like mechanism in SMMU page tables, or just >>>> report dirty pages in a log buffer? Either way tracking dirty pages in IOMMU >>>> side is generic thus doesn't require device-specific tweak like in Intel NIC. >>>> >>> >>> Currently HTTU just implement A/D-like mechanism in SMMU page tables. >>> We certainly >>> expect SMMU can also implement PML-like feature so that we can avoid >>> walking the >>> whole page table to get the dirty pages. > > There is no reporting of dirty pages in log buffer. It might be possible > to do software logging based on PRI or Stall, but that requires special > support in the endpoint as well as the SMMU. > >> Is there a link to HTTU introduction? > > I don't know any gentle introduction, but there are sections D5.4.11 > "Hardware management of the Access flag and dirty state" in the ARM > Architecture Reference Manual (DDI0487E), and section 3.13 "Translation > table entries and Access/Dirty flags" in the SMMU specification > (IHI0070C). HTTU stands for "Hardware Translation Table Update". > > In short, when HTTU is enabled, the SMMU translation performs an atomic > read-modify-write on the leaf translation table descriptor, setting some > bits depending on the type of memory access. This can be enabled > independently on both stage-1 and stage-2 tables (equivalent to your 1st > and 2nd page tables levels, I think). > > Thanks, > Jean > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm > . > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel