diff mbox series

[RFC,v12,based,on,mm-unstable,as,of,Feb,21,2025,18/25] mm/page_alloc: retry 3 times to take pcp pages on luf check failure

Message ID 20250226120132.28469-18-byungchul@sk.com (mailing list archive)
State New
Headers show
Series [RFC,v12,based,on,mm-unstable,as,of,Feb,21,2025,01/25] x86/tlb: add APIs manipulating tlb batch's arch data | expand

Commit Message

Byungchul Park Feb. 26, 2025, 12:01 p.m. UTC
Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 mm/page_alloc.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7b023b34d53da..f35ae2550019f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3384,6 +3384,12 @@  struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order,
 {
 	struct page *page;
 
+	/*
+	 * give up taking page from pcp if it fails to take pcp page
+	 * 3 times due to the tlb shootdownable issue.
+	 */
+	int try_luf_pages = 3;
+
 	do {
 		if (list_empty(list)) {
 			int batch = nr_pcp_alloc(pcp, zone, order);
@@ -3398,11 +3404,21 @@  struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order,
 				return NULL;
 		}
 
-		page = list_first_entry(list, struct page, pcp_list);
-		if (!luf_takeoff_check_and_fold(page))
+		list_for_each_entry(page, list, pcp_list) {
+			if (luf_takeoff_check_and_fold(page)) {
+				list_del(&page->pcp_list);
+				pcp->count -= 1 << order;
+				break;
+			}
+			if (!--try_luf_pages)
+				return NULL;
+		}
+
+		/*
+		 * If all the pages in the list fails...
+		 */
+		if (list_entry_is_head(page, list, pcp_list))
 			return NULL;
-		list_del(&page->pcp_list);
-		pcp->count -= 1 << order;
 	} while (check_new_pages(page, order));
 
 	return page;