hugetlb: do not demote poisoned hugetlb pages
authorMike Kravetz <mike.kravetz@oracle.com>
Fri, 15 Apr 2022 02:13:52 +0000 (19:13 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Apr 2022 21:49:55 +0000 (14:49 -0700)
commit5a317412ef884763fdf7aa17f9f3636959d11d8f
tree28d3f08cd0e8a61139d2cf79fc67d2bc6d22851f
parent31ca72fa7540bb654b55c56adaf99305847376e0
hugetlb: do not demote poisoned hugetlb pages

It is possible for poisoned hugetlb pages to reside on the free lists.
The huge page allocation routines which dequeue entries from the free
lists make a point of avoiding poisoned pages.  There is no such check
and avoidance in the demote code path.

If a hugetlb page on the is on a free list, poison will only be set in
the head page rather then the page with the actual error.  If such a
page is demoted, then the poison flag may follow the wrong page.  A page
without error could have poison set, and a page with poison could not
have the flag set.

Check for poison before attempting to demote a hugetlb page.  Also,
return -EBUSY to the caller if only poisoned pages are on the free list.

Link: https://lkml.kernel.org/r/20220307215707.50916-1-mike.kravetz@oracle.com
Fixes: 8531fc6f52f5 ("hugetlb: add hugetlb demote page support")
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/hugetlb.c