Skip to contentSkip to conversation

move max_page and total_pages to common code

PATCH In review Jan Beulich 3 participants 3 messages Aug 8, 2023 – Aug 9, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move max_page and total_pages to common code

Common code references both, so the variables shouldn't need declaring and defining by every arch. While moving the definitions, add __read_mostly (__ro_after_init would only be appropriate when !mem_hotplug).

xen/arch/arm/include/asm/mm.h +0 -3
@@ -198,9 +198,6 @@ extern unsigned long directmap_base_pdx;
 /* PDX of the first page in the frame table. */
 extern unsigned long frametable_base_pdx;
 
-extern unsigned long max_page;
-extern unsigned long total_pages;
-
 #define PDX_GROUP_SHIFT SECOND_SHIFT
 
 /* Boot-time pagetable setup */
xen/arch/arm/mm.c +0 -3
@@ -134,9 +134,6 @@ unsigned long directmap_base_pdx __read_
 unsigned long frametable_base_pdx __read_mostly;
 unsigned long frametable_virt_end __read_mostly;
 
-unsigned long max_page;
-unsigned long total_pages;
-
 extern char __init_begin[], __init_end[];
 
 /* Checking VA memory layout alignment. */
xen/arch/x86/include/asm/mm.h +0 -2
@@ -337,8 +337,6 @@ struct page_info
 #define maddr_get_owner(ma)   (page_get_owner(maddr_to_page((ma))))
 
 #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
-extern unsigned long max_page;
-extern unsigned long total_pages;
 void init_frametable(void);
 
 #define PDX_GROUP_SHIFT L2_PAGETABLE_SHIFT
xen/arch/x86/mm.c +0 -4
@@ -146,10 +146,6 @@ l1_pgentry_t __section(".bss.page_aligne
 l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
     l1_fixmap_x[L1_PAGETABLE_ENTRIES];
 
-/* Frame table size in pages. */
-unsigned long max_page;
-unsigned long total_pages;
-
 bool __read_mostly machine_to_phys_mapping_valid;
 
 struct rangeset *__read_mostly mmio_ro_ranges;
xen/common/page_alloc.c +2 -0
@@ -162,6 +162,8 @@
 #define PGT_TYPE_INFO_INITIALIZER 0
 #endif
 
+unsigned long __read_mostly max_page;
+unsigned long __read_mostly total_pages;
 paddr_t __ro_after_init mem_hotplug;
 
 /*
xen/include/xen/mm.h +2 -0
@@ -159,6 +159,8 @@ int assign_page(
 /* Dump info to serial console */
 void arch_dump_shared_mem_info(void);
 
+extern unsigned long max_page;
+extern unsigned long total_pages;
 extern paddr_t mem_hotplug;
 
 /*
Acked-by on v1 1/1
#2 lore raw
In reply to Jan Beulich

Hi Jan,

Quoted 6 lines · Jan Beulich

Common code references both, so the variables shouldn't need declaring and defining by every arch. While moving the definitions, add __read_mostly (__ro_after_init would only be appropriate when !mem_hotplug).

Cheers,

Quoted 71 lines
xen/arch/arm/include/asm/mm.h +0 -3
@@ -198,9 +198,6 @@ extern unsigned long directmap_base_pdx;
  /* PDX of the first page in the frame table. */
  extern unsigned long frametable_base_pdx;
 
-extern unsigned long max_page;
-extern unsigned long total_pages;
-
  #define PDX_GROUP_SHIFT SECOND_SHIFT
 
  /* Boot-time pagetable setup */
xen/arch/arm/mm.c +0 -3
@@ -134,9 +134,6 @@ unsigned long directmap_base_pdx __read_
  unsigned long frametable_base_pdx __read_mostly;
  unsigned long frametable_virt_end __read_mostly;
 
-unsigned long max_page;
-unsigned long total_pages;
-
  extern char __init_begin[], __init_end[];
 
  /* Checking VA memory layout alignment. */
xen/arch/x86/include/asm/mm.h +0 -2
@@ -337,8 +337,6 @@ struct page_info
  #define maddr_get_owner(ma)   (page_get_owner(maddr_to_page((ma))))
 
  #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
-extern unsigned long max_page;
-extern unsigned long total_pages;
  void init_frametable(void);
 
  #define PDX_GROUP_SHIFT L2_PAGETABLE_SHIFT
xen/arch/x86/mm.c +0 -4
@@ -146,10 +146,6 @@ l1_pgentry_t __section(".bss.page_aligne
  l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE)
      l1_fixmap_x[L1_PAGETABLE_ENTRIES];
 
-/* Frame table size in pages. */
-unsigned long max_page;
-unsigned long total_pages;
-
  bool __read_mostly machine_to_phys_mapping_valid;
 
  struct rangeset *__read_mostly mmio_ro_ranges;
xen/common/page_alloc.c +2 -0
@@ -162,6 +162,8 @@
  #define PGT_TYPE_INFO_INITIALIZER 0
  #endif
 
+unsigned long __read_mostly max_page;
+unsigned long __read_mostly total_pages;
  paddr_t __ro_after_init mem_hotplug;
 
  /*
xen/include/xen/mm.h +2 -0
@@ -159,6 +159,8 @@ int assign_page(
  /* Dump info to serial console */
  void arch_dump_shared_mem_info(void);
 
+extern unsigned long max_page;
+extern unsigned long total_pages;
  extern paddr_t mem_hotplug;
 
  /*
Signature · 1 line
Julien Grall