From: Lorenzo Stoakes <lstoakes@gmail.com> To: linux-mm@kvack.org Cc: "Linus Torvalds" <torvalds@linux-foundation.org>, "Michal Hocko" <mhocko@kernel.org>, "Jan Kara" <jack@suse.cz>, "Hugh Dickins" <hughd@google.com>, "Dave Hansen" <dave.hansen@linux.intel.com>, "Rik van Riel" <riel@redhat.com>, "Mel Gorman" <mgorman@techsingularity.net>, "Andrew Morton" <akpm@linux-foundation.org>, "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com>, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Lorenzo Stoakes" <lstoakes@gmail.com> Subject: [PATCH] mm: remove unnecessary __get_user_pages_unlocked() calls Date: Wed, 26 Oct 2016 00:36:09 +0100 [thread overview] Message-ID: <20161025233609.5601-1-lstoakes@gmail.com> (raw) 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. Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com> --- virt/kvm/async_pf.c | 7 ++++--- virt/kvm/kvm_main.c | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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; -- 2.10.1
WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Stoakes <lstoakes@gmail.com> To: linux-mm@kvack.org Cc: "Linus Torvalds" <torvalds@linux-foundation.org>, "Michal Hocko" <mhocko@kernel.org>, "Jan Kara" <jack@suse.cz>, "Hugh Dickins" <hughd@google.com>, "Dave Hansen" <dave.hansen@linux.intel.com>, "Rik van Riel" <riel@redhat.com>, "Mel Gorman" <mgorman@techsingularity.net>, "Andrew Morton" <akpm@linux-foundation.org>, "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com>, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Lorenzo Stoakes" <lstoakes@gmail.com> Subject: [PATCH] mm: remove unnecessary __get_user_pages_unlocked() calls Date: Wed, 26 Oct 2016 00:36:09 +0100 [thread overview] Message-ID: <20161025233609.5601-1-lstoakes@gmail.com> (raw) 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. Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com> --- virt/kvm/async_pf.c | 7 ++++--- virt/kvm/kvm_main.c | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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; -- 2.10.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2016-10-25 23:36 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-10-25 23:36 Lorenzo Stoakes [this message] 2016-10-25 23:36 ` [PATCH] mm: remove unnecessary __get_user_pages_unlocked() calls Lorenzo Stoakes 2016-10-25 23:46 ` Lorenzo Stoakes 2016-10-25 23:46 ` Lorenzo Stoakes 2016-10-26 9:15 ` Michal Hocko 2016-10-26 9:15 ` Michal Hocko 2016-10-26 9:39 ` Lorenzo Stoakes 2016-10-26 9:39 ` Lorenzo Stoakes 2016-10-26 9:54 ` Michal Hocko 2016-10-26 9:54 ` Michal Hocko 2016-10-26 7:59 ` Lorenzo Stoakes 2016-10-26 7:59 ` Lorenzo Stoakes 2016-10-26 9:07 ` Michal Hocko 2016-10-26 9:07 ` Michal Hocko 2016-10-26 9:12 ` Michal Hocko 2016-10-26 9:12 ` Michal Hocko 2016-10-26 9:25 ` [PATCH v2] " Lorenzo Stoakes 2016-10-26 9:25 ` Lorenzo Stoakes 2016-10-27 0:12 ` Andrew Morton 2016-10-27 0:12 ` Andrew Morton 2016-10-27 7:06 ` Lorenzo Stoakes 2016-10-27 7:06 ` Lorenzo Stoakes 2016-10-27 9:27 ` Paolo Bonzini 2016-10-27 9:27 ` Paolo Bonzini 2016-10-27 9:32 ` Lorenzo Stoakes 2016-10-27 9:32 ` Lorenzo Stoakes 2016-10-27 9:35 ` Paolo Bonzini 2016-10-27 9:35 ` Paolo Bonzini
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20161025233609.5601-1-lstoakes@gmail.com \ --to=lstoakes@gmail.com \ --cc=akpm@linux-foundation.org \ --cc=dave.hansen@linux.intel.com \ --cc=hughd@google.com \ --cc=jack@suse.cz \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mgorman@techsingularity.net \ --cc=mhocko@kernel.org \ --cc=pbonzini@redhat.com \ --cc=riel@redhat.com \ --cc=rkrcmar@redhat.com \ --cc=torvalds@linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.