On 4/26/2024 12:05 PM, Matthew Wilcox wrote:Besides, in a possible hugetlb demote scenario, it seems to me that we should retry
[..]
That would be unsafe, the safe way would be if we moved page_folio() afterthe call to __get_hw_poison() in get_any_page() and there would still be oneI think we should convert __get_hwpoison_page() to return either the folio
remaining user of shake_page() that we can't convert. A safe version of this
patch would result in a removal of one use of PageHuge() and two uses of
put_page(), would that be worth submitting?
get_any_page()
if(__get_hwpoison_page())
folio = page_folio() /* folio_try_get() returned 1, safe */
or an ERR_PTR or NULL. Also, I think we should delete the "cannot catch
tail" part and just loop in __get_hwpoison_page() until we do catch it.
See try_get_folio() in mm/gup.c for inspiration (although you can't use
it exactly because that code knows that the page is mapped into a page
table, so has a refcount).
But that's just an immediate assessment; you might find a reason that
doesn't work.