On 11/4/19 1:15 PM, Jason Gunthorpe wrote: ...
Right, and I thought about this when converting, and realized that the above code is working around the current gup.c limitations, which are "cannot support gup remote with FOLL_LONGTERM".
But AFAICT it doesn't have a problem, the protection test is just too strict, and I guess the control flow needs a bit of fixing..
The issue is this:
static __always_inline long __get_user_pages_locked(): { if (locked) { /* if VM_FAULT_RETRY can be returned, vmas become invalid */ BUG_ON(vmas); /* check caller initialized locked */ BUG_ON(*locked != 1); }
so remote could be written as:
if (gup_flags & FOLL_LONGTERM) { if (WARN_ON_ONCE(locked)) return -EINVAL; return __gup_longterm_locked(...) }
return __get_user_pages_locked(...)
??
Yes, that loosens it up just enough for the vfio case (which doesn't set "locked") to get through, great! OK, I'll put that (the above plus corresponding vfio fix) in a separate patch first.
This should clear things up nicely.
thanks,