linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/mm/thp_swap_allocator_test: Fix small folio alignment
@ 2025-12-09  3:17 Kaushlendra Kumar
  2025-12-16  3:31 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Kaushlendra Kumar @ 2025-12-09  3:17 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, Kaushlendra Kumar

Use ALIGNMENT_SMALLFOLIO instead of ALIGNMENT_MTHP when allocating
small folios to ensure correct memory alignment for the test case.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
 tools/mm/thp_swap_allocator_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/mm/thp_swap_allocator_test.c b/tools/mm/thp_swap_allocator_test.c
index 83afc52275a5..d4434df3dcff 100644
--- a/tools/mm/thp_swap_allocator_test.c
+++ b/tools/mm/thp_swap_allocator_test.c
@@ -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);
-- 
2.34.1



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

* Re: [PATCH] tools/mm/thp_swap_allocator_test: Fix small folio alignment
  2025-12-09  3:17 [PATCH] tools/mm/thp_swap_allocator_test: Fix small folio alignment Kaushlendra Kumar
@ 2025-12-16  3:31 ` Andrew Morton
  2025-12-18  3:04   ` Kumar, Kaushlendra
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2025-12-16  3:31 UTC (permalink / raw)
  To: Kaushlendra Kumar; +Cc: linux-mm

On Tue,  9 Dec 2025 08:47:45 +0530 Kaushlendra Kumar <kaushlendra.kumar@intel.com> wrote:

> Use ALIGNMENT_SMALLFOLIO instead of ALIGNMENT_MTHP when allocating
> small folios to ensure correct memory alignment for the test case.
> 
> ...
>
> --- a/tools/mm/thp_swap_allocator_test.c
> +++ b/tools/mm/thp_swap_allocator_test.c
> @@ -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.



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

* RE: [PATCH] tools/mm/thp_swap_allocator_test: Fix small folio alignment
  2025-12-16  3:31 ` Andrew Morton
@ 2025-12-18  3:04   ` Kumar, Kaushlendra
  0 siblings, 0 replies; 3+ messages in thread
From: Kumar, Kaushlendra @ 2025-12-18  3:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm

On Tue, 9 Dec 2025, Andrew Morton wrote:
> On Tue,  9 Dec 2025 08:47:45 +0530 Kaushlendra Kumar wrote:
>> Use ALIGNMENT_SMALLFOLIO instead of ALIGNMENT_MTHP when allocating 
>> small folios to ensure correct memory alignment for the test case.
>> 
>> ...
>>
>> --- a/tools/mm/thp_swap_allocator_test.c
>> +++ b/tools/mm/thp_swap_allocator_test.c
>> @@ -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?

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


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

end of thread, other threads:[~2025-12-18  3:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-09  3:17 [PATCH] tools/mm/thp_swap_allocator_test: Fix small folio alignment Kaushlendra Kumar
2025-12-16  3:31 ` Andrew Morton
2025-12-18  3:04   ` Kumar, Kaushlendra

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