Messages in this thread | | | Date | Wed, 17 Aug 2022 13:35:12 -0700 | Subject | Re: [PATCH v4 2/2] mm/gup.c: Refactor check_and_migrate_movable_pages() | From | John Hubbard <> |
| |
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
| |