Message ID | 20161026092548.12712-1-lstoakes@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> Subject: [PATCH v2] mm: remove unnecessary __get_user_pages_unlocked() calls The patch is rather misidentified. > virt/kvm/async_pf.c | 7 ++++--- > virt/kvm/kvm_main.c | 5 ++--- > 2 files changed, 6 insertions(+), 6 deletions(-) It's a KVM patch and should have been called "kvm: remove ...". Possibly the KVM maintainers will miss it for this reason. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Oct 26, 2016 at 05:12:07PM -0700, Andrew Morton wrote: > It's a KVM patch and should have been called "kvm: remove ...". > Possibly the KVM maintainers will miss it for this reason. > Ah, indeed, however I think given my and Michal's discussion in this thread regarding adjusting get_user_pages_remote() to allow for the unexporting of __get_user_pages_unlocked() it would make more sense for me to batch up this change with that change also (and then in fact actually be an mm patch.) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 27/10/2016 02:12, Andrew Morton wrote: > > >> Subject: [PATCH v2] mm: remove unnecessary __get_user_pages_unlocked() calls > > The patch is rather misidentified. > >> virt/kvm/async_pf.c | 7 ++++--- >> virt/kvm/kvm_main.c | 5 ++--- >> 2 files changed, 6 insertions(+), 6 deletions(-) > > It's a KVM patch and should have been called "kvm: remove ...". > Possibly the KVM maintainers will miss it for this reason. I noticed it, but I confused it with "mm: unexport __get_user_pages()". I'll merge this through the KVM tree for -rc3. Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Oct 27, 2016 at 11:27:24AM +0200, Paolo Bonzini wrote: > > > On 27/10/2016 02:12, Andrew Morton wrote: > > > > > >> Subject: [PATCH v2] mm: remove unnecessary __get_user_pages_unlocked() calls > > > > The patch is rather misidentified. > > > >> virt/kvm/async_pf.c | 7 ++++--- > >> virt/kvm/kvm_main.c | 5 ++--- > >> 2 files changed, 6 insertions(+), 6 deletions(-) > > > > It's a KVM patch and should have been called "kvm: remove ...". > > Possibly the KVM maintainers will miss it for this reason. > > I noticed it, but I confused it with "mm: unexport __get_user_pages()". > > I'll merge this through the KVM tree for -rc3. Actually Paolo could you hold off on this? As I think on reflection it'd make more sense to batch this change up with a change to get_user_pages_remote() as suggested by Michal. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 27/10/2016 11:32, Lorenzo Stoakes wrote: > On Thu, Oct 27, 2016 at 11:27:24AM +0200, Paolo Bonzini wrote: >> >> >> On 27/10/2016 02:12, Andrew Morton wrote: >>> >>> >>>> Subject: [PATCH v2] mm: remove unnecessary __get_user_pages_unlocked() calls >>> >>> The patch is rather misidentified. >>> >>>> virt/kvm/async_pf.c | 7 ++++--- >>>> virt/kvm/kvm_main.c | 5 ++--- >>>> 2 files changed, 6 insertions(+), 6 deletions(-) >>> >>> It's a KVM patch and should have been called "kvm: remove ...". >>> Possibly the KVM maintainers will miss it for this reason. >> >> I noticed it, but I confused it with "mm: unexport __get_user_pages()". >> >> I'll merge this through the KVM tree for -rc3. > > Actually Paolo could you hold off on this? As I think on reflection it'd make > more sense to batch this change up with a change to get_user_pages_remote() as > suggested by Michal. Okay. Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index 8035cc1..e8c832c 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -82,10 +82,11 @@ static void async_pf_execute(struct work_struct *work) /* * This work is run asynchromously to the task which owns * mm and might be done in another context, so we must - * use FOLL_REMOTE. + * access remotely. */ - __get_user_pages_unlocked(NULL, mm, addr, 1, NULL, - FOLL_WRITE | FOLL_REMOTE); + down_read(&mm->mmap_sem); + get_user_pages_remote(NULL, mm, addr, 1, FOLL_WRITE, NULL, NULL); + up_read(&mm->mmap_sem); kvm_async_page_present_sync(vcpu, apf); diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2907b7b..c45d951 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1415,13 +1415,12 @@ static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault, npages = get_user_page_nowait(addr, write_fault, page); up_read(¤t->mm->mmap_sem); } else { - unsigned int flags = FOLL_TOUCH | FOLL_HWPOISON; + unsigned int flags = FOLL_HWPOISON; if (write_fault) flags |= FOLL_WRITE; - npages = __get_user_pages_unlocked(current, current->mm, addr, 1, - page, flags); + npages = get_user_pages_unlocked(addr, 1, page, flags); } if (npages != 1) return npages;
In hva_to_pfn_slow() we are able to replace __get_user_pages_unlocked() with get_user_pages_unlocked() since we can now pass gup_flags. In async_pf_execute() we need to pass different tsk, mm arguments so get_user_pages_remote() is the sane replacement here (having added manual acquisition and release of mmap_sem.) Since we pass a NULL pages parameter the subsequent call to __get_user_pages_locked() will have previously bailed any attempt at VM_FAULT_RETRY, so we do not change this behaviour by using get_user_pages_remote() which does not invoke VM_FAULT_RETRY logic at all. Additionally get_user_pages_remote() reintroduces use of the FOLL_TOUCH flag. However, this flag was originally silently dropped by 1e9877902dc7e ("mm/gup: Introduce get_user_pages_remote()"), so this appears to have been unintentional and reintroducing it is therefore not an issue. Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com> --- v2: update description to reference dropped FOLL_TOUCH flag virt/kvm/async_pf.c | 7 ++++--- virt/kvm/kvm_main.c | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) -- 2.10.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html