Skip to contentSkip to conversation

mm/mm_init.c: use round_up() to calculate usermap size

PATCH Applied Wei Yang 5 participants 5 messages Feb 12, 2025 – Feb 13, 2025

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm/mm_init.c: use round_up() to calculate usermap size

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.

---
 mm/mm_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/mm_init.c +3 -3
index 3ec50b5fda12..550d5ae98cfd 100644
@@ -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;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · 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.

Thanks for the patch.

Quoted 30 lines
---
 mm/mm_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/mm_init.c +3 -3
index 3ec50b5fda12..550d5ae98cfd 100644
@@ -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 on v1 1/1
#2 lore raw
In reply to Wei Yang
Quoted 28 lines · 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.

---
  mm/mm_init.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
mm/mm_init.c +1 -1
index 3ec50b5fda12..550d5ae98cfd 100644
@@ -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;
 

mm/mm_init.c static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l · line 1479

Quoted 10 lines
mm/mm_init.c +2 -2
  	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;
  }
Signature · 3 lines
Cheers,

David / dhildenb
Reviewed-by on v1 1/1
#3 lore raw
In reply to Wei Yang
Quoted 28 lines · 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.

---
 mm/mm_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/mm_init.c +1 -1
index 3ec50b5fda12..550d5ae98cfd 100644
@@ -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;
 

mm/mm_init.c static unsigned long __init usemap_size(unsigned long zone_start_pfn, unsigned l · line 1479

Quoted 10 lines
mm/mm_init.c +2 -2
 	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;
 }
maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Wei Yang
Quoted 8 lines · 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.

Quoted 33 lines
---
 mm/mm_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/mm_init.c +3 -3
index 3ec50b5fda12..550d5ae98cfd 100644
@@ -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;
 }
Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours,
Mike.