From: Vivek Kasireddy <vivek.kasireddy@intel.com>
To: dri-devel@lists.freedesktop.org, linux-mm@kvack.org
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>,
David Hildenbrand <david@redhat.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Mike Kravetz <mike.kravetz@oracle.com>,
Hugh Dickins <hughd@google.com>, Peter Xu <peterx@redhat.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Dongwon Kim <dongwon.kim@intel.com>,
Junxiao Chang <junxiao.chang@intel.com>
Subject: [PATCH v1 1/3] mm/gup: Export check_and_migrate_movable_pages()
Date: Wed, 16 Aug 2023 23:49:32 -0700 [thread overview]
Message-ID: <20230817064934.3424431-2-vivek.kasireddy@intel.com> (raw)
In-Reply-To: <20230817064934.3424431-1-vivek.kasireddy@intel.com>
For drivers that would like to migrate pages out of the movable
zone (or CMA) in order to pin them (longterm) for DMA, using
check_and_migrate_movable_pages() directly provides a convenient
option instead of duplicating similar checks (e.g, checking
the folios for zone, hugetlb, etc) and calling migrate_pages()
directly.
Ideally, a driver is expected to call pin_user_pages(FOLL_LONGTERM)
to migrate and pin the pages for longterm DMA but there are
situations where the GUP APIs cannot be used directly for
various reasons (e.g, when the VMA or start addr cannot be
easily determined but the relevant pages are available).
Cc: David Hildenbrand <david@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Junxiao Chang <junxiao.chang@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
include/linux/mm.h | 2 ++
mm/gup.c | 9 +++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 406ab9ea818f..81871ffd3ff9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1547,6 +1547,8 @@ void unpin_user_pages_dirty_lock(struct page **pages, unsigned long npages,
void unpin_user_page_range_dirty_lock(struct page *page, unsigned long npages,
bool make_dirty);
void unpin_user_pages(struct page **pages, unsigned long npages);
+long check_and_migrate_movable_pages(unsigned long nr_pages,
+ struct page **pages);
static inline bool is_cow_mapping(vm_flags_t flags)
{
diff --git a/mm/gup.c b/mm/gup.c
index 76d222ccc3ff..18beda89fcf3 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2141,8 +2141,8 @@ static int migrate_longterm_unpinnable_pages(
* If everything is OK and all pages in the range are allowed to be pinned, then
* this routine leaves all pages pinned and returns zero for success.
*/
-static long check_and_migrate_movable_pages(unsigned long nr_pages,
- struct page **pages)
+long check_and_migrate_movable_pages(unsigned long nr_pages,
+ struct page **pages)
{
unsigned long collected;
LIST_HEAD(movable_page_list);
@@ -2156,12 +2156,13 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,
pages);
}
#else
-static long check_and_migrate_movable_pages(unsigned long nr_pages,
- struct page **pages)
+long check_and_migrate_movable_pages(unsigned long nr_pages,
+ struct page **pages)
{
return 0;
}
#endif /* CONFIG_MIGRATION */
+EXPORT_SYMBOL(check_and_migrate_movable_pages);
/*
* __gup_longterm_locked() is a wrapper for __get_user_pages_locked which
--
2.39.2
next prev parent reply other threads:[~2023-08-17 7:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-17 6:49 [PATCH v1 0/3] udmabuf: Add support for page migration out of movable zone or CMA Vivek Kasireddy
2023-08-17 6:49 ` Vivek Kasireddy [this message]
2023-08-30 14:15 ` [PATCH v1 1/3] mm/gup: Export check_and_migrate_movable_pages() Christoph Hellwig
2023-08-17 6:49 ` [PATCH v1 2/3] udmabuf: Add support for page migration out of movable zone or CMA Vivek Kasireddy
2023-08-17 6:49 ` [PATCH v1 3/3] selftests/dma-buf/udmabuf: Add tests to verify data after page migration Vivek Kasireddy
2023-08-17 15:01 ` [PATCH v1 0/3] udmabuf: Add support for page migration out of movable zone or CMA Jason Gunthorpe
2023-08-22 5:36 ` Kasireddy, Vivek
2023-08-22 12:23 ` Jason Gunthorpe
2023-08-23 9:34 ` David Hildenbrand
2023-08-24 6:31 ` Kasireddy, Vivek
2023-08-24 18:30 ` David Hildenbrand
2023-08-24 18:30 ` Jason Gunthorpe
2023-08-24 18:33 ` David Hildenbrand
2023-08-25 17:29 ` Jason Gunthorpe
2023-08-27 18:49 ` Kasireddy, Vivek
2023-08-27 19:05 ` Kasireddy, Vivek
2023-08-30 17:30 ` Jason Gunthorpe
2023-09-14 13:43 ` David Hildenbrand
2023-09-16 18:31 ` Kasireddy, Vivek
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=20230817064934.3424431-2-vivek.kasireddy@intel.com \
--to=vivek.kasireddy@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=david@redhat.com \
--cc=dongwon.kim@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hughd@google.com \
--cc=jgg@nvidia.com \
--cc=junxiao.chang@intel.com \
--cc=kraxel@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=peterx@redhat.com \
/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