Re: [patch 3/5] KVM: add kvm_follow_page()

Andrew Morton
2007-12-23T10:52:45Z

On Sun, 23 Dec 2007 12:35:30 +0200 Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:

> Andrew Morton wrote:
> > On Sun, 23 Dec 2007 10:59:22 +0200 Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> >
> >
> >> Avi Kivity wrote:
> >>
> >>> Avi Kivity wrote:
> >>>
> >>>
> >>>> Exactly. But it is better to be explicit about it and pass the page
> >>>> directly like you did before. I hate to make you go back-and-fourth,
> >>>> but I did not understand the issue completely before.
> >>>>
> >>>>
> >>>>
> >>> btw, the call to gfn_to_page() can happen in page_fault() instead of
> >>> walk_addr(); that will reduce the amount of error handling, and will
> >>> simplify the callers to walk_addr() that don't need the page.
> >>>
> >>>
> >>>
> >> Note further that all this doesn't obviate the need for follow_page()
> >> (or get_user_pages_inatomic()); we still need something in update_pte()
> >> for the demand paging case.
> >>
> >
> > Please review -mm's mm/pagewalk.c for suitability.
> >
> > If is is unsuitable but repairable then please cc Matt Mackall
> > <mpm-VDJrAJ4Gl5ZBDgjK7y7TUQ@public.gmane.org> on the review.
> >
> >
>
> The "no locks are taken" comment is very worrying. We need accurate
> results.

take down_read(mm->mmap_sem) before calling it..

You have to do that anyway for its results to be meaningful in the caller.
Ditto get_user_pages().

> Getting pte_t's in the callbacks is a little too low level for kvm's use
> (which wants struct page pointers) but of course that easily handled in
> a kvm wrapper.
>
> I'd prefer an atomic version of get_user_pages(), but if pagewalk is
> fixed to take the necessary locks, it will do.

It isn't exported to modules at present, although I see no problem in
changing that.