tools/mm/thp_swap_allocator_test: Fix small folio alignment
PATCH 1/1 tools/mm/thp_swap_allocator_test: Fix small folio alignment
Use ALIGNMENT_SMALLFOLIO instead of ALIGNMENT_MTHP when allocating small folios to ensure correct memory alignment for the test case.
--- tools/mm/thp_swap_allocator_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/mm/thp_swap_allocator_test.c +1 -1
@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) }if (use_small_folio) { - mem2 =aligned_alloc_mem (MEMSIZE_SMALLFOLIO ,ALIGNMENT_MTHP ); + mem2 =aligned_alloc_mem (MEMSIZE_SMALLFOLIO ,ALIGNMENT_SMALLFOLIO );if (mem2 ==NULL ) {fprintf (stderr,"Failed to allocate small folios memory\n" );free (mem1);
Signature · 1 line
2.34.1
Andrew Morton
maintainerQuoted 8 lines · On Tue, 9 Dec 2025 08:47:45 +0530 Kaushlendra Kumar…
Use
ALIGNMENT_SMALLFOLIOinstead ofALIGNMENT_MTHPwhen allocating small folios to ensure correct memory alignment for the test case....
tools/mm/thp_swap_allocator_test.c int main(int argc, char *argv[]) · line 148
Quoted 8 lines
tools/mm/thp_swap_allocator_test.c +1
-1@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) }if (use_small_folio) { - mem2 =aligned_alloc_mem (MEMSIZE_SMALLFOLIO ,ALIGNMENT_MTHP ); + mem2 =aligned_alloc_mem (MEMSIZE_SMALLFOLIO ,ALIGNMENT_SMALLFOLIO );if (mem2 ==NULL ) {fprintf (stderr,"Failed to allocate small folios memory\n" );free (mem1);
What are the worst-case userspace visible runtime effects of this change?
Thanks.
Quoted 11 lines · Andrew Morton
Quoted 10 lines · On Tue, 9 Dec 2025 08:47:45 +0530 Kaushlendra Kumar wrote:
Use
ALIGNMENT_SMALLFOLIOinstead ofALIGNMENT_MTHPwhen allocating small folios to ensure correct memory alignment for the test case....
tools/mm/thp_swap_allocator_test.c +0
-0@@ -142,7 +142,7 @@ int main(int argc, char *argv[]) }
Quoted 8 lines
tools/mm/thp_swap_allocator_test.c int main(int argc, char *argv[]) · line 148
Quoted 6 lines
tools/mm/thp_swap_allocator_test.c +1
-1if (use_small_folio) { - mem2 =aligned_alloc_mem (MEMSIZE_SMALLFOLIO ,ALIGNMENT_MTHP ); + mem2 =aligned_alloc_mem (MEMSIZE_SMALLFOLIO ,ALIGNMENT_SMALLFOLIO );if (mem2 ==NULL ) {fprintf (stderr,"Failed to allocate small folios memory\n" );free (mem1);What are the worst-case userspace visible runtime effects of this change?
Before: test allocates small folios with 64KB alignment (ALIGNMENT_MTHP) when only 4KB alignment (ALIGNMENT_SMALLFOLIO) is needed. This wastes address space and may cause allocation failures on systems with fragmented memory. Worst-case impact: this only affects thp_swap_allocator_test tool behavior.
-Kaushlendra