On Tue, Aug 06, 2024 at 04:29:34PM +0100, Ryan Roberts wrote: > >> Elsewhere in the file, this pattern is used: > >> > >> if (folio_test_hwpoison(folio) || > >> (folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) { > > > > Ugh. The hwpoison stuff is too complicated. Because that's wrong too. > > It should be ... > > > > if (folio_test_large(folio) && folio_test_has_hwpoisoned(folio) || > > !folio_test_large(folio) && folio_test_hwpoison(folio)) > > Err... I clearly don't understand it properly. I guess you sometimes want to > know if any page in the folio is poisioned, and sometimes if a specific page is > poisoned? So > > // returns true if any page in the folio is hwpoisoned. > // works for any folio (large or small). > folio_test_hwpoison(folio); > > // returns true if the page at index within folio is hwpoisoned. > // works for any folio (large or small). > // BUGs if index out of range. > folio_test_hwpoison_page(folio, index); > > Why isn't this the right interface? Why do we have a function that takes a folio > but is only correct to call if the folio is large? Well, quite. That would be a sane interface, although I think I'm fine with leaving PageHWPoison(folio_page(folio, idx)) as the second API. As always, HugeTLB makes things complicated. I need to finish rebasing on current -next and then I'll work up a patch.