Skip to contentSkip to conversation

mem-sharing: move (x86) / drop (Arm) arch_dump_shared_mem_info()

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mem-sharing: move (x86) / drop (Arm) arch_dump_shared_mem_info()

When !MEM_SHARING no useful output is produced. Move the function into mm/mem_sharing.c while conditionalizing the call to it, thus allowing to drop it altogether from Arm (and eliminating the need to introduce stubs on PPC and RISC-V).

---
I wasn't really sure whether introducing a stub in xen/mm.h would be any better than adding the (further) #ifdef to dump_domains().

We could go further and also eliminate the need for the stub variants of mem_sharing_get_nr_{shared,saved}_mfns() by moving the XENMEM_get_sharing_{shared,freed}_pages cases in {,compat_}arch_memory_op() into the already existing #ifdef-s there. Returning an error for those sub-ops may be slightly more appropriate than returning 0 when !MEM_SHARING.

xen/arch/arm/mm.c +0 -4
@@ -1297,10 +1297,6 @@ void free_init_memory(void)
     printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
 }
 
-void arch_dump_shared_mem_info(void)
-{
-}
-
 int steal_page(
     struct domain *d, struct page_info *page, unsigned int memflags)
 {
xen/arch/x86/mm.c +0 -7
@@ -6265,13 +6265,6 @@ void memguard_unguard_stack(void *p)
     map_pages_to_xen((unsigned long)p, virt_to_mfn(p), 1, PAGE_HYPERVISOR_RW);
 }
 
-void arch_dump_shared_mem_info(void)
-{
-    printk("Shared frames %u -- Saved frames %u\n",
-            mem_sharing_get_nr_shared_mfns(),
-            mem_sharing_get_nr_saved_mfns());
-}
-
 const struct platform_bad_page *__init get_platform_badpages(unsigned int *array_size)
 {
     u32 igd_id;
xen/arch/x86/mm/mem_sharing.c +7 -0
@@ -2329,3 +2329,10 @@ int mem_sharing_domctl(struct domain *d,
 
     return rc;
 }
+
+void arch_dump_shared_mem_info(void)
+{
+    printk("Shared frames %u -- Saved frames %u\n",
+            mem_sharing_get_nr_shared_mfns(),
+            mem_sharing_get_nr_saved_mfns());
+}
xen/common/keyhandler.c +2 -0
@@ -365,7 +365,9 @@ static void cf_check dump_domains(unsign
         }
     }
 
+#ifdef CONFIG_MEM_SHARING
     arch_dump_shared_mem_info();
+#endif
 
     rcu_read_unlock(&domlist_read_lock);
 }
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Jan Beulich

When !MEM_SHARING no useful output is produced. Move the function into mm/mem_sharing.c while conditionalizing the call to it, thus allowing to drop it altogether from Arm (and eliminating the need to introduce stubs on PPC and RISC-V).

---
I wasn't really sure whether introducing a stub in xen/mm.h would be any better than adding the (further) #ifdef to dump_domains().

We could go further and also eliminate the need for the stub variants of mem_sharing_get_nr_{shared,saved}_mfns() by moving the XENMEM_get_sharing_{shared,freed}_pages cases in {,compat_}arch_memory_op() into the already existing #ifdef-s there. Returning an error for those sub-ops may be slightly more appropriate than returning 0 when !MEM_SHARING.

xen/arch/arm/mm.c void free_init_memory(void) · line 1303

Quoted 7 lines
xen/arch/arm/mm.c +0 -4
@@ -1297,10 +1297,6 @@ void free_init_memory(void)
    printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
 }
 
-void arch_dump_shared_mem_info(void)
-{
-}
-

Hi Jan,

For the arm part:

#2 lore raw
Quoted 32 lines · Luca Fancellu
Quoted 22 lines · Jan Beulich

When !MEM_SHARING no useful output is produced. Move the function into mm/mem_sharing.c while conditionalizing the call to it, thus allowing to drop it altogether from Arm (and eliminating the need to introduce stubs on PPC and RISC-V).

---
I wasn't really sure whether introducing a stub in xen/mm.h would be any better than adding the (further) #ifdef to dump_domains().

We could go further and also eliminate the need for the stub variants of mem_sharing_get_nr_{shared,saved}_mfns() by moving the XENMEM_get_sharing_{shared,freed}_pages cases in {,compat_}arch_memory_op() into the already existing #ifdef-s there. Returning an error for those sub-ops may be slightly more appropriate than returning 0 when !MEM_SHARING.

xen/arch/arm/mm.c void free_init_memory(void) · line 1303

Quoted 7 lines
xen/arch/arm/mm.c +0 -4
@@ -1297,10 +1297,6 @@ void free_init_memory(void)
    printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
 }
 
-void arch_dump_shared_mem_info(void)
-{
-}
-

Hi Jan,

Quoted 3 lines

For the arm part:

#3 lore raw

Ping: [PATCH] mem-sharing: move (x86) / drop (Arm) arch_dump_shared_mem_info()

In reply to Jan Beulich
Quoted 6 lines · Jan Beulich

When !MEM_SHARING no useful output is produced. Move the function into mm/mem_sharing.c while conditionalizing the call to it, thus allowing to drop it altogether from Arm (and eliminating the need to introduce stubs on PPC and RISC-V).

Tamas - any chance of an ack?

Thanks, Jan

Quoted 66 lines

---
I wasn't really sure whether introducing a stub in xen/mm.h would be any better than adding the (further) #ifdef to dump_domains().

We could go further and also eliminate the need for the stub variants of mem_sharing_get_nr_{shared,saved}_mfns() by moving the XENMEM_get_sharing_{shared,freed}_pages cases in {,compat_}arch_memory_op() into the already existing #ifdef-s there. Returning an error for those sub-ops may be slightly more appropriate than returning 0 when !MEM_SHARING.

xen/arch/arm/mm.c +0 -4
@@ -1297,10 +1297,6 @@ void free_init_memory(void)
     printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10);
 }
 
-void arch_dump_shared_mem_info(void)
-{
-}
-
 int steal_page(
     struct domain *d, struct page_info *page, unsigned int memflags)
 {
xen/arch/x86/mm.c +0 -7
@@ -6265,13 +6265,6 @@ void memguard_unguard_stack(void *p)
     map_pages_to_xen((unsigned long)p, virt_to_mfn(p), 1, PAGE_HYPERVISOR_RW);
 }
 
-void arch_dump_shared_mem_info(void)
-{
-    printk("Shared frames %u -- Saved frames %u\n",
-            mem_sharing_get_nr_shared_mfns(),
-            mem_sharing_get_nr_saved_mfns());
-}
-
 const struct platform_bad_page *__init get_platform_badpages(unsigned int *array_size)
 {
     u32 igd_id;
xen/arch/x86/mm/mem_sharing.c +7 -0
@@ -2329,3 +2329,10 @@ int mem_sharing_domctl(struct domain *d,
 
     return rc;
 }
+
+void arch_dump_shared_mem_info(void)
+{
+    printk("Shared frames %u -- Saved frames %u\n",
+            mem_sharing_get_nr_shared_mfns(),
+            mem_sharing_get_nr_saved_mfns());
+}
xen/common/keyhandler.c +2 -0
@@ -365,7 +365,9 @@ static void cf_check dump_domains(unsign
         }
     }
 
+#ifdef CONFIG_MEM_SHARING
     arch_dump_shared_mem_info();
+#endif
 
     rcu_read_unlock(&domlist_read_lock);
 }