]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/MADV_COLLAPSE: set EAGAIN on unexpected page refcount
authorZach O'Keefe <zokeefe@google.com>
Wed, 25 Jan 2023 01:57:37 +0000 (17:57 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 10 Feb 2023 23:35:46 +0000 (15:35 -0800)
commit87d4093c0e815b036e76d64c713dea8fd90f8525
treea41b6875863df80200687f388f218840566d8309
parentcfecbdbbbd864bd6706fa25f3e7fc8ad2e77b1e5
mm/MADV_COLLAPSE: set EAGAIN on unexpected page refcount

During collapse, in a few places we check to see if a given small page has
any unaccounted references.  If the refcount on the page doesn't match our
expectations, it must be there is an unknown user concurrently interested
in the page, and so it's not safe to move the contents elsewhere.
However, the unaccounted pins are likely an ephemeral state.

In this situation, MADV_COLLAPSE returns -EINVAL when it should return
-EAGAIN.  This could cause userspace to conclude that the syscall
failed, when it in fact could succeed by retrying.

Link: https://lkml.kernel.org/r/20230125015738.912924-1-zokeefe@google.com
Fixes: 7d8faaf15545 ("mm/madvise: introduce MADV_COLLAPSE sync hugepage collapse")
Signed-off-by: Zach O'Keefe <zokeefe@google.com>
Reported-by: Hugh Dickins <hughd@google.com>
Acked-by: Hugh Dickins <hughd@google.com>
Reviewed-by: Yang Shi <shy828301@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/khugepaged.c