linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0
@ 2025-08-14 10:23 lirongqing
  2025-08-15  7:02 ` Dev Jain
  2025-08-18  2:21 ` jane.chu
  0 siblings, 2 replies; 6+ messages in thread
From: lirongqing @ 2025-08-14 10:23 UTC (permalink / raw)
  To: muchun.song, osalvador, david, akpm, linux-mm, linux-kernel; +Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com>

Optimize hugetlb_pages_alloc_boot() to return immediately when
max_huge_pages is 0, avoiding unnecessary CPU cycles and the below
log message when hugepages aren't configured in the kernel command
line.
[    3.702280] HugeTLB: allocation took 0ms with hugepage_allocation_threads=32

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
diff with v1: adding the reduced log messages in commit header 

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

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 753f99b..514fab5 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3654,6 +3654,9 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
 		return;
 	}
 
+	if (!h->max_huge_pages)
+		return;
+
 	/* do node specific alloc */
 	if (hugetlb_hstate_alloc_pages_specific_nodes(h))
 		return;
-- 
2.9.4


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

* Re: [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0
  2025-08-14 10:23 [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0 lirongqing
@ 2025-08-15  7:02 ` Dev Jain
  2025-08-18  2:21 ` jane.chu
  1 sibling, 0 replies; 6+ messages in thread
From: Dev Jain @ 2025-08-15  7:02 UTC (permalink / raw)
  To: lirongqing, muchun.song, osalvador, david, akpm, linux-mm,
	linux-kernel


On 14/08/25 3:53 pm, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Optimize hugetlb_pages_alloc_boot() to return immediately when
> max_huge_pages is 0, avoiding unnecessary CPU cycles and the below
> log message when hugepages aren't configured in the kernel command
> line.
> [    3.702280] HugeTLB: allocation took 0ms with hugepage_allocation_threads=32
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> diff with v1: adding the reduced log messages in commit header
>
>   mm/hugetlb.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 753f99b..514fab5 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -3654,6 +3654,9 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
>   		return;
>   	}
>   
> +	if (!h->max_huge_pages)
> +		return;
> +
>   	/* do node specific alloc */
>   	if (hugetlb_hstate_alloc_pages_specific_nodes(h))
>   		return;

Useful change!

Reviewed-by: Dev Jain <dev.jain@arm.com>
Tested-by: Dev Jain <dev.jain@arm.com>


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

* Re: [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0
  2025-08-14 10:23 [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0 lirongqing
  2025-08-15  7:02 ` Dev Jain
@ 2025-08-18  2:21 ` jane.chu
  2025-08-18  2:59   ` Andrew Morton
  1 sibling, 1 reply; 6+ messages in thread
From: jane.chu @ 2025-08-18  2:21 UTC (permalink / raw)
  To: lirongqing, muchun.song, osalvador, david, akpm, linux-mm,
	linux-kernel


On 8/14/2025 3:23 AM, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
> 
> Optimize hugetlb_pages_alloc_boot() to return immediately when
> max_huge_pages is 0, avoiding unnecessary CPU cycles and the below
> log message when hugepages aren't configured in the kernel command
> line.
> [    3.702280] HugeTLB: allocation took 0ms with hugepage_allocation_threads=32
> 
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> diff with v1: adding the reduced log messages in commit header
> 
>   mm/hugetlb.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 753f99b..514fab5 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -3654,6 +3654,9 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
>   		return;
>   	}
>   
> +	if (!h->max_huge_pages)
> +		return;
> +
>   	/* do node specific alloc */
>   	if (hugetlb_hstate_alloc_pages_specific_nodes(h))
>   		return;

Looks good.  Could you add stable: ?
Reviewed-by: Jane Chu <jane.chu@oracle.com>

thanks!
-jane

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

* Re: [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0
  2025-08-18  2:21 ` jane.chu
@ 2025-08-18  2:59   ` Andrew Morton
  2025-08-18  7:46     ` David Hildenbrand
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-18  2:59 UTC (permalink / raw)
  To: jane.chu
  Cc: lirongqing, muchun.song, osalvador, david, linux-mm, linux-kernel

On Sun, 17 Aug 2025 19:21:54 -0700 jane.chu@oracle.com wrote:

> 
> On 8/14/2025 3:23 AM, lirongqing wrote:
> > From: Li RongQing <lirongqing@baidu.com>
> > 
> > Optimize hugetlb_pages_alloc_boot() to return immediately when
> > max_huge_pages is 0, avoiding unnecessary CPU cycles and the below
> > log message when hugepages aren't configured in the kernel command
> > line.
> > [    3.702280] HugeTLB: allocation took 0ms with hugepage_allocation_threads=32
> > 
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > ---
> > diff with v1: adding the reduced log messages in commit header
> > 
> >   mm/hugetlb.c | 3 +++
> >   1 file changed, 3 insertions(+)
> > 
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index 753f99b..514fab5 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -3654,6 +3654,9 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
> >   		return;
> >   	}
> >   
> > +	if (!h->max_huge_pages)
> > +		return;
> > +
> >   	/* do node specific alloc */
> >   	if (hugetlb_hstate_alloc_pages_specific_nodes(h))
> >   		return;
> 
> Looks good.  Could you add stable: ?

Sure, I did that.

A Fixes: would be nice, to tell the -stable maintainers how far back in
time we need this, but the target sommit isn't obvious.


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

* Re: [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0
  2025-08-18  2:59   ` Andrew Morton
@ 2025-08-18  7:46     ` David Hildenbrand
  2025-08-19 22:59       ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2025-08-18  7:46 UTC (permalink / raw)
  To: Andrew Morton, jane.chu
  Cc: lirongqing, muchun.song, osalvador, linux-mm, linux-kernel

On 18.08.25 04:59, Andrew Morton wrote:
> On Sun, 17 Aug 2025 19:21:54 -0700 jane.chu@oracle.com wrote:
> 
>>
>> On 8/14/2025 3:23 AM, lirongqing wrote:
>>> From: Li RongQing <lirongqing@baidu.com>
>>>
>>> Optimize hugetlb_pages_alloc_boot() to return immediately when
>>> max_huge_pages is 0, avoiding unnecessary CPU cycles and the below
>>> log message when hugepages aren't configured in the kernel command
>>> line.
>>> [    3.702280] HugeTLB: allocation took 0ms with hugepage_allocation_threads=32
>>>
>>> Signed-off-by: Li RongQing <lirongqing@baidu.com>
>>> ---
>>> diff with v1: adding the reduced log messages in commit header
>>>
>>>    mm/hugetlb.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>>> index 753f99b..514fab5 100644
>>> --- a/mm/hugetlb.c
>>> +++ b/mm/hugetlb.c
>>> @@ -3654,6 +3654,9 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
>>>    		return;
>>>    	}
>>>    
>>> +	if (!h->max_huge_pages)
>>> +		return;
>>> +
>>>    	/* do node specific alloc */
>>>    	if (hugetlb_hstate_alloc_pages_specific_nodes(h))
>>>    		return;
>>
>> Looks good.  Could you add stable: ?

Can you elaborate why you think this is stable material?

> 
> Sure, I did that.

I don't think this is stable material, but for the change itself

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb


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

* Re: [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0
  2025-08-18  7:46     ` David Hildenbrand
@ 2025-08-19 22:59       ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2025-08-19 22:59 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: jane.chu, lirongqing, muchun.song, osalvador, linux-mm,
	linux-kernel

On Mon, 18 Aug 2025 09:46:59 +0200 David Hildenbrand <david@redhat.com> wrote:

> >>>    	if (hugetlb_hstate_alloc_pages_specific_nodes(h))
> >>>    		return;
> >>
> >> Looks good.  Could you add stable: ?
> 
> Can you elaborate why you think this is stable material?
> 

To prevent the

> [    3.702280] HugeTLB: allocation took 0ms with hugepage_allocation_threads=32

message when hugetlb pages are disabled.

Yeah, I guess it isn't very important.  I'll destabilize the patch.

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

end of thread, other threads:[~2025-08-19 22:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 10:23 [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0 lirongqing
2025-08-15  7:02 ` Dev Jain
2025-08-18  2:21 ` jane.chu
2025-08-18  2:59   ` Andrew Morton
2025-08-18  7:46     ` David Hildenbrand
2025-08-19 22:59       ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).