diff options
| author | Zach O'Keefe <[email protected]> | 2023-01-24 17:57:37 -0800 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2023-02-16 18:11:59 -0800 |
| commit | ae63c898f4004bbc7d212f4adcb3bb14852c30d6 (patch) | |
| tree | a41b6875863df80200687f388f218840566d8309 | |
| parent | 5956592ce337330cdff0399a6f8b6a5aea397a8e (diff) | |
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/[email protected]
Fixes: 7d8faaf15545 ("mm/madvise: introduce MADV_COLLAPSE sync hugepage collapse")
Signed-off-by: Zach O'Keefe <[email protected]>
Reported-by: Hugh Dickins <[email protected]>
Acked-by: Hugh Dickins <[email protected]>
Reviewed-by: Yang Shi <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
| -rw-r--r-- | mm/khugepaged.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 90acfea40c13..a26a28e3738c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2611,6 +2611,7 @@ static int madvise_collapse_errno(enum scan_result r) case SCAN_CGROUP_CHARGE_FAIL: return -EBUSY; /* Resource temporary unavailable - trying again might succeed */ + case SCAN_PAGE_COUNT: case SCAN_PAGE_LOCK: case SCAN_PAGE_LRU: case SCAN_DEL_PAGE_LRU: |