Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp279712ybl; Wed, 4 Dec 2019 02:39:42 -0800 (PST) X-Google-Smtp-Source: APXvYqzdN1ApUiMUZ8avGg3RG41pE7wm8STDf2z/3DEpQKwSMw/18NgMwHS+PprWdOmH1JlQ+3cx X-Received: by 2002:a9d:75c7:: with SMTP id c7mr1901406otl.12.1575455982170; Wed, 04 Dec 2019 02:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575455982; cv=none; d=google.com; s=arc-20160816; b=b1q2cc2awknvy9CAKMJBnMTMrzuLGfCw4UC7rBsvqJWv9Tu4i+ZASn34PBm6mOkPzS pmg86YhAkCw16msVUoOW4mVeGd2vJInRdujP0kusAZAmfElgp/nH9XQKSOzqfbpzJfu2 0R4tTgth5FBsebb8/T2Hrectd8y7PdMuo3H8XovH2Dsom75z9Lp2EjOQiZfdRCgsk0RS IgXYWwSZAYnlvVGOzWzkF8Pl+uVEbwhHSLqdZClV+xQoWQcvNjkWYltEiXYymS51YVUH UwzwGiTXBLDIXvXl8HrJK0mHnK7rSKI1nFsDMn2qXVDk2E8k9j+5yM1rWwKpD0NDojzn Ervg== 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=qyYnPmXfgI61ReQeMn/+NTEgEMEEZXrZpt8TBXvPtWs=; b=GSjRcAbooRhWqtPq7K+ZzUh+e3B0AsyEr3MtGjxrCC52I7tswcFUA4fwhJXZYYy2oV WT78HjlAPO2aFkQlWA0AQXkjoX5eGaUGNxCNai0XoFA4aFTJitu76B25dYmAHt9FIeHn /VUbHwzPOy9PingfTxnla0F5Xd9dNbo7hpnWgYWUj+11XyVXQRR7lggFQgtc6lveQqwq CsMtM4ux/k1TQNdcf/KXdRaMlfmfzTUSthlqv9540s7PLsamPD1XwjYgIxwRe9nTV4AG JkcrNZCs3PgyWXWEFvD1E6SJrFKFeOzJiwEyk6/OLDTfG+4MSwdrh0U7yW9XatlzlN62 STkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="PBV9A8K/"; 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 i15si2835456otk.120.2019.12.04.02.39.29; Wed, 04 Dec 2019 02:39:42 -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="PBV9A8K/"; 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 S1727537AbfLDKi6 (ORCPT + 99 others); Wed, 4 Dec 2019 05:38:58 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49847 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727445AbfLDKi6 (ORCPT ); Wed, 4 Dec 2019 05:38:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575455937; 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=qyYnPmXfgI61ReQeMn/+NTEgEMEEZXrZpt8TBXvPtWs=; b=PBV9A8K/tIfbfS9wJYChjoNSb9X+xXIEAHaNTucE75HhJ7gElP7WBMO+BMZ5ZJcM0UeGI4 XaHG5X/VApWjw7K0qxyt1BdIrHaMcY5pzLlUdJsIuU+mdrndbOiZStICt5QPsrqbshaJJP oZtT1b8uBtnQrNbljCEsgOb7tyQs7II= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-GMxku97lOqKb5wfj8JYdEQ-1; Wed, 04 Dec 2019 05:38:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3388D107ACC4; Wed, 4 Dec 2019 10:38:55 +0000 (UTC) Received: from [10.72.12.45] (ovpn-12-45.pek2.redhat.com [10.72.12.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0763E101E811; Wed, 4 Dec 2019 10:38:47 +0000 (UTC) Subject: Re: [PATCH RFC 04/15] KVM: Implement ring-based dirty memory tracking To: Peter Xu , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson , Paolo Bonzini , "Dr . David Alan Gilbert" , Vitaly Kuznetsov , "Michael S. Tsirkin" References: <20191129213505.18472-1-peterx@redhat.com> <20191129213505.18472-5-peterx@redhat.com> From: Jason Wang Message-ID: <1355422f-ab62-9dc3-2b48-71a6e221786b@redhat.com> Date: Wed, 4 Dec 2019 18:38:35 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191129213505.18472-5-peterx@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: GMxku97lOqKb5wfj8JYdEQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/11/30 =E4=B8=8A=E5=8D=885:34, Peter Xu wrote: > +int kvm_dirty_ring_push(struct kvm_dirty_ring *ring, > +=09=09=09struct kvm_dirty_ring_indexes *indexes, > +=09=09=09u32 slot, u64 offset, bool lock) > +{ > +=09int ret; > +=09struct kvm_dirty_gfn *entry; > + > +=09if (lock) > +=09=09spin_lock(&ring->lock); > + > +=09if (kvm_dirty_ring_full(ring)) { > +=09=09ret =3D -EBUSY; > +=09=09goto out; > +=09} > + > +=09entry =3D &ring->dirty_gfns[ring->dirty_index & (ring->size - 1)]; > +=09entry->slot =3D slot; > +=09entry->offset =3D offset; Haven't gone through the whole series, sorry if it was a silly question=20 but I wonder things like this will suffer from similar issue on=20 virtually tagged archs as mentioned in [1]. Is this better to allocate the ring from userspace and set to KVM=20 instead? Then we can use copy_to/from_user() friends (a little bit slow=20 on recent CPUs). [1] https://lkml.org/lkml/2019/4/9/5 Thanks > +=09smp_wmb(); > +=09ring->dirty_index++; > +=09WRITE_ONCE(indexes->avail_index, ring->dirty_index); > +=09ret =3D kvm_dirty_ring_used(ring) >=3D ring->soft_limit; > +=09pr_info("%s: slot %u offset %llu used %u\n", > +=09=09__func__, slot, offset, kvm_dirty_ring_used(ring)); > + > +out: