]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
x86/genapic: remove indirection from genapic hook accesses
authorJan Beulich <jbeulich@suse.com>
Thu, 8 Nov 2018 14:59:14 +0000 (15:59 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 8 Nov 2018 14:59:14 +0000 (15:59 +0100)
Instead of loading a pointer at each use site, have a single runtime
instance of struct genapic, copying into it from the individual
instances. The individual instances can this way also be moved to .init
(also adjust apic_probe[] at this occasion).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/apic.c
xen/arch/x86/genapic/bigsmp.c
xen/arch/x86/genapic/default.c
xen/arch/x86/genapic/probe.c
xen/arch/x86/genapic/x2apic.c
xen/arch/x86/mpparse.c
xen/arch/x86/smp.c
xen/include/asm-x86/genapic.h
xen/include/asm-x86/mach-generic/mach_apic.h

index df6aea75ab044295c3a93a2e55a1bc8f02881756..7120107b0c417966940e716759e0ef02a0c71f00 100644 (file)
@@ -944,8 +944,8 @@ void __init x2apic_bsp_setup(void)
 
     force_iommu = 1;
 
-    genapic = apic_x2apic_probe();
-    printk("Switched to APIC driver %s.\n", genapic->name);
+    genapic = *apic_x2apic_probe();
+    printk("Switched to APIC driver %s.\n", genapic.name);
 
     if ( !x2apic_enabled )
     {
index 294902ba852bea63c3d82778debe7fc6fbad2a88..91a973ac16513209acf7993a8e251f46d7756709 100644 (file)
@@ -42,7 +42,7 @@ static __init int probe_bigsmp(void)
        return def_to_bigsmp;
 } 
 
-const struct genapic apic_bigsmp = {
+const struct genapic __initconstrel apic_bigsmp = {
        APIC_INIT("bigsmp", probe_bigsmp),
        GENAPIC_PHYS
 };
index 4d1a06fb8248dc550eff88b7a168b222532e1d0e..53ebf20a3feac5f0d833b93eb4862db160a67b0e 100644 (file)
@@ -20,7 +20,7 @@ static __init int probe_default(void)
        return 1;
 } 
 
-const struct genapic apic_default = {
+const struct genapic __initconstrel apic_default = {
        APIC_INIT("default", probe_default),
        GENAPIC_FLAT
 };
index af3745aa21f61a6c59de8bd62dfd2f97c842d475..6aa7eb7b1c45a1de552726ffd458e1a7cd93b307 100644 (file)
 #include <asm/mach-generic/mach_apic.h>
 #include <asm/setup.h>
 
-extern const struct genapic apic_bigsmp;
+struct genapic __read_mostly genapic;
 
-const struct genapic *__read_mostly genapic;
-
-const struct genapic *apic_probe[] __initdata = {
+const struct genapic *const __initconstrel apic_probe[] = {
        &apic_bigsmp, 
        &apic_default,  /* must be last */
        NULL,
@@ -36,11 +34,11 @@ void __init generic_bigsmp_probe(void)
         * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
         */
 
-       if (!cmdline_apic && genapic == &apic_default)
+       if (!cmdline_apic && genapic.name == apic_default.name)
                if (apic_bigsmp.probe()) {
-                       genapic = &apic_bigsmp;
+                       genapic = apic_bigsmp;
                        printk(KERN_INFO "Overriding APIC driver with %s\n",
-                              genapic->name);
+                              genapic.name);
                }
 }
 
@@ -50,7 +48,7 @@ static int __init genapic_apic_force(const char *str)
 
        for (i = 0; apic_probe[i]; i++)
                if (!strcmp(apic_probe[i]->name, str)) {
-                       genapic = apic_probe[i];
+                       genapic = *apic_probe[i];
                        rc = 0;
                }
 
@@ -66,18 +64,18 @@ void __init generic_apic_probe(void)
        record_boot_APIC_mode();
 
        check_x2apic_preenabled();
-       cmdline_apic = changed = (genapic != NULL);
+       cmdline_apic = changed = !!genapic.name;
 
        for (i = 0; !changed && apic_probe[i]; i++) { 
                if (apic_probe[i]->probe()) {
                        changed = 1;
-                       genapic = apic_probe[i];
+                       genapic = *apic_probe[i];
                } 
        }
        if (!changed) 
-               genapic = &apic_default;
+               genapic = apic_default;
 
-       printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
+       printk(KERN_INFO "Using APIC driver %s\n", genapic.name);
 } 
 
 /* These functions can switch the APIC even after the initial ->probe() */
@@ -88,9 +86,9 @@ int __init mps_oem_check(struct mp_config_table *mpc, char *oem, char *productid
        for (i = 0; apic_probe[i]; ++i) { 
                if (apic_probe[i]->mps_oem_check(mpc,oem,productid)) { 
                        if (!cmdline_apic) {
-                               genapic = apic_probe[i];
+                               genapic = *apic_probe[i];
                                printk(KERN_INFO "Switched to APIC driver `%s'.\n", 
-                                      genapic->name);
+                                      genapic.name);
                        }
                        return 1;
                } 
@@ -104,9 +102,9 @@ int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
        for (i = 0; apic_probe[i]; ++i) { 
                if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) { 
                        if (!cmdline_apic) {
-                               genapic = apic_probe[i];
+                               genapic = *apic_probe[i];
                                printk(KERN_INFO "Switched to APIC driver `%s'.\n", 
-                                      genapic->name);
+                                      genapic.name);
                        }
                        return 1;
                } 
index 5df70b0cf637c7ec2e7593a7ae53e83d5ddfe3d1..7e2e89d8815f859b2306b35fab3b36491e4be7e4 100644 (file)
@@ -163,7 +163,7 @@ static void send_IPI_mask_x2apic_cluster(const cpumask_t *cpumask, int vector)
     local_irq_restore(flags);
 }
 
-static const struct genapic apic_x2apic_phys = {
+static const struct genapic __initconstrel apic_x2apic_phys = {
     APIC_INIT("x2apic_phys", NULL),
     .int_delivery_mode = dest_Fixed,
     .int_dest_mode = 0 /* physical delivery */,
@@ -175,7 +175,7 @@ static const struct genapic apic_x2apic_phys = {
     .send_IPI_self = send_IPI_self_x2apic
 };
 
-static const struct genapic apic_x2apic_cluster = {
+static const struct genapic __initconstrel apic_x2apic_cluster = {
     APIC_INIT("x2apic_cluster", NULL),
     .int_delivery_mode = dest_LowestPrio,
     .int_dest_mode = 1 /* logical delivery */,
@@ -259,6 +259,6 @@ void __init check_x2apic_preenabled(void)
     {
         printk("x2APIC mode is already enabled by BIOS.\n");
         x2apic_enabled = 1;
-        genapic = apic_x2apic_probe();
+        genapic = *apic_x2apic_probe();
     }
 }
index f2b6d6bdabf2369ac52a19f5f08fc08893c25bd5..16c93a935d882f812ba86276fd9b25a83f0307a9 100644 (file)
@@ -162,7 +162,8 @@ static int MP_processor_info_x(struct mpc_config_processor *m,
                return -ENOSPC;
        }
 
-       if (num_processors >= 8 && hotplug && genapic == &apic_default) {
+       if (num_processors >= 8 && hotplug
+           && genapic.name == apic_default.name) {
                printk(KERN_WARNING "WARNING: CPUs limit of 8 reached."
                        " Processor ignored.\n");
                return -ENOSPC;
index 63e819ca3837fda1fc6df893bcfa3b9d0ea97345..b15d4f05df162ab33648e13cd92795f297e3afa5 100644 (file)
 
 void send_IPI_mask(const cpumask_t *mask, int vector)
 {
-    genapic->send_IPI_mask(mask, vector);
+    genapic.send_IPI_mask(mask, vector);
 }
 
 void send_IPI_self(int vector)
 {
-    genapic->send_IPI_self(vector);
+    genapic.send_IPI_self(vector);
 }
 
 /*
index 8aeb28ecda1c89137ccba64fa24549a5dd2f41fa..5aa35ceb5f10dc0bdc50c94df625cdb4cfc872c9 100644 (file)
@@ -47,8 +47,9 @@ struct genapic {
        APICFUNC(mps_oem_check), \
        APICFUNC(acpi_madt_oem_check)
 
-extern const struct genapic *genapic;
+extern struct genapic genapic;
 extern const struct genapic apic_default;
+extern const struct genapic apic_bigsmp;
 
 void send_IPI_self_legacy(uint8_t vector);
 
index 3fed22c81a0ff852856eee2047e080f0265f9f00..0984554d3684e21de4025471085adc95c5a636ca 100644 (file)
 #define esr_disable (0)
 
 /* The following are dependent on APIC delivery mode (logical vs. physical). */
-#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
-#define INT_DEST_MODE (genapic->int_dest_mode)
+#define INT_DELIVERY_MODE (genapic.int_delivery_mode)
+#define INT_DEST_MODE (genapic.int_dest_mode)
 #define TARGET_CPUS ((const typeof(cpu_online_map) *)&cpu_online_map)
-#define init_apic_ldr (genapic->init_apic_ldr)
-#define clustered_apic_check (genapic->clustered_apic_check) 
-#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
-#define vector_allocation_cpumask(cpu) (genapic->vector_allocation_cpumask(cpu))
+#define init_apic_ldr (genapic.init_apic_ldr)
+#define clustered_apic_check (genapic.clustered_apic_check)
+#define cpu_mask_to_apicid (genapic.cpu_mask_to_apicid)
+#define vector_allocation_cpumask(cpu) (genapic.vector_allocation_cpumask(cpu))
 
 static inline void enable_apic_mode(void)
 {