Skip to content

Commit 83b9355

Browse files
tehcastertorvalds
authored andcommitted
mm, page_alloc: prevent infinite loop in buffered_rmqueue()
In DEBUG_VM kernel, we can hit infinite loop for order == 0 in buffered_rmqueue() when check_new_pcp() returns 1, because the bad page is never removed from the pcp list. Fix this by removing the page before retrying. Also we don't need to check if page is non-NULL, because we simply grab it from the list which was just tested for being non-empty. Fixes: 479f854 ("mm, page_alloc: defer debugging checks of pages allocated from the PCP") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Vlastimil Babka <[email protected]> Signed-off-by: Mel Gorman <[email protected]> Reported-by: Naoya Horiguchi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 879be4f commit 83b9355

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mm/page_alloc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,11 +2615,12 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
26152615
page = list_last_entry(list, struct page, lru);
26162616
else
26172617
page = list_first_entry(list, struct page, lru);
2618-
} while (page && check_new_pcp(page));
26192618

2620-
__dec_zone_state(zone, NR_ALLOC_BATCH);
2621-
list_del(&page->lru);
2622-
pcp->count--;
2619+
__dec_zone_state(zone, NR_ALLOC_BATCH);
2620+
list_del(&page->lru);
2621+
pcp->count--;
2622+
2623+
} while (check_new_pcp(page));
26232624
} else {
26242625
/*
26252626
* We most definitely don't want callers attempting to

0 commit comments

Comments
 (0)