From: David Hildenbrand <david@redhat.com>
To: Vivek Kasireddy <vivek.kasireddy@intel.com>,
dri-devel@lists.freedesktop.org, linux-mm@kvack.org
Cc: Matthew Wilcox <willy@infradead.org>,
Christoph Hellwig <hch@infradead.org>,
Jason Gunthorpe <jgg@nvidia.com>, Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH v13 2/8] mm/gup: Introduce check_and_migrate_movable_folios()
Date: Fri, 5 Apr 2024 11:19:32 +0200 [thread overview]
Message-ID: <a8b536ca-0882-4e13-9681-4ff2f1d2a7d9@redhat.com> (raw)
In-Reply-To: <20240404073053.3073706-3-vivek.kasireddy@intel.com>
On 04.04.24 09:26, Vivek Kasireddy wrote:
> This helper is the folio equivalent of check_and_migrate_movable_pages().
> Therefore, all the rules that apply to check_and_migrate_movable_pages()
> also apply to this one as well. Currently, this helper is only used by
> memfd_pin_folios().
>
> This patch also includes changes to rename and convert the internal
> functions collect_longterm_unpinnable_pages() and
> migrate_longterm_unpinnable_pages() to work on folios. As a result,
> check_and_migrate_movable_pages() is now a wrapper around
> check_and_migrate_movable_folios().
>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Jason Gunthorpe <jgg@nvidia.com>
> Cc: Peter Xu <peterx@redhat.com>
> Suggested-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> ---
[...]
> +/*
> + * Check whether all folios are *allowed* to be pinned indefinitely (longterm).
> + * Rather confusingly, all folios in the range are required to be pinned via
> + * FOLL_PIN, before calling this routine.
> + *
> + * If any folios in the range are not allowed to be pinned, then this routine
> + * will migrate those folios away, unpin all the folios in the range and return
> + * -EAGAIN. The caller should re-pin the entire range with FOLL_PIN and then
> + * call this routine again.
> + *
> + * If an error other than -EAGAIN occurs, this indicates a migration failure.
> + * The caller should give up, and propagate the error back up the call stack.
> + *
> + * If everything is OK and all folios in the range are allowed to be pinned,
> + * then this routine leaves all folios pinned and returns zero for success.
> + */
> +static long check_and_migrate_movable_folios(unsigned long nr_folios,
> + struct folio **folios)
> +{
> + unsigned long collected;
> + LIST_HEAD(movable_folio_list);
> +
> + collected = collect_longterm_unpinnable_folios(&movable_folio_list,
> + nr_folios, folios);
> + if (!collected)
> + return 0;
> +
> + return migrate_longterm_unpinnable_folios(&movable_folio_list,
> + nr_folios, folios);
> +}
> +
> /*
> * Check whether all pages are *allowed* to be pinned. Rather confusingly, all
> * pages in the range are required to be pinned via FOLL_PIN, before calling
Likely we should just drop that comment and refer to
check_and_migrate_movable_folios() instead. No need to duplicate all that.
> @@ -2555,16 +2585,20 @@ static int migrate_longterm_unpinnable_pages(
> static long check_and_migrate_movable_pages(unsigned long nr_pages,
> struct page **pages)
> {
> - unsigned long collected;
> - LIST_HEAD(movable_page_list);
> + struct folio **folios;
> + long i, ret;
>
> - collected = collect_longterm_unpinnable_pages(&movable_page_list,
> - nr_pages, pages);
> - if (!collected)
> - return 0;
> + folios = kmalloc_array(nr_pages, sizeof(*folios), GFP_KERNEL);
> + if (!folios)
> + return -ENOMEM;
>
> - return migrate_longterm_unpinnable_pages(&movable_page_list, nr_pages,
> - pages);
> + for (i = 0; i < nr_pages; i++)
> + folios[i] = page_folio(pages[i]);
I wonder if we have to handle pages[i] being NULL. Hopefully not :)
Looks straight forward now:
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-04-05 9:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 7:26 [PATCH v13 0/8] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios Vivek Kasireddy
2024-04-04 7:26 ` [PATCH v13 1/8] mm/gup: Introduce unpin_folio/unpin_folios helpers Vivek Kasireddy
2024-04-04 7:26 ` [PATCH v13 2/8] mm/gup: Introduce check_and_migrate_movable_folios() Vivek Kasireddy
2024-04-05 9:19 ` David Hildenbrand [this message]
2024-04-04 7:26 ` [PATCH v13 3/8] mm/gup: Introduce memfd_pin_folios() for pinning memfd folios Vivek Kasireddy
2024-04-04 7:26 ` [PATCH v13 4/8] udmabuf: Use vmf_insert_pfn and VM_PFNMAP for handling mmap Vivek Kasireddy
2024-04-04 7:26 ` [PATCH v13 5/8] udmabuf: Add back support for mapping hugetlb pages Vivek Kasireddy
2024-04-04 7:26 ` [PATCH v13 6/8] udmabuf: Convert udmabuf driver to use folios Vivek Kasireddy
2024-04-04 7:26 ` [PATCH v13 7/8] udmabuf: Pin the pages using memfd_pin_folios() API Vivek Kasireddy
2024-04-04 7:26 ` [PATCH v13 8/8] selftests/udmabuf: Add tests to verify data after page migration Vivek Kasireddy
2024-04-04 20:53 ` Shuah Khan
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=a8b536ca-0882-4e13-9681-4ff2f1d2a7d9@redhat.com \
--to=david@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hch@infradead.org \
--cc=jgg@nvidia.com \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=vivek.kasireddy@intel.com \
--cc=willy@infradead.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