Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1332517ybl; Wed, 4 Dec 2019 22:52:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxQyG6Z0xPuJ/sdtz8tmeddf3EgSaYvGKqVhEyjtBZvxzwcMKaPDanHRFUKqD+ryKSuAjyT X-Received: by 2002:a9d:ea6:: with SMTP id 35mr5289326otj.106.1575528732681; Wed, 04 Dec 2019 22:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575528732; cv=none; d=google.com; s=arc-20160816; b=oGjSHQ9MFfsRzdmDIuZvi7uu/dYq6y8nH6+U8zq1Swn4vIvN7RpiTFy+V8RRwM5HET 01v3KJoJcR2dR/znPul5QlnhP3i1qXewfy3hMyyLzuR+2bxkScFlYQJrN+sD5rNYiGcY A0gnD0um7ORE2qoFHXRhP2wKm0aLJs+H21ygQ7srw5sZskSXmH1oUMdyH98LPQrE82rX K0GmMA5ImTfGsnps4k6gbCTKse3M9NJqusdDZEEDDg5al5ZHwgNtc2Zh79L7CYCEhdJ7 JF/a5rxtDDsB5inhZlMDtJqBbgjpMUZtBtrsLc6OGP3NZ4F5vZitIHnVDJ7ZGRBp3rdT SOhA== 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=+DU3T5dQyNYaNnp2KSExVI3M/SSBxmIkMbbcIbwNecU=; b=etchtdFzPCVRyAbMVcVRAECybi2fVCxFmWRjmBJsNmd6sRa0kAMT40uHEKfhLdsxRT yhM8+5dTwQUEpOprjmrMgydFyWG+KxyMilJU9dO9Mxk/dVbxNQ6ZBuClCQmnBRAVrcNl SWESZZ513nfg5kWyVvGjXM6OCuc+bGMFP3gEtRQUwYp+n70jiSkovy2D6/5qq9kRCzfF BKkeMcqlVLhKnNeDLNHT0asn84w0lKEcdOLNd4Fiv3COKudICshoIfPgGbCtQuFjFx/8 cPNqGkhLp5Jy9nFomO41UJk3fMoC9UqFQ5m0TzkaoSBlN//WiqEo4asyl2oqX4X85gk3 1/MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gw8ND8Pk; 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 f4si4409633oto.169.2019.12.04.22.52.00; Wed, 04 Dec 2019 22:52:12 -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=Gw8ND8Pk; 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 S1726127AbfLEGv3 (ORCPT + 99 others); Thu, 5 Dec 2019 01:51:29 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20356 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725953AbfLEGv2 (ORCPT ); Thu, 5 Dec 2019 01:51:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575528688; 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=+DU3T5dQyNYaNnp2KSExVI3M/SSBxmIkMbbcIbwNecU=; b=Gw8ND8PkMYA5bghbamyW+DcXMQjnu3luguFp2WTAmNOaVgPheH8v7P9ab3JbEMeZH8Y/gf tSU/VDJCtA3MHLqxuoXEoCh1KfHyxrtWIdPFVGU5TjQoQydjq/03lHQinIUNmLpVnjBNR8 G3VsI+Y4JXLXcpMIq98cSm+IQi+EAKo= 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-283-WWP2KC1HNgCn_njLjEo2vg-1; Thu, 05 Dec 2019 01:51:27 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13365800D4C; Thu, 5 Dec 2019 06:51:26 +0000 (UTC) Received: from [10.72.12.247] (ovpn-12-247.pek2.redhat.com [10.72.12.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id A44CE19481; Thu, 5 Dec 2019 06:51:17 +0000 (UTC) Subject: Re: [PATCH RFC 04/15] KVM: Implement ring-based dirty memory tracking To: Peter Xu , Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Sean Christopherson , "Dr . David Alan Gilbert" , Vitaly Kuznetsov , "Michael S. Tsirkin" References: <20191129213505.18472-1-peterx@redhat.com> <20191129213505.18472-5-peterx@redhat.com> <1355422f-ab62-9dc3-2b48-71a6e221786b@redhat.com> <20191204195230.GF19939@xz-x1> From: Jason Wang Message-ID: Date: Thu, 5 Dec 2019 14:51:15 +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: <20191204195230.GF19939@xz-x1> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: WWP2KC1HNgCn_njLjEo2vg-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/12/5 =E4=B8=8A=E5=8D=883:52, Peter Xu wrote: > On Wed, Dec 04, 2019 at 12:04:53PM +0100, Paolo Bonzini wrote: >> On 04/12/19 11:38, Jason Wang wrote: >>>> +=C2=A0=C2=A0=C2=A0 entry =3D &ring->dirty_gfns[ring->dirty_index & (r= ing->size - 1)]; >>>> +=C2=A0=C2=A0=C2=A0 entry->slot =3D slot; >>>> +=C2=A0=C2=A0=C2=A0 entry->offset =3D offset; >>> >>> Haven't gone through the whole series, sorry if it was a silly question >>> but I wonder things like this will suffer from similar issue on >>> virtually tagged archs as mentioned in [1]. >> There is no new infrastructure to track the dirty pages---it's just a >> different way to pass them to userspace. >> >>> Is this better to allocate the ring from userspace and set to KVM >>> instead? Then we can use copy_to/from_user() friends (a little bit slow >>> on recent CPUs). >> Yeah, I don't think that would be better than mmap. > Yeah I agree, because I didn't see how copy_to/from_user() helped to > do icache/dcache flushings... It looks to me one advantage is that exact the same VA is used by both=20 userspace and kernel so there will be no alias. Thanks > > Some context here: Jason raised this question offlist first on whether > we should also need these flush_dcache_cache() helpers for operations > like kvm dirty ring accesses. I feel like it should, however I've got > two other questions, on: > > - if we need to do flush_dcache_page() on kernel modified pages > (assuming the same page has mapped to userspace), then why don't > we need flush_cache_page() too on the page, where > flush_cache_page() is defined not-a-nop on those archs? > > - assuming an arch has not-a-nop impl for flush_[d]cache_page(), > would atomic operations like cmpxchg really work for them > (assuming that ISAs like cmpxchg should depend on cache > consistency). > > Sorry I think these are for sure a bit out of topic for kvm dirty ring > patchset, but since we're at it, I'm raising the questions up in case > there're answers.. > > Thanks, >