lkml.org 
[lkml]   [2012]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/4] KVM: MMU: Make kvm_handle_hva() handle range of addresses
On 06/19/2012 04:46 PM, Takuya Yoshikawa wrote:
> On Mon, 18 Jun 2012 15:11:42 +0300
> Avi Kivity <avi@redhat.com> wrote:
>
>> Potential for improvement: don't do 512 iterations on same large page.
>>
>> Something like
>>
>> if ((gfn ^ prev_gfn) & mask(level))
>> ret |= handler(...)
>>
>> with clever selection of the first prev_gfn so it always matches (~gfn
>> maybe).
>
>
> I thought up a better solution:
>
> 1. Separate rmap_pde from lpage_info->write_count and
> make this a simple array. (I once tried this.)
>

This has the potential to increase cache misses, but I don't think it's
a killer. The separation can simplify other things as well.


> 2. Use gfn_to_index() and loop over rmap array:
> ...
> /* intersection check */
> start = max(start, memslot->userspace_addr);
> end = min(end, memslot->userspace_addr +
> (memslot->npages << PAGE_SHIFT));
> if (start > end)
> continue;
>
> /* hva to gfn conversion */
> gfn_start = hva_to_gfn_memslot(start);
> gfn_end = hva_to_gfn_memslot(end);
>
> /* main part */
> for each level {
> rmapp = __gfn_to_rmap(gfn_start, level, memslot);
> for (idx = gfn_to_index(gfn_start, memslot->base_gfn, level);
> idx < gfn_to_index(gfn_end, memslot->base_gfn, level); idx++) {
> ...
> /* loop over rmap array */
> ret |= handler(kvm, rmapp + idx, data);
> }
> }
>

Probably want idx <= gfn_to_index(gfn_end-1, ...) otherwise we fail on
small slots.

--
error compiling committee.c: too many arguments to function




\
 
 \ /
  Last update: 2012-06-21 11:01    [W:0.054 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site