Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2097577ybl; Thu, 5 Dec 2019 12:00:19 -0800 (PST) X-Google-Smtp-Source: APXvYqz8GZG6iFP+1a+LqQliIL7HSkGEeAIzK4sV9QYeFXyjq9MErdCJNWtH22IrOZmPGrbpZJfB X-Received: by 2002:aca:2812:: with SMTP id 18mr8898741oix.14.1575576019572; Thu, 05 Dec 2019 12:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575576019; cv=none; d=google.com; s=arc-20160816; b=VRq5AcXiBReL3Vesml+tveBhivTblGy6XWlIh8V6TQYxg2gKsTB7p/bG0QkWqxCOOh a76ZjZs9LXiEuwMg/J3wuZ+jk4q+MQM0Dn3YE8dwGw+Gn8BQE+EybBOC2A0AoM4pTnKi NmfcPnYE4GmtuSnUMbhIyD4LjQB9Qs5AdM5X7Dc+JEobftTx64AOm044Nsh0dxU1WqK4 7lqmtcZuRDsbzw1mZoxcXfV8w8tEJk1wbjK580v3HhFZLrkfwabpkZ6OSfCdizZyYd9v AppDeOta5Mz4d0/LDH/sG82Zk5AgH/IdSTpZYkDCWq0Ytk5vio0jrBw/JOXKxYD4+t1T ZB0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=KWNSf29mI3MtykR8BlHVVbiXJxX25JJg8iyhbBzj48A=; b=NzUh0koKRFvwmNZPrXAJHCO5QQyE54m0qVLu65SUPscrM2erZEuQuPyDWK2WfUu9P3 AQ0zOYWFGIjPX2MOnIEneCWigW5b43nTRxCSj+GmajeoessiwCwhq84CTnQyCcIrhsX2 etRYVwcYtoW7QHiEUx0ostDssnJkfUl42qVwhHMTJJLBK9VwKAAktpyzR2lzmR31GSvu WYpw4ck9yjJE34rgIFl1AMjiKhLggrrQHe20ZOcWV9XzQYtaddoKx+MMKlOJzifUk3Kc gtGQTfDBx9a8oenJrwJ+t0d+ZdAnCx0xHxmrhCPMA8WILerwYFioGKg4J88nF0wEKCpq HJ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hx44nlvt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g190si5701659oib.106.2019.12.05.12.00.06; Thu, 05 Dec 2019 12:00:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hx44nlvt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729502AbfLET7j (ORCPT + 99 others); Thu, 5 Dec 2019 14:59:39 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:32895 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729154AbfLET7i (ORCPT ); Thu, 5 Dec 2019 14:59:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575575977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KWNSf29mI3MtykR8BlHVVbiXJxX25JJg8iyhbBzj48A=; b=hx44nlvtkq5WwynOFC26Au9+OiJdNhIaVhIOnFcXhrcEijZaRlQ7sah/ZZazYwDBvWGLfc g7w0prt4gGmTggj6G/9cQX/tUbOF3BCzE9NTSNRZTcqq2xlAd2CWNODED92JIdWO7q0UFz dXUyEzSILSxcOktilvE0khRArDOr0Qk= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-MW0z7lwJNx6--d3CiyzHRg-1; Thu, 05 Dec 2019 14:59:36 -0500 Received: by mail-wr1-f72.google.com with SMTP id l20so2015581wrc.13 for ; Thu, 05 Dec 2019 11:59:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KWNSf29mI3MtykR8BlHVVbiXJxX25JJg8iyhbBzj48A=; b=C1OL+5TqOk2rpn+zF6UNLuZWBgr6ncT9S1hzj7QuHumtBDay8CCzsznnEFzdkj9xMQ yEE46saLIlchAFxzOVh8ld1rf2or5yYx+4a/hrulRM6vaS5GSirBLKi3MWhDAXtSCXC6 D6U8xIy4Ne+6BCi5uPQIIElW9S02sV2V1e+Icg3cFssbfQC1nlHWUnp2ib4mHqlhucj4 +cipmAq3k3NYzIhdvRAq63LyG/6GQ85uV10nrpxLZCRWOjrEZRPBVGFTLKTY5X3Tr6nT nxTDC5wxdIO4VFZxz11yPn+8sLh2N1bLcQSEPqJlGzZHUHecx0s3g4mFHwMOQxDX333J KLuw== X-Gm-Message-State: APjAAAUhWYUP9v+vcvWL2C4IYGePszTzfTsvaW0nfk535IFpb0jrMiS9 +FD0MIvd2YPS8AzPO/m3154CvpmKZZebw5U7ZIpmfb5F5z0Dz3jVZCfJe58uzEHkmdEdNqtsJHW /H3x7adGBjIn8Xhfbz7ONPGoC X-Received: by 2002:a5d:4d06:: with SMTP id z6mr11594384wrt.339.1575575975181; Thu, 05 Dec 2019 11:59:35 -0800 (PST) X-Received: by 2002:a5d:4d06:: with SMTP id z6mr11594377wrt.339.1575575974905; Thu, 05 Dec 2019 11:59:34 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:541f:a977:4b60:6802? ([2001:b07:6468:f312:541f:a977:4b60:6802]) by smtp.gmail.com with ESMTPSA id h127sm980721wme.31.2019.12.05.11.59.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Dec 2019 11:59:34 -0800 (PST) Subject: Re: [PATCH RFC 00/15] KVM: Dirty ring interface To: Peter Xu Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Sean Christopherson , "Dr . David Alan Gilbert" , Vitaly Kuznetsov References: <20191129213505.18472-1-peterx@redhat.com> <20191202021337.GB18887@xz-x1> <20191205193055.GA7201@xz-x1> From: Paolo Bonzini Message-ID: <60888f25-2299-2a04-68c2-6eca171a2a18@redhat.com> Date: Thu, 5 Dec 2019 20:59:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191205193055.GA7201@xz-x1> Content-Language: en-US X-MC-Unique: MW0z7lwJNx6--d3CiyzHRg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/12/19 20:30, Peter Xu wrote: >> Try enabling kvmmmu tracepoints too, it will tell >> you more of the path that was taken while processing the EPT violation. > > These new tracepoints are extremely useful (which I didn't notice > before). Yes, they are! > So here's the final culprit... > > void kvm_reset_dirty_gfn(struct kvm *kvm, u32 slot, u64 offset, u64 mask) > { > ... > spin_lock(&kvm->mmu_lock); > /* FIXME: we should use a single AND operation, but there is no > * applicable atomic API. > */ > while (mask) { > clear_bit_le(offset + __ffs(mask), memslot->dirty_bitmap); > mask &= mask - 1; > } > > kvm_arch_mmu_enable_log_dirty_pt_masked(kvm, memslot, offset, mask); > spin_unlock(&kvm->mmu_lock); > } > > The mask is cleared before reaching > kvm_arch_mmu_enable_log_dirty_pt_masked().. I'm not sure why that results in two vmexits? (clearing before kvm_arch_mmu_enable_log_dirty_pt_masked is also what KVM_{GET,CLEAR}_DIRTY_LOG does). > The funny thing is that I did have a few more patches to even skip > allocate the dirty_bitmap when dirty ring is enabled (hence in that > tree I removed this while loop too, so that has no such problem). > However I dropped those patches when I posted the RFC because I don't > think it's mature, and the selftest didn't complain about that > either.. Though, I do plan to redo that in v2 if you don't disagree. > The major question would be whether the dirty_bitmap could still be > for any use if dirty ring is enabled. Userspace may want a dirty bitmap in addition to a list (for example: list for migration, bitmap for framebuffer update), but it can also do a pass over the dirty rings in order to update an internal bitmap. So I think it make sense to make it either one or the other. Paolo