From: Alistair Popple <apopple@nvidia.com>
To: John Hubbard <jhubbard@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
akpm@linux-foundation.org, minchan@kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
pasha.tatashin@soleen.com
Subject: Re: [PATCH] mm/gup.c: Simplify and fix check_and_migrate_movable_pages() return codes
Date: Mon, 01 Aug 2022 12:38:05 +1000 [thread overview]
Message-ID: <87sfmgd6l0.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <8f1f3278-ce9e-e328-6a8b-a793bc7f950f@nvidia.com>
John Hubbard <jhubbard@nvidia.com> writes:
> On 7/29/22 12:44, Jason Gunthorpe wrote:
>
>> I came up with this ontop:
>>
> That cleans it up even more, looks nice. I'd go just a touch further,
> and also (unless there is some odd reason?) stay with -EAGAIN rather
> than -EBUSY, because otherwise both the function's comment header, and
> the caller, should change from -EBUSY to -EAGAIN just for consistency.
We return both:
-EBUSY to indicate that we should fail the entire PUP operation. -EAGAIN
to indicate to __gup_longterm_locked() that the pages have been
unpinned and it should repin them and check again.
> And also because the way it's used: the caller is literally "trying
> again".
>
> So on top of the ontop:
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 43c1fc532842..5f04033ee0ed 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1901,10 +1901,12 @@ struct page *get_dump_page(unsigned long addr)
>
> #ifdef CONFIG_MIGRATION
> /*
> - * Check whether all pages are pinnable. If some pages are not pinnable migrate
> - * them and unpin all the pages. Returns -EAGAIN if pages were unpinned or zero
> - * if all pages are pinnable and in the right zone. Other errors indicate
> - * migration failure.
> + * Check whether all pages are pinnable. If some pages are not pinnable, migrate
> + * them and unpin all the pages.
> + * Return values:
> + * 0: all pages are already pinnable and in the right zone
> + * -EAGAIN: some pages were unpinned or were zero
> + * -ENOMEM: migration of some pages failed
> */
> static long check_and_migrate_movable_pages(unsigned long nr_pages,
> struct page **pages,
> @@ -1914,11 +1916,11 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,
> .nid = NUMA_NO_NODE,
> .gfp_mask = GFP_USER | __GFP_NOWARN,
> };
> - unsigned long i;
> + unsigned long i, not_migrated;
> struct folio *prev_folio = NULL;
> LIST_HEAD(movable_page_list);
> bool drain_allow = true, coherent_pages = false;
> - int ret = -EBUSY;
> + int ret = -EAGAIN;
>
> for (i = 0; i < nr_pages; i++) {
> struct folio *folio = page_folio(pages[i]);
> @@ -1990,7 +1992,7 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages,
>
> /*
> * Unpin all pages. If device coherent pages were found
> - * migrate_deivce_coherent_page() will have dropped the pin and set
> + * migrate_device_coherent_page() will have dropped the pin and set
> * pages[i] == NULL.
> */
> for (i = 0; i < nr_pages; i++) {
>
>
> thanks,
next prev parent reply other threads:[~2022-08-01 2:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 2:46 [PATCH] mm/gup.c: Simplify and fix check_and_migrate_movable_pages() return codes Alistair Popple
2022-07-29 19:44 ` Jason Gunthorpe
2022-07-29 21:22 ` John Hubbard
2022-08-01 2:38 ` Alistair Popple [this message]
2022-08-01 2:18 ` Alistair Popple
2022-08-01 2:46 ` Alistair Popple
2022-08-02 12:21 ` Jason Gunthorpe
2022-08-02 12:52 ` Alistair Popple
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=87sfmgd6l0.fsf@nvdebian.thelocal \
--to=apopple@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=pasha.tatashin@soleen.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 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.