All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER
@ 2021-04-09  5:55 Anshuman Khandual
  2021-04-09  8:24 ` David Hildenbrand
  0 siblings, 1 reply; 3+ messages in thread
From: Anshuman Khandual @ 2021-04-09  5:55 UTC (permalink / raw)
  To: linux-mm; +Cc: Anshuman Khandual, Andrew Morton, linux-kernel

pageblock_order must always be less than MAX_ORDER, otherwise it might lead
to an warning during boot. A similar problem got fixed on arm64 platform
with the commit 79cc2ed5a716 ("arm64/mm: Drop THP conditionality from
FORCE_MAX_ZONEORDER"). Assert the above condition before HUGETLB_PAGE_ORDER
gets assigned as pageblock_order. This will help detect the problem earlier
on platforms where HUGETLB_PAGE_SIZE_VARIABLE is enabled.

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>
---
 mm/page_alloc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 604dcd69397b..81b7460e1228 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7068,10 +7068,17 @@ void __init set_pageblock_order(void)
 	if (pageblock_order)
 		return;
 
-	if (HPAGE_SHIFT > PAGE_SHIFT)
+	if (HPAGE_SHIFT > PAGE_SHIFT) {
+		/*
+		 * pageblock_order must always be less than
+		 * MAX_ORDER. So does HUGETLB_PAGE_ORDER if
+		 * that is being assigned here.
+		 */
+		WARN_ON(HUGETLB_PAGE_ORDER >= MAX_ORDER);
 		order = HUGETLB_PAGE_ORDER;
-	else
+	} else {
 		order = MAX_ORDER - 1;
+	}
 
 	/*
 	 * Assume the largest contiguous order of interest is a huge page.
-- 
2.20.1


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

* Re: [PATCH] mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER
  2021-04-09  5:55 [PATCH] mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER Anshuman Khandual
@ 2021-04-09  8:24 ` David Hildenbrand
  2021-04-09  8:37   ` Anshuman Khandual
  0 siblings, 1 reply; 3+ messages in thread
From: David Hildenbrand @ 2021-04-09  8:24 UTC (permalink / raw)
  To: Anshuman Khandual, linux-mm; +Cc: Andrew Morton, linux-kernel

On 09.04.21 07:55, Anshuman Khandual wrote:
> pageblock_order must always be less than MAX_ORDER, otherwise it might lead
> to an warning during boot. A similar problem got fixed on arm64 platform
> with the commit 79cc2ed5a716 ("arm64/mm: Drop THP conditionality from
> FORCE_MAX_ZONEORDER"). Assert the above condition before HUGETLB_PAGE_ORDER
> gets assigned as pageblock_order. This will help detect the problem earlier
> on platforms where HUGETLB_PAGE_SIZE_VARIABLE is enabled.
> 
> 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>
> ---
>   mm/page_alloc.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 604dcd69397b..81b7460e1228 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -7068,10 +7068,17 @@ void __init set_pageblock_order(void)
>   	if (pageblock_order)
>   		return;
>   
> -	if (HPAGE_SHIFT > PAGE_SHIFT)
> +	if (HPAGE_SHIFT > PAGE_SHIFT) {
> +		/*
> +		 * pageblock_order must always be less than
> +		 * MAX_ORDER. So does HUGETLB_PAGE_ORDER if
> +		 * that is being assigned here.
> +		 */
> +		WARN_ON(HUGETLB_PAGE_ORDER >= MAX_ORDER);

Can't that be a BUILD_BUG_ON() ?

>   		order = HUGETLB_PAGE_ORDER;
> -	else
> +	} else {
>   		order = MAX_ORDER - 1;
> +	}
>   
>   	/*
>   	 * Assume the largest contiguous order of interest is a huge page.
> 


-- 
Thanks,

David / dhildenb


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

* Re: [PATCH] mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER
  2021-04-09  8:24 ` David Hildenbrand
@ 2021-04-09  8:37   ` Anshuman Khandual
  0 siblings, 0 replies; 3+ messages in thread
From: Anshuman Khandual @ 2021-04-09  8:37 UTC (permalink / raw)
  To: David Hildenbrand, linux-mm; +Cc: Andrew Morton, linux-kernel



On 4/9/21 1:54 PM, David Hildenbrand wrote:
> On 09.04.21 07:55, Anshuman Khandual wrote:
>> pageblock_order must always be less than MAX_ORDER, otherwise it might lead
>> to an warning during boot. A similar problem got fixed on arm64 platform
>> with the commit 79cc2ed5a716 ("arm64/mm: Drop THP conditionality from
>> FORCE_MAX_ZONEORDER"). Assert the above condition before HUGETLB_PAGE_ORDER
>> gets assigned as pageblock_order. This will help detect the problem earlier
>> on platforms where HUGETLB_PAGE_SIZE_VARIABLE is enabled.
>>
>> 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>
>> ---
>>   mm/page_alloc.c | 11 +++++++++--
>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 604dcd69397b..81b7460e1228 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -7068,10 +7068,17 @@ void __init set_pageblock_order(void)
>>       if (pageblock_order)
>>           return;
>>   -    if (HPAGE_SHIFT > PAGE_SHIFT)
>> +    if (HPAGE_SHIFT > PAGE_SHIFT) {
>> +        /*
>> +         * pageblock_order must always be less than
>> +         * MAX_ORDER. So does HUGETLB_PAGE_ORDER if
>> +         * that is being assigned here.
>> +         */
>> +        WARN_ON(HUGETLB_PAGE_ORDER >= MAX_ORDER);
> 
> Can't that be a BUILD_BUG_ON() ?

Yes, it can be. Probably might be appropriate as well, given that both
the arguments here are compile time constants. Okay, will change.

> 
>>           order = HUGETLB_PAGE_ORDER;
>> -    else
>> +    } else {
>>           order = MAX_ORDER - 1;
>> +    }
>>         /*
>>        * Assume the largest contiguous order of interest is a huge page.
>>
> 
> 

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

end of thread, other threads:[~2021-04-09  8:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09  5:55 [PATCH] mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER Anshuman Khandual
2021-04-09  8:24 ` David Hildenbrand
2021-04-09  8:37   ` Anshuman Khandual

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.