Skip to content

Commit ae63c89

Browse files
zokeefeakpm00
authored andcommitted
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: 7d8faaf ("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]>
1 parent 5956592 commit ae63c89

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/khugepaged.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,6 +2611,7 @@ static int madvise_collapse_errno(enum scan_result r)
26112611
case SCAN_CGROUP_CHARGE_FAIL:
26122612
return -EBUSY;
26132613
/* Resource temporary unavailable - trying again might succeed */
2614+
case SCAN_PAGE_COUNT:
26142615
case SCAN_PAGE_LOCK:
26152616
case SCAN_PAGE_LRU:
26162617
case SCAN_DEL_PAGE_LRU:

0 commit comments

Comments
 (0)