diff mbox series

[02/10] um: Fix MAX_ORDER usage in linux_main()

Message ID 20230315113133.11326-3-kirill.shutemov@linux.intel.com (mailing list archive)
State New
Headers show
Series Fix confusion around MAX_ORDER | expand

Commit Message

Kirill A. Shutemov March 15, 2023, 11:31 a.m. UTC
MAX_ORDER is not inclusive: the maximum allocation order buddy allocator
can deliver is MAX_ORDER-1.

Fix MAX_ORDER usage in linux_main().

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
---
 arch/um/kernel/um_arch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mike Rapoport March 17, 2023, 8:49 a.m. UTC | #1
On Wed, Mar 15, 2023 at 02:31:25PM +0300, Kirill A. Shutemov wrote:
> MAX_ORDER is not inclusive: the maximum allocation order buddy allocator
> can deliver is MAX_ORDER-1.
> 
> Fix MAX_ORDER usage in linux_main().
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>

Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>

> ---
>  arch/um/kernel/um_arch.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
> index 8dcda617b8bf..5e5a9c8e0e5d 100644
> --- a/arch/um/kernel/um_arch.c
> +++ b/arch/um/kernel/um_arch.c
> @@ -368,10 +368,10 @@ int __init linux_main(int argc, char **argv)
>  	max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
>  
>  	/*
> -	 * Zones have to begin on a 1 << MAX_ORDER page boundary,
> +	 * Zones have to begin on a 1 << MAX_ORDER-1 page boundary,
>  	 * so this makes sure that's true for highmem
>  	 */
> -	max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER)) - 1);
> +	max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER - 1)) - 1);
>  	if (physmem_size + iomem_size > max_physmem) {
>  		highmem = physmem_size + iomem_size - max_physmem;
>  		physmem_size -= highmem;
> -- 
> 2.39.2
>
Vlastimil Babka March 21, 2023, 7:49 a.m. UTC | #2
On 3/15/23 12:31, Kirill A. Shutemov wrote:
> MAX_ORDER is not inclusive: the maximum allocation order buddy allocator
> can deliver is MAX_ORDER-1.
> 
> Fix MAX_ORDER usage in linux_main().
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> Cc: Richard Weinberger <richard@nod.at>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> ---
>  arch/um/kernel/um_arch.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
> index 8dcda617b8bf..5e5a9c8e0e5d 100644
> --- a/arch/um/kernel/um_arch.c
> +++ b/arch/um/kernel/um_arch.c
> @@ -368,10 +368,10 @@ int __init linux_main(int argc, char **argv)
>  	max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
>  
>  	/*
> -	 * Zones have to begin on a 1 << MAX_ORDER page boundary,
> +	 * Zones have to begin on a 1 << MAX_ORDER-1 page boundary,
>  	 * so this makes sure that's true for highmem
>  	 */
> -	max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER)) - 1);
> +	max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER - 1)) - 1);
>  	if (physmem_size + iomem_size > max_physmem) {
>  		highmem = physmem_size + iomem_size - max_physmem;
>  		physmem_size -= highmem;
diff mbox series

Patch

diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 8dcda617b8bf..5e5a9c8e0e5d 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -368,10 +368,10 @@  int __init linux_main(int argc, char **argv)
 	max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
 
 	/*
-	 * Zones have to begin on a 1 << MAX_ORDER page boundary,
+	 * Zones have to begin on a 1 << MAX_ORDER-1 page boundary,
 	 * so this makes sure that's true for highmem
 	 */
-	max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER)) - 1);
+	max_physmem &= ~((1 << (PAGE_SHIFT + MAX_ORDER - 1)) - 1);
 	if (physmem_size + iomem_size > max_physmem) {
 		highmem = physmem_size + iomem_size - max_physmem;
 		physmem_size -= highmem;