mm/z3fold.c: claim page in the beginning of free

There's a really hard to reproduce race in z3fold between z3fold_free()
and z3fold_reclaim_page().  z3fold_reclaim_page() can claim the page
after z3fold_free() has checked if the page was claimed and
z3fold_free() will then schedule this page for compaction which may in
turn lead to random page faults (since that page would have been
reclaimed by then).

Fix that by claiming page in the beginning of z3fold_free() and not
forgetting to clear the claim in the end.

[ v2]
Signed-off-by: Vitaly Wool <>
Reported-by: Markus Linnala <>
Cc: Dan Streetman <>
Cc: Vlastimil Babka <>
Cc: Henry Burns <>
Cc: Shakeel Butt <>
Cc: Markus Linnala <>
Cc: <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
1 file changed