From: Jason Gunthorpe <jgg@nvidia.com>
To: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
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>,
Gerd Hoffmann <kraxel@redhat.com>,
"Kim, Dongwon" <dongwon.kim@intel.com>,
"Chang, Junxiao" <junxiao.chang@intel.com>
Subject: Re: [PATCH v1 0/3] udmabuf: Add support for page migration out of movable zone or CMA
Date: Tue, 22 Aug 2023 09:23:53 -0300 [thread overview]
Message-ID: <ZOSo2cuw1ashK3+Z@nvidia.com> (raw)
In-Reply-To: <IA0PR11MB7185ABFBB06771B7646F8F50F81FA@IA0PR11MB7185.namprd11.prod.outlook.com>
On Tue, Aug 22, 2023 at 05:36:56AM +0000, Kasireddy, Vivek wrote:
> Hi Jason,
>
> > > This patch series adds support for migrating pages associated with
> > > a udmabuf out of the movable zone or CMA to avoid breaking features
> > > such as memory hotunplug.
> > >
> > > The first patch exports check_and_migrate_movable_pages() function
> > > out of GUP so that the udmabuf driver can leverage it for page
> > > migration that is done as part of the second patch. The last patch
> > > adds two new udmabuf selftests to verify data coherency after
> > > page migration.
> >
> > Please don't do this. If you want to do what GUP does then call
> > GUP. udmabuf is not so special that it needs to open code its own
> > weird version of it.
> We can't call GUP directly as explained in the first patch of this series:
> "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)."
>
> Given the current (model and) UAPI (udmabuf_create), the userspace
> only shares (memfd, offset, size) values that we use to find the
> relevant pages and pin them (by doing get_page()). Since the goal
> is to also migrate these pages, I think we have the following options:
This seems like a bad choice of uAPI - we don't have any kernel
support for pinning from a memfd. If you want this then you have to
build this as generic code, not open code it into udmabuf.
> - Leverage check_and_migrate_movable_pages(); but this function
> needs to be exported from GUP.
GUP has many behaviors, we keep adding more, these functions should
not leak out of the mm core code into drivers.
> - Iterate over all the pages (in udmabuf) to check for folio_is_longterm_pinnable()
> and call migrate_pages() eventually. This requires changes only to
> the udmabuf driver but we'd be duplicating much of the functionality
> provided by check_and_migrate_movable_pages().
Definately not
> - Call pin_user_pages_fast(FOLL_LONGTERM) from udmabuf driver. In
> order to do this, we have to first unpin all pages and iterate over all
> the VMAs of the VMM to identify the Guest RAM VMA and then use
> page_address_in_vma() to find the start addr of the ranges and then
> call GUP. Although this approach is feasible, it feels a bit convoluted.
Userspace should have told the kernel where the memfd is mapped.
> - Add a new udmabuf UAPI to have userspace share (start addr, len) values
> so that the udmabuf driver can directly call GUP APIs. But this means all
> the current users of udmabuf such as Qemu, CrosVM, etc, need to be
> updated to use the new UAPI.
There you go
> - Add a new API to the backing store/allocator to longterm-pin the page.
> For example, something along the lines of shmem_pin_mapping_page_longterm()
> for shmem as suggested by Daniel. A similar one needs to be added for
> hugetlbfs as well.
This may also be reasonable.
Jason
next prev parent reply other threads:[~2023-08-22 12:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-17 6:49 Vivek Kasireddy
2023-08-17 6:49 ` [PATCH v1 1/3] mm/gup: Export check_and_migrate_movable_pages() Vivek Kasireddy
2023-08-30 14:15 ` 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 [this message]
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=ZOSo2cuw1ashK3+Z@nvidia.com \
--to=jgg@nvidia.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=junxiao.chang@intel.com \
--cc=kraxel@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=peterx@redhat.com \
--cc=vivek.kasireddy@intel.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