]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
x86/dom0: add verbose mode and print memory allocation stats
authorRoger Pau Monné <roger.pau@citrix.com>
Tue, 8 Jan 2019 09:08:48 +0000 (10:08 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 8 Jan 2019 09:08:48 +0000 (10:08 +0100)
Add a verbose option to the dom0 command line, so that dom0 builder
can print extra debug information when required.

Use this new verbose mode to print statistics about memory allocations
when populating dom0 p2m.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
docs/misc/xen-command-line.pandoc
xen/arch/x86/dom0_build.c
xen/arch/x86/hvm/dom0_build.c
xen/include/asm-x86/setup.h

index a755a67127b6141f3d9558c965bacbe5953369bb..99c283cb10af1f56f4cb0ef3f233bb104e9dbcae 100644 (file)
@@ -637,7 +637,7 @@ trace feature is only enabled in debugging builds of Xen.
 Specify the bit width of the DMA heap.
 
 ### dom0 (x86)
-> `= List of [ pvh | shadow ]`
+> `= List of [ pvh | shadow | verbose ]`
 
 > Sub-options:
 
@@ -654,6 +654,12 @@ Flag that makes a dom0 boot in PVHv2 mode.
 Flag that makes a dom0 use shadow paging. Only works when "pvh" is
 enabled.
 
+> `verbose`
+
+> Default: `false`
+
+Print debug information during dom0 build.
+
 ### dom0-iommu
 > `= List of [ passthrough | strict | map-inclusive ]`
 
index 54737daf6a972eb03f2b69b4370b4085c151bc50..c0bc022a838bee9ac380b511caf3d1955f3d1967 100644 (file)
@@ -281,6 +281,7 @@ struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0)
 bool __initdata opt_dom0_shadow;
 #endif
 bool __initdata dom0_pvh;
+bool __initdata dom0_verbose;
 
 /*
  * List of parameters that affect Dom0 creation:
@@ -306,6 +307,8 @@ static int __init parse_dom0_param(const char *s)
         else if ( (val = parse_boolean("shadow", s, ss)) >= 0 )
             opt_dom0_shadow = val;
 #endif
+        else if ( (val = parse_boolean("verbose", s, ss)) >= 0 )
+            dom0_verbose = val;
         else
             rc = -EINVAL;
 
index 5ae3a3206077e7695f85982da73c267958ebd4e0..303c44b5d9b36c04c7dfa37535d76a02bf9f439c 100644 (file)
@@ -60,6 +60,18 @@ static struct acpi_madt_interrupt_override __initdata *intsrcovr;
 static unsigned int __initdata acpi_nmi_sources;
 static struct acpi_madt_nmi_source __initdata *nmisrc;
 
+static unsigned int __initdata order_stats[MAX_ORDER + 1];
+
+static void __init print_order_stats(const struct domain *d)
+{
+    unsigned int i;
+
+    printk("Dom%u memory allocation stats:\n", d->domain_id);
+    for ( i = 0; i < ARRAY_SIZE(order_stats); i++ )
+        if ( order_stats[i] )
+            printk("order %2u allocations: %u\n", i, order_stats[i]);
+}
+
 static int __init modify_identity_mmio(struct domain *d, unsigned long pfn,
                                        unsigned long nr_pages, const bool map)
 {
@@ -169,6 +181,7 @@ static int __init pvh_populate_memory_range(struct domain *d,
         }
         start += 1UL << order;
         nr_pages -= 1UL << order;
+        order_stats[order]++;
         if ( (++i % MAP_MAX_ITER) == 0 )
             process_pending_softirqs();
     }
@@ -465,6 +478,9 @@ static int __init pvh_setup_p2m(struct domain *d)
             return rc;
     }
 
+    if ( dom0_verbose )
+        print_order_stats(d);
+
     return 0;
 #undef MB1_PAGES
 }
index 1c8078340d1f9309febf36105bed7f40c41f7edf..bb4c38567c68837e1a8c2a9b610f6517ede0ccb0 100644 (file)
@@ -65,6 +65,7 @@ extern bool opt_dom0_shadow;
 #define opt_dom0_shadow false
 #endif
 extern bool dom0_pvh;
+extern bool dom0_verbose;
 
 #define max_init_domid (0)