Skip to contentSkip to conversation

x86/mm: Make highstart_pfn and highend_pfn local to initmem_init()

PATCH In review Thorsten Blum 2 participants 5 messages Nov 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86/mm: Make highstart_pfn and highend_pfn local to initmem_init()

Since commit 35c3151a98a6 ("x86/mm: Consolidate initmem_init()") removed arch/x86/mm/numa_32.c, highstart_pfn and highend_pfn are only used in initmem_init().

Declare both variables locally and remove their unused extern declaration. Use min() to initialize highstart_pfn.

No functional change.

---
 arch/x86/include/asm/highmem.h | 3 ---
 arch/x86/mm/init_32.c          | 8 +++-----
 2 files changed, 3 insertions(+), 8 deletions(-)
arch/x86/include/asm/highmem.h +0 -3
index decfaaf52326..31d6d2a556f6 100644
@@ -27,9 +27,6 @@
 #include <asm/fixmap.h>
 #include <asm/pgtable_areas.h>
 
-/* declarations for highmem.c */
-extern unsigned long highstart_pfn, highend_pfn;
-
 /*
  * Right now we initialize only a single pte table. It can be extended
  * easily, subsequent pte tables have to be allocated in one physical
arch/x86/mm/init_32.c +3 -5
index 0908c44d51e6..9b0a3dd02da0 100644
@@ -55,8 +55,6 @@
 
 #include "mm_internal.h"
 
-unsigned long highstart_pfn, highend_pfn;
-
 bool __read_mostly __vmalloc_start_set = false;
 
 /*
@@ -615,9 +613,9 @@ void __init find_low_pfn_range(void)
 void __init initmem_init(void)
 {
 #ifdef CONFIG_HIGHMEM
-	highstart_pfn = highend_pfn = max_pfn;
-	if (max_pfn > max_low_pfn)
-		highstart_pfn = max_low_pfn;
+	unsigned long highstart_pfn = min(max_pfn, max_low_pfn);
+	unsigned long highend_pfn = max_pfn;
+
 	printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
 		pages_to_mb(highend_pfn - highstart_pfn));
 	high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
#1 lore raw

PATCH 2/2 x86/mm: Convert printk(KERN_*) to pr_*() in initmem_init()

Convert printk(KERN_*) to pr_notice() and pr_info(), use %lu for the unsigned long arguments, and add spaces around the shift operators.

No functional change.

---
 arch/x86/mm/init_32.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/x86/mm/init_32.c +4 -7
index 9b0a3dd02da0..a799f4cff63f 100644
@@ -616,8 +616,7 @@ void __init initmem_init(void)
 	unsigned long highstart_pfn = min(max_pfn, max_low_pfn);
 	unsigned long highend_pfn = max_pfn;
 
-	printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
-		pages_to_mb(highend_pfn - highstart_pfn));
+	pr_notice("%luMB HIGHMEM available.\n", pages_to_mb(highend_pfn - highstart_pfn));
 	high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
 	high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
@@ -627,12 +626,10 @@ void __init initmem_init(void)
 
 	__vmalloc_start_set = true;
 
-	printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
-			pages_to_mb(max_low_pfn));
+	pr_notice("%luMB LOWMEM available.\n", pages_to_mb(max_low_pfn));
 
-	printk(KERN_INFO "  mapped low ram: 0 - %08lx\n",
-		 max_pfn_mapped<<PAGE_SHIFT);
-	printk(KERN_INFO "  low ram: 0 - %08lx\n", max_low_pfn<<PAGE_SHIFT);
+	pr_info("  mapped low ram: 0 - %08lx\n", max_pfn_mapped << PAGE_SHIFT);
+	pr_info("  low ram: 0 - %08lx\n", max_low_pfn << PAGE_SHIFT);
 }
 
 /*
Acked-by on v1 1/2
#4 lore raw
In reply to Thorsten Blum
Quoted 10 lines · Thorsten Blum

Since commit 35c3151a98a6 ("x86/mm: Consolidate initmem_init()") removed arch/x86/mm/numa_32.c, highstart_pfn and highend_pfn are only used in initmem_init().

Declare both variables locally and remove their unused extern declaration. Use min() to initialize highstart_pfn.

No functional change.

Quoted 4 lines
---
 arch/x86/include/asm/highmem.h | 3 ---
 arch/x86/mm/init_32.c          | 8 +++-----
 2 files changed, 3 insertions(+), 8 deletions(-)
Signature · 2 lines
Sincerely yours,
Mike.
#2 lore raw

Re: [PATCH 2/2] x86/mm: Convert printk(KERN_*) to pr_*() in initmem_init()

In reply to Thorsten Blum
Quoted 2 lines · Thorsten Blum

Convert printk(KERN_*) to pr_notice() and pr_info(), use %lu for the unsigned long arguments, and add spaces around the shift operators.

Heh, there are about 90 printk(KERN_*) in arch/x86/mm and way more in arch/x86.

Maybe change them in a scripted sweep?

Quoted 37 lines

No functional change.

---
 arch/x86/mm/init_32.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/x86/mm/init_32.c +4 -7
index 9b0a3dd02da0..a799f4cff63f 100644
@@ -616,8 +616,7 @@ void __init initmem_init(void)
 	unsigned long highstart_pfn = min(max_pfn, max_low_pfn);
 	unsigned long highend_pfn = max_pfn;
 
-	printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
-		pages_to_mb(highend_pfn - highstart_pfn));
+	pr_notice("%luMB HIGHMEM available.\n", pages_to_mb(highend_pfn - highstart_pfn));
 	high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
 	high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
@@ -627,12 +626,10 @@ void __init initmem_init(void)
 
 	__vmalloc_start_set = true;
 
-	printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
-			pages_to_mb(max_low_pfn));
+	pr_notice("%luMB LOWMEM available.\n", pages_to_mb(max_low_pfn));
 
-	printk(KERN_INFO "  mapped low ram: 0 - %08lx\n",
-		 max_pfn_mapped<<PAGE_SHIFT);
-	printk(KERN_INFO "  low ram: 0 - %08lx\n", max_low_pfn<<PAGE_SHIFT);
+	pr_info("  mapped low ram: 0 - %08lx\n", max_pfn_mapped << PAGE_SHIFT);
+	pr_info("  low ram: 0 - %08lx\n", max_low_pfn << PAGE_SHIFT);
 }
 
 /*
Signature · 2 lines
Sincerely yours,
Mike.
#3 lore raw

Re: [PATCH 2/2] x86/mm: Convert printk(KERN_*) to pr_*() in initmem_init()

Quoted 8 lines · Mike Rapoport
Quoted 2 lines · Thorsten Blum

Convert printk(KERN_*) to pr_notice() and pr_info(), use %lu for the unsigned long arguments, and add spaces around the shift operators.

Heh, there are about 90 printk(KERN_*) in arch/x86/mm and way more in arch/x86.

Maybe change them in a scripted sweep?

I prefer to convert them when I'm already touching the code rather than in a broader sweep. The %ld to %lu and the spacing changes modify these lines anyway, which would trigger multiple checkpatch warnings about the leftover printk(KERN_*) calls.