Skip to contentSkip to conversation

lib/test_meminit: Allocate pages up to order MAX_ORDER

PATCH Applied Andrew Donnellan 2 participants 2 messages Jul 14, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/test_meminit: Allocate pages up to order MAX_ORDER

test_pages() tests the page allocator by calling alloc_pages() with different orders up to order 10.

However, different architectures and platforms support different maximum contiguous allocation sizes. The default maximum allocation order (MAX_ORDER) is 10, but architectures can use CONFIG_ARCH_FORCE_MAX_ORDER to override this. On platforms where this is less than 10, test_meminit() will blow up with a WARN(). This is expected, so let's not do that.

Replace the hardcoded "10" with the MAX_ORDER macro so that we test allocations up to the expected platform limit.

Fixes 5015a300a522 ("lib: introduce test_meminit module")
---
 lib/test_meminit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_meminit.c +1 -1
index 60e1984c060f..0ae35223d773 100644
@@ -93,7 +93,7 @@ static int __init test_pages(int *total_failures)
 	int failures = 0, num_tests = 0;
 	int i;
 
-	for (i = 0; i < 10; i++)
+	for (i = 0; i <= MAX_ORDER; i++)
 		num_tests += do_alloc_pages_order(i, &failures);
 
 	REPORT_FAILURES_IN_FN();
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Andrew Donnellan

test_pages() tests the page allocator by calling alloc_pages() with different orders up to order 10.

However, different architectures and platforms support different maximum contiguous allocation sizes. The default maximum allocation order (MAX_ORDER) is 10, but architectures can use CONFIG_ARCH_FORCE_MAX_ORDER to override this. On platforms where this is less than 10, test_meminit() will blow up with a WARN(). This is expected, so let's not do that.

Quoted 5 lines

Replace the hardcoded "10" with the MAX_ORDER macro so that we test allocations up to the expected platform limit.

Fixes 5015a300a522 ("lib: introduce test_meminit module")