linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mm_init.c: use round_up() to calculate usermap size
@ 2025-02-12  1:38 Wei Yang
  2025-02-12  4:30 ` Shivank Garg
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Wei Yang @ 2025-02-12  1:38 UTC (permalink / raw)
  To: rppt, akpm; +Cc: shivankg, linux-mm, Wei Yang

Since pageblock_nr_pages and BITS_PER_LONG are power of 2, we could use
round_up() to calculate it.

Also we have renamed blockflags to pageblock_flags, adjust the comment
accordingly.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Suggested-by: Shivank Garg <shivankg@amd.com>
---
 mm/mm_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 3ec50b5fda12..550d5ae98cfd 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1459,7 +1459,7 @@ void __meminit init_currently_empty_zone(struct zone *zone,
 
 #ifndef CONFIG_SPARSEMEM
 /*
- * Calculate the size of the zone->blockflags rounded to an unsigned long
+ * Calculate the size of the zone->pageblock_flags rounded to an unsigned long
  * Start by making sure zonesize is a multiple of pageblock_order by rounding
  * up. Then use 1 NR_PAGEBLOCK_BITS worth of bits per pageblock, finally
  * round what is now in bits to nearest long in bits, then return it in
@@ -1470,10 +1470,10 @@ static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l
 	unsigned long usemapsize;
 
 	zonesize += zone_start_pfn & (pageblock_nr_pages-1);
-	usemapsize = roundup(zonesize, pageblock_nr_pages);
+	usemapsize = round_up(zonesize, pageblock_nr_pages);
 	usemapsize = usemapsize >> pageblock_order;
 	usemapsize *= NR_PAGEBLOCK_BITS;
-	usemapsize = roundup(usemapsize, BITS_PER_LONG);
+	usemapsize = round_up(usemapsize, BITS_PER_LONG);
 
 	return usemapsize / BITS_PER_BYTE;
 }
-- 
2.34.1



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

* Re: [PATCH] mm/mm_init.c: use round_up() to calculate usermap size
  2025-02-12  1:38 [PATCH] mm/mm_init.c: use round_up() to calculate usermap size Wei Yang
@ 2025-02-12  4:30 ` Shivank Garg
  2025-02-12 17:09 ` David Hildenbrand
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Shivank Garg @ 2025-02-12  4:30 UTC (permalink / raw)
  To: Wei Yang, rppt, akpm; +Cc: linux-mm



On 2/12/2025 7:08 AM, Wei Yang wrote:
> Since pageblock_nr_pages and BITS_PER_LONG are power of 2, we could use
> round_up() to calculate it.
> 
> Also we have renamed blockflags to pageblock_flags, adjust the comment
> accordingly.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Suggested-by: Shivank Garg <shivankg@amd.com>

Thanks for the patch.

Reviewed-by: Shivank Garg <shivankg@amd.com>

> ---
>  mm/mm_init.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 3ec50b5fda12..550d5ae98cfd 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1459,7 +1459,7 @@ void __meminit init_currently_empty_zone(struct zone *zone,
>  
>  #ifndef CONFIG_SPARSEMEM
>  /*
> - * Calculate the size of the zone->blockflags rounded to an unsigned long
> + * Calculate the size of the zone->pageblock_flags rounded to an unsigned long
>   * Start by making sure zonesize is a multiple of pageblock_order by rounding
>   * up. Then use 1 NR_PAGEBLOCK_BITS worth of bits per pageblock, finally
>   * round what is now in bits to nearest long in bits, then return it in
> @@ -1470,10 +1470,10 @@ static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l
>  	unsigned long usemapsize;
>  
>  	zonesize += zone_start_pfn & (pageblock_nr_pages-1);
> -	usemapsize = roundup(zonesize, pageblock_nr_pages);
> +	usemapsize = round_up(zonesize, pageblock_nr_pages);
>  	usemapsize = usemapsize >> pageblock_order;
>  	usemapsize *= NR_PAGEBLOCK_BITS;
> -	usemapsize = roundup(usemapsize, BITS_PER_LONG);
> +	usemapsize = round_up(usemapsize, BITS_PER_LONG);
>  
>  	return usemapsize / BITS_PER_BYTE;
>  }



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

* Re: [PATCH] mm/mm_init.c: use round_up() to calculate usermap size
  2025-02-12  1:38 [PATCH] mm/mm_init.c: use round_up() to calculate usermap size Wei Yang
  2025-02-12  4:30 ` Shivank Garg
@ 2025-02-12 17:09 ` David Hildenbrand
  2025-02-13  4:35 ` Anshuman Khandual
  2025-02-13  6:32 ` Mike Rapoport
  3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2025-02-12 17:09 UTC (permalink / raw)
  To: Wei Yang, rppt, akpm; +Cc: shivankg, linux-mm

On 12.02.25 02:38, Wei Yang wrote:
> Since pageblock_nr_pages and BITS_PER_LONG are power of 2, we could use
> round_up() to calculate it.
> 
> Also we have renamed blockflags to pageblock_flags, adjust the comment
> accordingly.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Suggested-by: Shivank Garg <shivankg@amd.com>
> ---
>   mm/mm_init.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 3ec50b5fda12..550d5ae98cfd 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1459,7 +1459,7 @@ void __meminit init_currently_empty_zone(struct zone *zone,
>   
>   #ifndef CONFIG_SPARSEMEM
>   /*
> - * Calculate the size of the zone->blockflags rounded to an unsigned long
> + * Calculate the size of the zone->pageblock_flags rounded to an unsigned long
>    * Start by making sure zonesize is a multiple of pageblock_order by rounding
>    * up. Then use 1 NR_PAGEBLOCK_BITS worth of bits per pageblock, finally
>    * round what is now in bits to nearest long in bits, then return it in
> @@ -1470,10 +1470,10 @@ static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l
>   	unsigned long usemapsize;
>   
>   	zonesize += zone_start_pfn & (pageblock_nr_pages-1);
> -	usemapsize = roundup(zonesize, pageblock_nr_pages);
> +	usemapsize = round_up(zonesize, pageblock_nr_pages);
>   	usemapsize = usemapsize >> pageblock_order;
>   	usemapsize *= NR_PAGEBLOCK_BITS;
> -	usemapsize = roundup(usemapsize, BITS_PER_LONG);
> +	usemapsize = round_up(usemapsize, BITS_PER_LONG);
>   
>   	return usemapsize / BITS_PER_BYTE;
>   }

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

-- 
Cheers,

David / dhildenb



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

* Re: [PATCH] mm/mm_init.c: use round_up() to calculate usermap size
  2025-02-12  1:38 [PATCH] mm/mm_init.c: use round_up() to calculate usermap size Wei Yang
  2025-02-12  4:30 ` Shivank Garg
  2025-02-12 17:09 ` David Hildenbrand
@ 2025-02-13  4:35 ` Anshuman Khandual
  2025-02-13  6:32 ` Mike Rapoport
  3 siblings, 0 replies; 5+ messages in thread
From: Anshuman Khandual @ 2025-02-13  4:35 UTC (permalink / raw)
  To: Wei Yang, rppt, akpm; +Cc: shivankg, linux-mm



On 2/12/25 07:08, Wei Yang wrote:
> Since pageblock_nr_pages and BITS_PER_LONG are power of 2, we could use
> round_up() to calculate it.
> 
> Also we have renamed blockflags to pageblock_flags, adjust the comment
> accordingly.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Suggested-by: Shivank Garg <shivankg@amd.com>
> ---
>  mm/mm_init.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 3ec50b5fda12..550d5ae98cfd 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1459,7 +1459,7 @@ void __meminit init_currently_empty_zone(struct zone *zone,
>  
>  #ifndef CONFIG_SPARSEMEM
>  /*
> - * Calculate the size of the zone->blockflags rounded to an unsigned long
> + * Calculate the size of the zone->pageblock_flags rounded to an unsigned long
>   * Start by making sure zonesize is a multiple of pageblock_order by rounding
>   * up. Then use 1 NR_PAGEBLOCK_BITS worth of bits per pageblock, finally
>   * round what is now in bits to nearest long in bits, then return it in
> @@ -1470,10 +1470,10 @@ static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l
>  	unsigned long usemapsize;
>  
>  	zonesize += zone_start_pfn & (pageblock_nr_pages-1);
> -	usemapsize = roundup(zonesize, pageblock_nr_pages);
> +	usemapsize = round_up(zonesize, pageblock_nr_pages);
>  	usemapsize = usemapsize >> pageblock_order;
>  	usemapsize *= NR_PAGEBLOCK_BITS;
> -	usemapsize = roundup(usemapsize, BITS_PER_LONG);
> +	usemapsize = round_up(usemapsize, BITS_PER_LONG);
>  
>  	return usemapsize / BITS_PER_BYTE;
>  }

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>


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

* Re: [PATCH] mm/mm_init.c: use round_up() to calculate usermap size
  2025-02-12  1:38 [PATCH] mm/mm_init.c: use round_up() to calculate usermap size Wei Yang
                   ` (2 preceding siblings ...)
  2025-02-13  4:35 ` Anshuman Khandual
@ 2025-02-13  6:32 ` Mike Rapoport
  3 siblings, 0 replies; 5+ messages in thread
From: Mike Rapoport @ 2025-02-13  6:32 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, shivankg, linux-mm

On Wed, Feb 12, 2025 at 01:38:18AM +0000, Wei Yang wrote:
> Since pageblock_nr_pages and BITS_PER_LONG are power of 2, we could use
> round_up() to calculate it.
> 
> Also we have renamed blockflags to pageblock_flags, adjust the comment
> accordingly.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Suggested-by: Shivank Garg <shivankg@amd.com>

Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  mm/mm_init.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 3ec50b5fda12..550d5ae98cfd 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1459,7 +1459,7 @@ void __meminit init_currently_empty_zone(struct zone *zone,
>  
>  #ifndef CONFIG_SPARSEMEM
>  /*
> - * Calculate the size of the zone->blockflags rounded to an unsigned long
> + * Calculate the size of the zone->pageblock_flags rounded to an unsigned long
>   * Start by making sure zonesize is a multiple of pageblock_order by rounding
>   * up. Then use 1 NR_PAGEBLOCK_BITS worth of bits per pageblock, finally
>   * round what is now in bits to nearest long in bits, then return it in
> @@ -1470,10 +1470,10 @@ static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l
>  	unsigned long usemapsize;
>  
>  	zonesize += zone_start_pfn & (pageblock_nr_pages-1);
> -	usemapsize = roundup(zonesize, pageblock_nr_pages);
> +	usemapsize = round_up(zonesize, pageblock_nr_pages);
>  	usemapsize = usemapsize >> pageblock_order;
>  	usemapsize *= NR_PAGEBLOCK_BITS;
> -	usemapsize = roundup(usemapsize, BITS_PER_LONG);
> +	usemapsize = round_up(usemapsize, BITS_PER_LONG);
>  
>  	return usemapsize / BITS_PER_BYTE;
>  }
> -- 
> 2.34.1
> 

-- 
Sincerely yours,
Mike.


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

end of thread, other threads:[~2025-02-13  6:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12  1:38 [PATCH] mm/mm_init.c: use round_up() to calculate usermap size Wei Yang
2025-02-12  4:30 ` Shivank Garg
2025-02-12 17:09 ` David Hildenbrand
2025-02-13  4:35 ` Anshuman Khandual
2025-02-13  6:32 ` Mike Rapoport

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