introduce a cpumask with all bits set
authorJuergen Gross <jgross@suse.com>
Thu, 14 Mar 2019 15:42:05 +0000 (16:42 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 14 Mar 2019 15:42:05 +0000 (16:42 +0100)
There are several places in Xen allocating a cpumask on the stack and
setting all bits in it just to use it as an initial mask for allowing
all cpus.

Save the stack space and omit the need for runtime initialization by
defining a globally accessible cpumask_all variable.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/io_apic.c
xen/common/cpu.c
xen/common/schedule.c
xen/include/xen/cpumask.h

index daa5e9e5ff5d6d7ca84b7f00d34ee6e874679640..a5344ed7279bf1c41d9a643de50ee52c202c31fe 100644 (file)
@@ -1881,7 +1881,6 @@ static void __init check_timer(void)
     int apic1, pin1, apic2, pin2;
     int vector, ret;
     unsigned long flags;
-    cpumask_t mask_all;
 
     local_irq_save(flags);
 
@@ -1892,8 +1891,7 @@ static void __init check_timer(void)
     vector = IRQ0_VECTOR;
     clear_irq_vector(0);
 
-    cpumask_setall(&mask_all);
-    if ((ret = bind_irq_vector(0, vector, &mask_all)))
+    if ((ret = bind_irq_vector(0, vector, &cpumask_all)))
         printk(KERN_ERR"..IRQ0 is not set correctly with ioapic!!!, err:%d\n", ret);
     
     irq_desc[0].status &= ~IRQ_DISABLED;
index 653a56b840b6c83e7daa962e10493194db64673b..836c62f97f4922c799a8b014d9b4a735abf35ac6 100644 (file)
@@ -11,6 +11,10 @@ unsigned int __read_mostly nr_cpumask_bits
     = BITS_TO_LONGS(NR_CPUS) * BITS_PER_LONG;
 #endif
 
+const cpumask_t cpumask_all = {
+    .bits[0 ... (BITS_TO_LONGS(NR_CPUS) - 1)] = ~0UL
+};
+
 /*
  * cpu_bit_bitmap[] is a special, "compressed" data structure that
  * represents all NR_CPUS bits binary values of 1<<nr.
index fd587622f4c3ee13d57334f90b1eab4b17031c0b..60755a631ed6199bf9b9dee0464cc422d64b5ed0 100644 (file)
@@ -256,9 +256,6 @@ static void sched_spin_unlock_double(spinlock_t *lock1, spinlock_t *lock2,
 int sched_init_vcpu(struct vcpu *v, unsigned int processor)
 {
     struct domain *d = v->domain;
-    cpumask_t allcpus;
-
-    cpumask_setall(&allcpus);
 
     v->processor = processor;
 
@@ -280,9 +277,9 @@ int sched_init_vcpu(struct vcpu *v, unsigned int processor)
      * domain-0 VCPUs, are pinned onto their respective physical CPUs.
      */
     if ( is_idle_domain(d) || d->is_pinned )
-        sched_set_affinity(v, cpumask_of(processor), &allcpus);
+        sched_set_affinity(v, cpumask_of(processor), &cpumask_all);
     else
-        sched_set_affinity(v, &allcpus, &allcpus);
+        sched_set_affinity(v, &cpumask_all, &cpumask_all);
 
     /* Idle VCPUs are scheduled immediately, so don't put them in runqueue. */
     if ( is_idle_domain(d) )
@@ -361,7 +358,6 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
     for_each_vcpu ( d, v )
     {
         spinlock_t *lock;
-        cpumask_t allcpus;
 
         vcpudata = v->sched_priv;
 
@@ -369,11 +365,9 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
         migrate_timer(&v->singleshot_timer, new_p);
         migrate_timer(&v->poll_timer, new_p);
 
-        cpumask_setall(&allcpus);
-
         lock = vcpu_schedule_lock_irq(v);
 
-        sched_set_affinity(v, &allcpus, &allcpus);
+        sched_set_affinity(v, &cpumask_all, &cpumask_all);
 
         v->processor = new_p;
         /*
@@ -812,8 +806,6 @@ int cpu_disable_scheduler(unsigned int cpu)
             if ( cpumask_empty(&online_affinity) &&
                  cpumask_test_cpu(cpu, v->cpu_hard_affinity) )
             {
-                cpumask_t allcpus;
-
                 if ( v->affinity_broken )
                 {
                     /* The vcpu is temporarily pinned, can't move it. */
@@ -831,8 +823,7 @@ int cpu_disable_scheduler(unsigned int cpu)
                 else
                     printk(XENLOG_DEBUG "Breaking affinity for %pv\n", v);
 
-                cpumask_setall(&allcpus);
-                sched_set_affinity(v, &allcpus, NULL);
+                sched_set_affinity(v, &cpumask_all, NULL);
             }
 
             if ( v->processor != cpu )
index b4cc92a4f55ddb30960ec8c6a94366a637fd19f6..1d73f9f3b6dd8872d0a2991bd7e73be3b85a0a3e 100644 (file)
@@ -306,6 +306,8 @@ static inline const cpumask_t *cpumask_of(unsigned int cpu)
 
 #define cpumask_bits(maskp) ((maskp)->bits)
 
+extern const cpumask_t cpumask_all;
+
 /*
  * cpumask_var_t: struct cpumask for stack usage.
  *