lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 17 Aug 2022 13:35:12 -0700 From: John Hubbard <jhubbard@...dia.com> To: Jason Gunthorpe <jgg@...dia.com>, Alistair Popple <apopple@...dia.com> Cc: linux-mm@...ck.org, akpm@...ux-foundation.org, linux-kernel@...r.kernel.org, "Sierra Guiza, Alejandro (Alex)" <alex.sierra@....com>, Chaitanya Kulkarni <kch@...dia.com>, Dan Williams <dan.j.williams@...el.com>, Felix Kuehling <Felix.Kuehling@....com>, Logan Gunthorpe <logang@...tatee.com>, Miaohe Lin <linmiaohe@...wei.com>, Muchun Song <songmuchun@...edance.com>, Ralph Campbell <rcampbell@...dia.com>, David Hildenbrand <david@...hat.com>, Matthew Wilcox <willy@...radead.org> Subject: Re: [PATCH v4 2/2] mm/gup.c: Refactor check_and_migrate_movable_pages() 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
Powered by blists - more mailing lists