[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f90a2900-74a6-4264-9bf6-2f8d51d21980@nvidia.com>
Date: Wed, 16 Oct 2024 15:22:52 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Alistair Popple <apopple@...dia.com>
CC: Andrew Morton <akpm@...ux-foundation.org>, LKML
<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>, Shigeru Yoshida
<syoshida@...hat.com>, David Hildenbrand <david@...hat.com>, Jason Gunthorpe
<jgg@...dia.com>, Minchan Kim <minchan@...nel.org>, Pasha Tatashin
<pasha.tatashin@...een.com>
Subject: Re: [PATCH] mm/gup: stop leaking pinned pages in low memory
conditions
On 10/16/24 3:13 PM, Alistair Popple wrote:
> John Hubbard <jhubbard@...dia.com> writes:
...
>> diff --git a/mm/gup.c b/mm/gup.c
>> index a82890b46a36..24acf53c8294 100644
>> --- a/mm/gup.c
>> +++ b/mm/gup.c
>> @@ -2492,6 +2492,17 @@ static long __gup_longterm_locked(struct mm_struct *mm,
>>
>> /* FOLL_LONGTERM implies FOLL_PIN */
>> rc = check_and_migrate_movable_pages(nr_pinned_pages, pages);
>> +
>> + /*
>> + * The __get_user_pages_locked() call happens before we know
>> + * that whether it's possible to successfully complete the whole
>> + * operation. To compensate for this, if we get an unexpected
>> + * error (such as -ENOMEM) then we must unpin everything, before
>> + * erroring out.
>> + */
>> + if (rc != -EAGAIN && rc != 0)
>> + unpin_user_pages(pages, nr_pinned_pages);
>
> I know this is going to fall out of the loop in the next line but given
> this is an error handling case it would be nice if this was made
> explicit here with a break statement. It looks correct to me though so:
Yes, I'm not sure that adding another line of code for cosmetics really
makes this better. At this point, smaller is better IMHO, and then the
next step should be something bigger, such as refactoring to avoid the
tri-state return codes.
>
> Reviewed-by: Alistair Popple <apopple@...dia.com>
Thanks for the super fast response and the review!
thanks,
--
John Hubbard
Powered by blists - more mailing lists