lkml.org 
[lkml]   [2022]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v4 2/2] mm/gup.c: Refactor check_and_migrate_movable_pages()
From
On 8/17/22 05:09, Jason Gunthorpe wrote:
>>> if (!ret) == if (ret != 0)
>>
>> Huh? Unless I'm misinterpretting you or am really behind on coffee
>> if (!ret) is equivalent to if (ret == 0), not if (ret != 0).

Although the !ret idiom is a huge, huge part of kernel coding practice,
it also adds a slight bit of unnecessary mental translation (go ahead,
flame me hard, I know I'm asking for it...but...see above, after all.
Pixels have been spilt working through it).

And also...

>
> Oh Dear, maybe I am still a bit jetlagged
>
> Regardless, it is confusingly written :)
>

...this is a slightly tricky and unusual error case, so it helps to be
extra clear by comparing against zero, and even adding a few short comments.

How's this look to you:

collected = collect_longterm_unpinnable_pages(&movable_page_list,
nr_pages, pages);
if (collected == 0)
return 0;

ret = migrate_longterm_unpinnable_pages(&movable_page_list, nr_pages,
pages);

/* If we got here, we have some unpinnable pages... */

if (ret == 0) {
/*
* ...and we successfully migrated those pages. Which means that
* the caller should retry the operation now.
*/
ret = -EAGAIN;
}

return ret;


thanks,
--
John Hubbard
NVIDIA

\
 
 \ /
  Last update: 2022-08-17 22:37    [W:0.050 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site