mm: fix unexpected changes to {failslab|fail_page_alloc}.attr

When we specify __GFP_NOWARN, we only expect that no warnings will be
issued for current caller.  But in the __should_failslab() and
__should_fail_alloc_page(), the local GFP flags alter the global
{failslab|fail_page_alloc}.attr, which is persistent and shared by all
tasks.  This is not what we expected, let's fix it.

[ unexport should_fail_ex()]
Fixes: 3f913fc5f974 ("mm: fix missing handler for __GFP_NOWARN")
Signed-off-by: Qi Zheng <>
Reported-by: Dmitry Vyukov <>
Reviewed-by: Akinobu Mita <>
Reviewed-by: Jason Gunthorpe <>
Cc: Akinobu Mita <>
Cc: Matthew Wilcox <>
Cc: <>
Signed-off-by: Andrew Morton <>
4 files changed