From 36cd4c37aba0d1f66e86f039b32b5c883ff7461f Mon Sep 17 00:00:00 2001 From: Mel Gorman Date: Thu, 26 Aug 2021 21:49:44 +0800 Subject: [PATCH] mm/page_alloc: correct return value of populated elements if bulk array is populated mainline inclusion from mainline-5.14-rc1 commit ff4b2b4014cbffb3d32b22629252f4dc8616b0fe category: bugfix bugzilla: https://gitee.com/src-openeuler/nfs-utils/issues/I46NSS CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ff4b2b4014cbffb3d32b22629252f4dc8616b0fe ------------------------------------------------- Dave Jones reported the following This made it into 5.13 final, and completely breaks NFSD for me (Serving tcp v3 mounts). Existing mounts on clients hang, as do new mounts from new clients. Rebooting the server back to rc7 everything recovers. The commit b3b64ebd3822 ("mm/page_alloc: do bulk array bounds check after checking populated elements") returns the wrong value if the array is already populated which is interpreted as an allocation failure. Dave reported this fixes his problem and it also passed a test running dbench over NFS. Link: https://lkml.kernel.org/r/20210628150219.GC3840@techsingularity.net Fixes: b3b64ebd3822 ("mm/page_alloc: do bulk array bounds check after checking populated elements") Signed-off-by: Mel Gorman Reported-by: Dave Jones Tested-by: Dave Jones Cc: Dan Carpenter Cc: Jesper Dangaard Brouer Cc: Vlastimil Babka Cc: [5.13+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit ff4b2b4014cbffb3d32b22629252f4dc8616b0fe) Signed-off-by: Yongqiang Liu Reviewed-by: tong tiangen Signed-off-by: Zheng Zengkai --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 853d65d5420f..19394f8f9daf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4965,7 +4965,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, /* Already populated array? */ if (unlikely(page_array && nr_pages - nr_populated == 0)) - return 0; + return nr_populated; /* Use the single page allocator for one page. */ if (nr_pages - nr_populated == 1) -- GitLab