1 From ff4b2b4014cbffb3d32b22629252f4dc8616b0fe Mon Sep 17 00:00:00 2001
2 From: Mel Gorman <mgorman@techsingularity.net>
3 Date: Mon, 28 Jun 2021 19:33:29 -0700
4 Subject: mm/page_alloc: correct return value of populated elements if bulk array is populated
6 From: Mel Gorman <mgorman@techsingularity.net>
8 commit ff4b2b4014cbffb3d32b22629252f4dc8616b0fe upstream.
10 Dave Jones reported the following
12 This made it into 5.13 final, and completely breaks NFSD for me
13 (Serving tcp v3 mounts). Existing mounts on clients hang, as do
14 new mounts from new clients. Rebooting the server back to rc7
17 The commit b3b64ebd3822 ("mm/page_alloc: do bulk array bounds check after
18 checking populated elements") returns the wrong value if the array is
19 already populated which is interpreted as an allocation failure. Dave
20 reported this fixes his problem and it also passed a test running dbench
23 Link: https://lkml.kernel.org/r/20210628150219.GC3840@techsingularity.net
24 Fixes: b3b64ebd3822 ("mm/page_alloc: do bulk array bounds check after checking populated elements")
25 Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
26 Reported-by: Dave Jones <davej@codemonkey.org.uk>
27 Tested-by: Dave Jones <davej@codemonkey.org.uk>
28 Cc: Dan Carpenter <dan.carpenter@oracle.com>
29 Cc: Jesper Dangaard Brouer <brouer@redhat.com>
30 Cc: Vlastimil Babka <vbabka@suse.cz>
31 Cc: <stable@vger.kernel.org> [5.13+]
32 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
33 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36 mm/page_alloc.c | 2 +-
37 1 file changed, 1 insertion(+), 1 deletion(-)
41 @@ -5058,7 +5058,7 @@ unsigned long __alloc_pages_bulk(gfp_t g
43 /* Already populated array? */
44 if (unlikely(page_array && nr_pages - nr_populated == 0))
46 + return nr_populated;
48 /* Use the single page allocator for one page. */
49 if (nr_pages - nr_populated == 1)