From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
KVM list <kvm@vger.kernel.org>
Subject: Re: [PATCH v5 5/9] KVM: MMU: introduce gfn_to_page_many_atomic() function
Date: Mon, 12 Jul 2010 10:55:49 +0800 [thread overview]
Message-ID: <4C3A8435.4050805@cn.fujitsu.com> (raw)
In-Reply-To: <4C39C030.6080009@redhat.com>
Avi Kivity wrote:
> On 07/06/2010 01:48 PM, Xiao Guangrong wrote:
>> This function not only return the gfn's page but also the page number
>> after @gfn in the slot
>>
>>
>> @@ -923,15 +923,25 @@ static unsigned long gfn_to_hva_memslot(struct
>> kvm_memory_slot *slot, gfn_t gfn)
>> return slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE;
>> }
>>
>> -unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn)
>> +static unsigned long gfn_to_hva_many(struct kvm *kvm, gfn_t gfn, int
>> *entry)
>> {
>>
>
> 'entry' better be gfn_t. We limit gfns in a slot, but that's
> artificial, let's use the correct type.
>
> Also suggest nr_pages as the name.
>
OK, will fix it in the next version.
>> @@ -1011,6 +1021,23 @@ pfn_t gfn_to_pfn_memslot(struct kvm *kvm,
>> return hva_to_pfn(kvm, addr, false);
>> }
>>
>> +int gfn_to_page_many_atomic(struct kvm *kvm, gfn_t gfn,
>> + struct page **pages, int nr_pages, bool *enough)
>> +{
>> + unsigned long addr;
>> + int entry, ret;
>> +
>> + addr = gfn_to_hva_many(kvm, gfn,&entry);
>> + if (kvm_is_error_hva(addr))
>> + return -1;
>> +
>> + entry = min(entry, nr_pages);
>> + *enough = (entry == nr_pages) ? true : false;
>>
>
> s/ ? true : false//; :)
Yeah, it's better.
>
> Why not return 0 if !enough?
>
I think it's better that handle the reset pages in the slot, for example,
we expect 16 pages are consecutive, but only 12 pages in the slot, the better
way is handle the reset 12 pages not throw those away.
>> + ret = __get_user_pages_fast(addr, entry, 1, pages);
>> + return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(gfn_to_page_many_atomic);
>> +
>> struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn)
>> {
>> pfn_t pfn;
>>
>
>
next prev parent reply other threads:[~2010-07-12 2:59 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-06 10:44 [PATCH v5 1/9] KVM: MMU: fix forgot reserved bits check in speculative path Xiao Guangrong
2010-07-06 10:45 ` [PATCH v5 2/9] KVM: MMU: fix race between 'walk_addr' and 'fetch' Xiao Guangrong
2010-07-06 10:46 ` [PATCH v5 3/9] export __get_user_pages_fast() function Xiao Guangrong
2010-07-11 12:52 ` [PATCH v5 2/9] KVM: MMU: fix race between 'walk_addr' and 'fetch' Avi Kivity
2010-07-11 15:40 ` Avi Kivity
2010-07-06 10:47 ` [PATCH v5 4/9] KVM: MMU: introduce gfn_to_pfn_atomic() function Xiao Guangrong
2010-07-06 11:22 ` Gleb Natapov
2010-07-06 11:28 ` Xiao Guangrong
2010-07-09 1:34 ` Xiao Guangrong
2010-07-06 10:48 ` [PATCH v5 5/9] KVM: MMU: introduce gfn_to_page_many_atomic() function Xiao Guangrong
2010-07-11 12:59 ` Avi Kivity
2010-07-12 2:55 ` Xiao Guangrong [this message]
2010-07-12 12:28 ` Avi Kivity
2010-07-13 1:17 ` Xiao Guangrong
2010-07-06 10:49 ` [PATCH v5 6/9] KVM: MMU: introduce pte_prefetch_topup_memory_cache() Xiao Guangrong
2010-07-11 13:05 ` Avi Kivity
2010-07-12 3:05 ` Xiao Guangrong
2010-07-12 12:26 ` Avi Kivity
2010-07-13 1:16 ` Xiao Guangrong
2010-07-13 4:21 ` Avi Kivity
2010-07-13 4:25 ` Xiao Guangrong
2010-07-13 5:35 ` Avi Kivity
2010-07-13 5:48 ` Xiao Guangrong
2010-07-13 6:05 ` Avi Kivity
2010-07-13 6:10 ` Xiao Guangrong
2010-07-13 6:29 ` Avi Kivity
2010-07-13 6:52 ` Xiao Guangrong
2010-07-13 7:45 ` Avi Kivity
2010-07-06 10:50 ` [PATCH v5 7/9] KVM: MMU: prefetch ptes when intercepted guest #PF Xiao Guangrong
2010-07-06 10:51 ` [PATCH v5 8/9] KVM: MMU: combine guest pte read between fetch and pte prefetch Xiao Guangrong
2010-07-06 19:52 ` Marcelo Tosatti
2010-07-07 1:23 ` Xiao Guangrong
2010-07-07 13:07 ` Marcelo Tosatti
2010-07-07 13:11 ` Xiao Guangrong
2010-07-07 13:40 ` Marcelo Tosatti
2010-07-07 14:10 ` Xiao Guangrong
2010-07-07 15:30 ` Marcelo Tosatti
2010-07-06 10:52 ` [PATCH v5 9/9] KVM: MMU: trace " Xiao Guangrong
2010-07-11 12:24 ` [PATCH v5 1/9] KVM: MMU: fix forgot reserved bits check in speculative path Avi Kivity
2010-07-12 2:37 ` Xiao Guangrong
2010-07-12 13:15 ` Avi Kivity
2010-07-13 1:57 ` Xiao Guangrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C3A8435.4050805@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.