linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix pcp count beyond pcp high in pcplist allocation
@ 2022-10-24 13:41 Chen Wandun
  2022-10-24 14:55 ` Mel Gorman
  0 siblings, 1 reply; 7+ messages in thread
From: Chen Wandun @ 2022-10-24 13:41 UTC (permalink / raw)
  To: akpm, mgorman, vbabka, linux-mm, linux-kernel, wangkefeng.wang

Nowadays there are several orders in pcplist, Function __rmqueue_pcplist
would alloc pcp batch pages to refill pcplist, when list of target order
if empty meanwhile other lists is not all empty, that result in pcp count
beyond pcp high after allocation. This behaviour can be easily observed by
adding debugging information in __rmqueue_pcplist.

Fix this by recalculate the batch pages to be allocated.

Fixes: 44042b449872 ("mm/page_alloc: allow high-order pages to be stored on the per-cpu lists")
Signed-off-by: Chen Wandun <chenwandun@huawei.com>
---
 mm/page_alloc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 39f846d098f5..93e18b6de2f3 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3742,6 +3742,7 @@ struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order,
 	do {
 		if (list_empty(list)) {
 			int batch = READ_ONCE(pcp->batch);
+			int high = READ_ONCE(pcp->high);
 			int alloced;
 
 			/*
@@ -3753,6 +3754,7 @@ struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order,
 			 */
 			if (batch > 1)
 				batch = max(batch >> order, 2);
+			batch = min(batch, (high - pcp->count) >> order);
 			alloced = rmqueue_bulk(zone, order,
 					batch, list,
 					migratetype, alloc_flags);
-- 
2.25.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-03 12:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 13:41 [PATCH] mm: fix pcp count beyond pcp high in pcplist allocation Chen Wandun
2022-10-24 14:55 ` Mel Gorman
2022-10-25 11:49   ` Chen Wandun
2022-10-25 13:19     ` Mel Gorman
2022-10-31  3:37       ` Chen Wandun
2022-11-01 10:40         ` Mel Gorman
2022-11-03 12:46           ` Chen Wandun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox