linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: Ensure adequate CMA areas available for hugetlb_cma[]
@ 2024-02-09  6:50 Anshuman Khandual
  2024-02-09 22:16 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Anshuman Khandual @ 2024-02-09  6:50 UTC (permalink / raw)
  To: linux-mm; +Cc: Anshuman Khandual, Muchun Song, Andrew Morton, linux-kernel

HugeTLB CMA area array is being created for possible MAX_NUMNODES without
ensuring corresponding MAX_CMA_AREAS support in CMA. Let's just warn for
such scenarios indicating need for CONFIG_CMA_AREAS adjustment.

Cc: Muchun Song <muchun.song@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on v6.8-rc3

 mm/hugetlb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a188b7c60f4f..fda8ced69832 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -7750,6 +7750,13 @@ void __init hugetlb_cma_reserve(int order)
 	}
 
 	reserved = 0;
+
+	/*
+	 * There needs to be enough MAX_CMA_AREAS to accommodate
+	 * MAX_NUMNODES heap areas being created here. Otherwise
+	 * adjust CONFIG_CMA_AREAS as required.
+	 */
+	VM_WARN_ON(MAX_CMA_AREAS < MAX_NUMNODES);
 	for_each_online_node(nid) {
 		int res;
 		char name[CMA_MAX_NAME];
-- 
2.25.1



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

* Re: [PATCH] mm/hugetlb: Ensure adequate CMA areas available for hugetlb_cma[]
  2024-02-09  6:50 [PATCH] mm/hugetlb: Ensure adequate CMA areas available for hugetlb_cma[] Anshuman Khandual
@ 2024-02-09 22:16 ` Andrew Morton
  2024-02-12  2:06   ` Anshuman Khandual
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2024-02-09 22:16 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: linux-mm, Muchun Song, linux-kernel

On Fri,  9 Feb 2024 12:20:36 +0530 Anshuman Khandual <anshuman.khandual@arm.com> wrote:

> HugeTLB CMA area array is being created for possible MAX_NUMNODES without
> ensuring corresponding MAX_CMA_AREAS support in CMA. Let's just warn for
> such scenarios indicating need for CONFIG_CMA_AREAS adjustment.
> 
> ...
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -7750,6 +7750,13 @@ void __init hugetlb_cma_reserve(int order)
>  	}
>  
>  	reserved = 0;
> +
> +	/*
> +	 * There needs to be enough MAX_CMA_AREAS to accommodate
> +	 * MAX_NUMNODES heap areas being created here. Otherwise
> +	 * adjust CONFIG_CMA_AREAS as required.
> +	 */
> +	VM_WARN_ON(MAX_CMA_AREAS < MAX_NUMNODES);

Could this simply be fixed up in Kconfig logic?

And I think this could be detected at compile-time?  BUILD_BUG_ON()?

>  	for_each_online_node(nid) {
>  		int res;
>  		char name[CMA_MAX_NAME];
> -- 
> 2.25.1


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

* Re: [PATCH] mm/hugetlb: Ensure adequate CMA areas available for hugetlb_cma[]
  2024-02-09 22:16 ` Andrew Morton
@ 2024-02-12  2:06   ` Anshuman Khandual
  0 siblings, 0 replies; 3+ messages in thread
From: Anshuman Khandual @ 2024-02-12  2:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Muchun Song, linux-kernel



On 2/10/24 03:46, Andrew Morton wrote:
> On Fri,  9 Feb 2024 12:20:36 +0530 Anshuman Khandual <anshuman.khandual@arm.com> wrote:
> 
>> HugeTLB CMA area array is being created for possible MAX_NUMNODES without
>> ensuring corresponding MAX_CMA_AREAS support in CMA. Let's just warn for
>> such scenarios indicating need for CONFIG_CMA_AREAS adjustment.
>>
>> ...
>>
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -7750,6 +7750,13 @@ void __init hugetlb_cma_reserve(int order)
>>  	}
>>  
>>  	reserved = 0;
>> +
>> +	/*
>> +	 * There needs to be enough MAX_CMA_AREAS to accommodate
>> +	 * MAX_NUMNODES heap areas being created here. Otherwise
>> +	 * adjust CONFIG_CMA_AREAS as required.
>> +	 */
>> +	VM_WARN_ON(MAX_CMA_AREAS < MAX_NUMNODES);
> 
> Could this simply be fixed up in Kconfig logic?

CMA_AREAS should default as (1 << NODES_SHIFT) ? But the system admin might want
to create more heap areas for other purposes as well. The idea here is to ensure
MAX_CMA_AREAS is at least MAX_NUMNODES if HugeTLB support is enabled. Do we have
some other methods ?

> 
> And I think this could be detected at compile-time?  BUILD_BUG_ON()?

Right, was thinking about this at first. Makes sense, will change here, seems to
be the right location for a build check as well.

> 
>>  	for_each_online_node(nid) {
>>  		int res;
>>  		char name[CMA_MAX_NAME];
>> -- 
>> 2.25.1
> 


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

end of thread, other threads:[~2024-02-12  2:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-09  6:50 [PATCH] mm/hugetlb: Ensure adequate CMA areas available for hugetlb_cma[] Anshuman Khandual
2024-02-09 22:16 ` Andrew Morton
2024-02-12  2:06   ` Anshuman Khandual

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