Re: [PATCH 2/3] KVM: MMU: Improve iteration over sptes linked by rmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Avi Kivity <avi@xxxxxxxxxx> wrote:

> > + * Iteration must be started by this function.  This should also be used after
> > + * removing/dropping sptes from rmap because in such cases the information in
> > + * the itererator may not be valid.
> 
> Note: this suggests rmap_remove(struct rmap_iterator *ri) to remove an
> rmap from the iterator while keeping it valid.  Converts a potentially
> quadratic kvm_mmu_rmap_write_protect() to linear.

Yes, but a bit scary because we need to touch drop_spte() and so on.

Actually drop_spte() itself should be changed to take rmap as an argument to
avoid recalculating it from sp.

I personally do not like current rmap_* interface.  We should think of
a better design for the future.

> > +static bool rmap_get_first(unsigned long rmap, struct rmap_iterator *iter)
> > +{
> > +	if (!rmap) {
> > +		iter->sptep = NULL;
> > +		return false;
> > +	}
> > +
> > +	if (!(rmap & 1)) {
> > +		iter->sptep = (u64 *)rmap;
> > +		iter->desc = NULL;
> > +	} else {
> > +		iter->desc = (struct pte_list_desc *)(rmap & ~1ul);
> > +		iter->pos = 0;
> > +		iter->sptep = iter->desc->sptes[iter->pos];
> > +	}
> > +
> > +	return true;
> > +}
> 
> Might be simplified to return the sptep or NULL; so you don't have to
> copy it to the iterator.

while ((spte = rmap_...)) or for (rmap_...; iter.sptep; ...)

Will think again!

	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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux