Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1169071ybs; Mon, 25 May 2020 08:47:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPVQTIJJMPCRq2S/cEWdmV5ZyC8q11/nTq3QE+QW95le+s6fO7wLAsnEPzze7+t2tl0/Q7 X-Received: by 2002:a05:6402:2211:: with SMTP id cq17mr15294884edb.171.1590421648593; Mon, 25 May 2020 08:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590421648; cv=none; d=google.com; s=arc-20160816; b=Ce4JktJx+P9NjNjW69xV+W9Kx6+RgTsjmWAFR4fgYo74eArISJUfV0lakZqSYm89EV LmtI6AC3PGwSciNp8+gl0iwDPUnKOK8U4R6uzl2Iq1lpCcFPyW/aZO8ptTUfiDGrITSY jRz14ZJCYS9TaVYYd0i2gbHETBgR1CYqw73aRn8A2nWhbEcqmYqzW8QceoCklDXRjYXj A1+LQEGDZwZj1z5US744zRiAJiOLy88eQGjYjZRh64EBAn2lDCpZjGSSNAkmNqEdoGt2 fwUqpD5WDluJS/2Ojdg74IUaEsUkQf2Ry5/P7B3L23JvxHudKyAJN7dLYa045+9+TcQq wLoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=4Chf7ukj7qTUxK4XlDTiE/gC+7lJTsiqhRK/nchDr7s=; b=zhi1VODC5zbo7FprCKICGtn6ijHkzZ5bd1bFUO0IV7PsZdOYjZ1t7t+Wlf8hY4LSSq f/R4QwEB7nqwHmYOzC6i0oolEvapLp90UzrwGXkBXqc99ILPui50kbDrwe4Y5dKxIeGI 3ZeBdwlPC7Dy3tylCsVCt/ZnErVewJrFBirsZU/HCmakGzX7L3zsAQ4o0udv8uKT4Qv0 7cXyYk7gp0ToPrWJK91Mk+LdN6PkouUMO43NS4F1i7e0xWlTjs+UAD4fIik92VlYf/Jj 9J7Jl1OX48lNWTrBT1A7jyJcPeiFC9349sIiq32ryg7oer6VVtr3x8dK7xBuT459M6Lx XeiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jaImQu0p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn20si14341572ejc.319.2020.05.25.08.47.05; Mon, 25 May 2020 08:47:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=jaImQu0p; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390935AbgEYPo4 (ORCPT + 99 others); Mon, 25 May 2020 11:44:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:54236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725969AbgEYPo4 (ORCPT ); Mon, 25 May 2020 11:44:56 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A22992071C; Mon, 25 May 2020 15:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590421495; bh=r8OCSimYRde1NwHA/0Q7MB3/3zxYFYjrUXrzd9tKjr8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jaImQu0pAsogF1OmK8r3Cbbzn3J1P85LmElRGOIs0VgCmyozC8RrwHIJ+DIMyUnqi NK2HPQuQAhIlUiOnqaBmX54A14oy1kBZO0SYrzxnu7F/qhagrMQENb5MLd6dYplEBc L86U2sMjEGtzOnzFmM953wVFfjZpoYxQR8Q8TczU= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jdFHZ-00FCGg-VI; Mon, 25 May 2020 16:44:54 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 25 May 2020 16:44:53 +0100 From: Marc Zyngier To: Keqian Zhu Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Catalin Marinas , James Morse , Will Deacon , Suzuki K Poulose , Sean Christopherson , Julien Thierry , Mark Brown , Thomas Gleixner , Andrew Morton , Alexios Zavras , wanghaibin.wang@huawei.com, zhengxiang9@huawei.com Subject: Re: [RFC PATCH 0/7] kvm: arm64: Support stage2 hardware DBM In-Reply-To: <20200525112406.28224-1-zhukeqian1@huawei.com> References: <20200525112406.28224-1-zhukeqian1@huawei.com> User-Agent: Roundcube Webmail/1.4.4 Message-ID: <4b8a939172395bf38e581634abecf925@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: zhukeqian1@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, catalin.marinas@arm.com, james.morse@arm.com, will@kernel.org, suzuki.poulose@arm.com, sean.j.christopherson@intel.com, julien.thierry.kdev@gmail.com, broonie@kernel.org, tglx@linutronix.de, akpm@linux-foundation.org, alexios.zavras@intel.com, wanghaibin.wang@huawei.com, zhengxiang9@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-25 12:23, Keqian Zhu wrote: > This patch series add support for stage2 hardware DBM, and it is only > used for dirty log for now. > > It works well under some migration test cases, including VM with 4K > pages or 2M THP. I checked the SHA256 hash digest of all memory and > they keep same for source VM and destination VM, which means no dirty > pages is missed under hardware DBM. > > However, there are some known issues not solved. > > 1. Some mechanisms that rely on "write permission fault" become > invalid, > such as kvm_set_pfn_dirty and "mmap page sharing". > > kvm_set_pfn_dirty is called in user_mem_abort when guest issues > write > fault. This guarantees physical page will not be dropped directly > when > host kernel recycle memory. After using hardware dirty management, > we > have no chance to call kvm_set_pfn_dirty. Then you will end-up with memory corruption under memory pressure. This also breaks things like CoW, which we depend on. > > For "mmap page sharing" mechanism, host kernel will allocate a new > physical page when guest writes a page that is shared with other > page > table entries. After using hardware dirty management, we have no > chance > to do this too. > > I need to do some survey on how stage1 hardware DBM solve these > problems. > It helps if anyone can figure it out. > > 2. Page Table Modification Races: Though I have found and solved some > data > races when kernel changes page table entries, I still doubt that > there > are data races I am not aware of. It's great if anyone can figure > them out. > > 3. Performance: Under Kunpeng 920 platform, for every 64GB memory, KVM > consumes about 40ms to traverse all PTEs to collect dirty log. It > will > cause unbearable downtime for migration if memory size is too big. I > will > try to solve this problem in Patch v1. This, in my opinion, is why Stage-2 DBM is fairly useless. From a performance perspective, this is the worse possible situation. You end up continuously scanning page tables, at an arbitrary rate, without a way to evaluate the fault rate. One thing S2-DBM would be useful for is SVA, where a device write would mark the S2 PTs dirty as they are shared between CPU and SMMU. Another thing is SPE, which is essentially a DMA agent using the CPU's PTs. But on its own, and just to log the dirty pages, S2-DBM is pretty rubbish. I wish arm64 had something like Intel's PML, which looks far more interesting for the purpose of tracking accesses. Thanks, M. -- Jazz is not dead. It just smells funny...