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