On Mon, 18 Jun 2012 15:11:42 +0300 Avi Kivity <avi@xxxxxxxxxx> 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.) 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); } } Thanks, Takuya -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html