From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takuya Yoshikawa Subject: Re: [PATCH 1/1 v2] KVM: MMU: Use ptep_user for cmpxchg_gpte() Date: Wed, 4 May 2011 23:00:35 +0900 Message-ID: <20110504230035.b7f41443.takuya.yoshikawa@gmail.com> References: <20110501143026.9eb3c875.takuya.yoshikawa@gmail.com> <20110501143307.1bcfd375.takuya.yoshikawa@gmail.com> <20110504111611.GA26538@amt.cnet> <4DC13C2F.4090402@redhat.com> <20110504115827.GA28957@amt.cnet> <4DC14277.4090006@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp To: Avi Kivity Return-path: Received: from mail-pz0-f46.google.com ([209.85.210.46]:47587 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752556Ab1EDOAk (ORCPT ); Wed, 4 May 2011 10:00:40 -0400 Received: by pzk9 with SMTP id 9so507420pzk.19 for ; Wed, 04 May 2011 07:00:40 -0700 (PDT) In-Reply-To: <4DC14277.4090006@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: > > > >gfn_to_page is the interface for mapping guest pages inside KVM, > > > >and you're bypassing it for IMO no good reason (i doubt there's any > > > >performance improvement by skipping the translation). > > > > > > He isn't skipping it - he's using gfn_to_hva() to derive ptep_user, > > > which is equivalent. > > > > Well, he is removing the second translation. So that is skipped. > > hva->gpa translation is not supposed to be changed by kvm. > > > > The motivation isn't performance, it's to ensure that cmpxchg_gpte() > > > operates on the same address as we read it from. > > > > OK, my objection is direct get_user_pages_fast usage. Please pass gfn to > > gfn_to_page. > > We do get_user() in read_gpte(). That is equivalent to > get_user_pages(). So we already broke that layer of abstraction. At first, I broke hva_to_pfn() into two functions: hva_to_page hva_to_pfn and used the former to get the page. But after making that patch, I thought it might be a bit extra to do such things in the function which is doing low level page manipulations like kmapping. Actually, we are already assuming that the page returned by gfn_to_page is always a usual page which contains gptes without extra checks. Which way do you like the best? Takuya