[PATCH] move max_page and total_pages to common code

Jan Beulich posted 1 patch 8 months, 3 weeks ago
Failed in applying to current master (apply log)
[PATCH] move max_page and total_pages to common code
Posted by Jan Beulich 8 months, 3 weeks ago
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).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/arm/include/asm/mm.h
+++ b/xen/arch/arm/include/asm/mm.h
@@ -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 */
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -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. */
--- a/xen/arch/x86/include/asm/mm.h
+++ b/xen/arch/x86/include/asm/mm.h
@@ -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
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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;
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -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;
 
 /*
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -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;
 
 /*
Re: [PATCH] move max_page and total_pages to common code
Posted by Julien Grall 8 months, 3 weeks ago
Hi Jan,

On 08/08/2023 11:47, Jan Beulich wrote:
> 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).
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

> 
> --- a/xen/arch/arm/include/asm/mm.h
> +++ b/xen/arch/arm/include/asm/mm.h
> @@ -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 */
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -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. */
> --- a/xen/arch/x86/include/asm/mm.h
> +++ b/xen/arch/x86/include/asm/mm.h
> @@ -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
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -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;
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -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;
>   
>   /*
> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -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;
>   
>   /*

-- 
Julien Grall
Re: [PATCH] move max_page and total_pages to common code
Posted by Andrew Cooper 8 months, 3 weeks ago
On 08/08/2023 11:47 am, Jan Beulich wrote:
> 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).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>