From: Jason Gunthorpe <jgg@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>, <linux-mm@kvack.org>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Ira Weiny <ira.weiny@intel.com>, Jan Kara <jack@suse.cz>,
John Hubbard <jhubbard@nvidia.com>
Subject: [PATCH rc] mm/gup: use unpin_user_pages() in check_and_migrate_cma_pages()
Date: Fri, 30 Oct 2020 13:32:28 -0300 [thread overview]
Message-ID: <0-v1-976effcd4468+d4-gup_cma_fix_jgg@nvidia.com> (raw)
When FOLL_PIN is passed to __get_user_pages() the page list must be put
back using unpin_user_pages() otherwise the page pin reference persists in
a corrupted state.
Cc: <stable@kernel.org>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Fixes: 3faa52c03f44 ("mm/gup: track FOLL_PIN pages")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
mm/gup.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
I don't have any way to test CMA stuff, this was noticed by inspection.
diff --git a/mm/gup.c b/mm/gup.c
index 1bb349e5ed212a..2e26757f3c9276 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1630,8 +1630,11 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm,
/*
* drop the above get_user_pages reference.
*/
- for (i = 0; i < nr_pages; i++)
- put_page(pages[i]);
+ if (gup_flags & FOLL_PIN)
+ unpin_user_pages(pages, nr_pages);
+ else
+ for (i = 0; i < nr_pages; i++)
+ put_page(pages[i]);
if (migrate_pages(&cma_page_list, alloc_migration_target, NULL,
(unsigned long)&mtc, MIGRATE_SYNC, MR_CONTIG_RANGE)) {
--
2.28.0
next reply other threads:[~2020-10-30 16:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 16:32 Jason Gunthorpe [this message]
2020-10-30 20:50 ` Ira Weiny
2020-10-30 21:39 ` John Hubbard
2020-10-30 23:58 ` Jason Gunthorpe
2020-11-02 18:54 ` Ira Weiny
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=0-v1-976effcd4468+d4-gup_cma_fix_jgg@nvidia.com \
--to=jgg@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=jhubbard@nvidia.com \
--cc=linux-mm@kvack.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox