eliminate cpu_test_xyz()
authorJan Beulich <jbeulich@suse.com>
Tue, 8 Nov 2011 09:33:02 +0000 (10:33 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 8 Nov 2011 09:33:02 +0000 (10:33 +0100)
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
15 files changed:
xen/arch/ia64/linux-xen/smp.c
xen/arch/ia64/linux-xen/smpboot.c
xen/arch/ia64/xen/domain.c
xen/arch/ia64/xen/regionreg.c
xen/arch/ia64/xen/vhpt.c
xen/arch/x86/cpu/common.c
xen/arch/x86/smp.c
xen/arch/x86/smpboot.c
xen/arch/x86/time.c
xen/common/cpupool.c
xen/common/kexec.c
xen/common/sched_credit2.c
xen/common/sched_sedf.c
xen/common/trace.c
xen/include/xen/cpumask.h

index 0ee2e54103187665806389d87d46a8497bc3af37..528346561759c3cbf2badbc7df7fc9a06549032b 100644 (file)
@@ -68,7 +68,7 @@ void smp_send_event_check_mask(const cpumask_t *mask)
     //printf("smp_send_event_check_mask called\n");
 
     for (cpu = 0; cpu < NR_CPUS; ++cpu)
-        if (cpu_isset(cpu, *mask) && cpu != smp_processor_id())
+        if (cpumask_test_cpu(cpu, mask) && cpu != smp_processor_id())
            platform_send_ipi(cpu, IA64_IPI_RESCHEDULE, IA64_IPI_DM_INT, 0);
 }
 #endif
index 64c28f77648781b6b72c289b80257018a6d9e0e7..09fd0ebacbac7f283ec01b06d4e996b2f2e3f13a 100644 (file)
@@ -548,13 +548,13 @@ do_rest:
         */
        Dprintk("Waiting on callin_map ...");
        for (timeout = 0; timeout < 100000; timeout++) {
-               if (cpu_isset(cpu, cpu_callin_map))
+               if (cpumask_test_cpu(cpu, &cpu_callin_map))
                        break;  /* It has booted */
                udelay(100);
        }
        Dprintk("\n");
 
-       if (!cpu_isset(cpu, cpu_callin_map)) {
+       if (!cpumask_test_cpu(cpu, &cpu_callin_map)) {
                printk(KERN_ERR "Processor 0x%x/0x%x is stuck.\n", cpu, sapicid);
                ia64_cpu_to_sapicid[cpu] = -1;
                cpu_clear(cpu, cpu_online_map);  /* was set in smp_callin() */
@@ -818,7 +818,7 @@ __cpu_up (unsigned int cpu)
         * Already booted cpu? not valid anymore since we dont
         * do idle loop tightspin anymore.
         */
-       if (cpu_isset(cpu, cpu_callin_map))
+       if (cpumask_test_cpu(cpu, &cpu_callin_map))
                return -EINVAL;
 
        if (!per_cpu(cpu_sibling_mask, cpu) &&
index fd7c13c4a270f775767f0db3946e2d52f751d483..e48e31876be7483e56d9768fccdb9934522ecd9a 100644 (file)
@@ -140,7 +140,7 @@ static void flush_cache_for_context_switch(struct vcpu *next)
 
        if (is_idle_vcpu(next) ||
            __test_and_clear_bit(cpu, &next->arch.cache_coherent_map)) {
-               if (cpu_test_and_clear(cpu, cpu_cache_coherent_map)) {
+               if (cpumask_test_and_clear_cpu(cpu, &cpu_cache_coherent_map)) {
                        unsigned long flags;
                        u64 progress = 0;
                        s64 status;
index c23cb903e8dac95e8c99282df4fcf6d5eb8a4a1f..b2c7c50f6a2ccbb3334aaf87576ba38bd57c24dd 100644 (file)
@@ -320,8 +320,8 @@ int set_one_rr_efi(unsigned long rr, unsigned long val)
        else {
                if (current && VMX_DOMAIN(current))
                        vpd = __get_cpu_var(inserted_vpd);
-               ia64_new_rr7_efi(val, cpu_isset(smp_processor_id(),
-                                percpu_set), vpd);
+               ia64_new_rr7_efi(val, cpumask_test_cpu(smp_processor_id(),
+                                                      &percpu_set), vpd);
        }
 
        return 1;
@@ -342,8 +342,8 @@ set_one_rr_efi_restore(unsigned long rr, unsigned long val)
                   and strcut domain are initialized. */
                if (unlikely(current == NULL || current->domain == NULL ||
                             is_idle_vcpu(current)))
-                       ia64_new_rr7_efi(val, cpu_isset(smp_processor_id(),
-                                                       percpu_set),
+                       ia64_new_rr7_efi(val, cpumask_test_cpu(smp_processor_id(),
+                                                              &percpu_set),
                                         0UL);
                else if (VMX_DOMAIN(current))
                        __vmx_switch_rr7_vcpu(current, val);
index e5e5e2f721884d6d529ff7589b169b39677f3548..5af17ba7ffc21586a9fc4037dd3815348765d2a8 100644 (file)
@@ -553,7 +553,7 @@ void flush_tlb_mask(const cpumask_t *mask)
     int cpu;
 
     cpu = smp_processor_id();
-    if (cpu_isset(cpu, *mask))
+    if (cpumask_test_cpu(cpu, mask))
         flush_tlb_vhpt_all (NULL);
 
     if (cpumask_subset(mask, cpumask_of(cpu)))
index b1239ad3a9926d74c71bf53caa1118299ccd8597..3cea4ca66db1ac22ef185fc36f0b52f76ed160d6 100644 (file)
@@ -624,7 +624,7 @@ void __cpuinit cpu_init(void)
                .limit = LAST_RESERVED_GDT_BYTE
        };
 
-       if (cpu_test_and_set(cpu, cpu_initialized)) {
+       if (cpumask_test_and_set_cpu(cpu, &cpu_initialized)) {
                printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
                for (;;) local_irq_enable();
        }
index 8b96c024c0d8b32f3660cd25683d6a8f0a7f8149..84ba4bba29bd7c21cd0796ada7bc8bb0f8d66618 100644 (file)
@@ -234,7 +234,7 @@ void flush_area_mask(const cpumask_t *mask, const void *va, unsigned int flags)
 {
     ASSERT(local_irq_is_enabled());
 
-    if ( cpu_isset(smp_processor_id(), *mask) )
+    if ( cpumask_test_cpu(smp_processor_id(), mask) )
         flush_area_local(va, flags);
 
     if ( !cpumask_subset(mask, cpumask_of(smp_processor_id())) )
index e1fd15e3586a657f94b00404515fd7e175802794..855e6216f15ef560cb1350d532b4e1084aaab3d2 100644 (file)
@@ -138,7 +138,7 @@ static void synchronize_tsc_master(unsigned int slave)
         return;
 
     if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) &&
-         !cpu_isset(slave, tsc_sync_cpu_mask) )
+         !cpumask_test_cpu(slave, &tsc_sync_cpu_mask) )
         return;
 
     for ( i = 1; i <= 5; i++ )
@@ -162,7 +162,7 @@ static void synchronize_tsc_slave(unsigned int slave)
         return;
 
     if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) &&
-         !cpu_isset(slave, tsc_sync_cpu_mask) )
+         !cpumask_test_cpu(slave, &tsc_sync_cpu_mask) )
         return;
 
     for ( i = 1; i <= 5; i++ )
@@ -956,7 +956,7 @@ int __cpu_up(unsigned int cpu)
         return ret;
 
     set_cpu_state(CPU_STATE_ONLINE);
-    while ( !cpu_isset(cpu, cpu_online_map) )
+    while ( !cpu_online(cpu) )
     {
         cpu_relax();
         process_pending_softirqs();
index e47e1b281dceee7001c25092c7c9f26f533cb6d9..1996890e3c531bcc8945d090c93c887bf3d3c2ff 100644 (file)
@@ -1580,7 +1580,7 @@ void pit_broadcast_exit(void)
 {
     int cpu = smp_processor_id();
 
-    if ( cpu_test_and_clear(cpu, pit_broadcast_mask) )
+    if ( cpumask_test_and_clear_cpu(cpu, &pit_broadcast_mask) )
         reprogram_timer(this_cpu(timer_deadline));
 }
 
index e3ad20bf37922ab6127f4ee5f72a23784fc8d692..781f667658972011bcd8fcc5fa23cb568257106b 100644 (file)
@@ -299,7 +299,7 @@ int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu)
     ret = -EBUSY;
     if ( (cpupool_moving_cpu != -1) && (cpu != cpupool_moving_cpu) )
         goto out;
-    if ( cpu_isset(cpu, cpupool_locked_cpus) )
+    if ( cpumask_test_cpu(cpu, &cpupool_locked_cpus) )
         goto out;
 
     ret = 0;
@@ -499,7 +499,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
         if ( cpu >= nr_cpu_ids )
             goto addcpu_out;
         ret = -EBUSY;
-        if ( !cpu_isset(cpu, cpupool_free_cpus) )
+        if ( !cpumask_test_cpu(cpu, &cpupool_free_cpus) )
             goto addcpu_out;
         c = cpupool_find_by_id(op->cpupool_id);
         ret = -ENOENT;
index cd37636cf88c8a70b09364c0efe27398c70379c1..1a3b52382dfecec46958394b087ea1a4b08bd8f8 100644 (file)
@@ -169,7 +169,7 @@ void kexec_crash_save_cpu(void)
     ELF_Prstatus *prstatus;
     crash_xen_core_t *xencore;
 
-    if ( cpu_test_and_set(cpu, crash_saved_cpus) )
+    if ( cpumask_test_and_set_cpu(cpu, &crash_saved_cpus) )
         return;
 
     prstatus = (ELF_Prstatus *)ELFNOTE_DESC(note);
@@ -187,7 +187,7 @@ crash_xen_info_t *kexec_crash_save_info(void)
     crash_xen_info_t info;
     crash_xen_info_t *out = (crash_xen_info_t *)ELFNOTE_DESC(xen_crash_note);
 
-    BUG_ON(!cpu_test_and_set(cpu, crash_saved_cpus));
+    BUG_ON(!cpumask_test_and_set_cpu(cpu, &crash_saved_cpus));
 
     memset(&info, 0, sizeof(info));
     info.xen_major_version = xen_major_version();
index 0592c96c9e1b5c128010c95c1919b4fe7dc73001..a933535570d6e74a09b20ab945c2c66bc53958d0 100644 (file)
@@ -1366,7 +1366,7 @@ csched_vcpu_migrate(
     struct csched_runqueue_data *trqd;
 
     /* Check if new_cpu is valid */
-    BUG_ON(!cpu_isset(new_cpu, CSCHED_PRIV(ops)->initialized));
+    BUG_ON(!cpumask_test_cpu(new_cpu, &CSCHED_PRIV(ops)->initialized));
 
     trqd = RQD(ops, new_cpu);
 
@@ -1602,10 +1602,10 @@ csched_schedule(
              scurr->vcpu->vcpu_id,
              now);
 
-    BUG_ON(!cpu_isset(cpu, CSCHED_PRIV(ops)->initialized));
+    BUG_ON(!cpumask_test_cpu(cpu, &CSCHED_PRIV(ops)->initialized));
 
     rqd = RQD(ops, cpu);
-    BUG_ON(!cpu_isset(cpu, rqd->active));
+    BUG_ON(!cpumask_test_cpu(cpu, &rqd->active));
 
     /* Protected by runqueue lock */        
 
@@ -1637,7 +1637,7 @@ csched_schedule(
     BUG_ON(!is_idle_vcpu(scurr->vcpu) && scurr->rqd != rqd);
 
     /* Clear "tickled" bit now that we've been scheduled */
-    if ( cpu_isset(cpu, rqd->tickled) )
+    if ( cpumask_test_cpu(cpu, &rqd->tickled) )
         cpu_clear(cpu, rqd->tickled);
 
     /* Update credits */
@@ -1708,7 +1708,7 @@ csched_schedule(
         }
 
         /* Clear the idle mask if necessary */
-        if ( cpu_isset(cpu, rqd->idle) )
+        if ( cpumask_test_cpu(cpu, &rqd->idle) )
             cpu_clear(cpu, rqd->idle);
 
         snext->start_time = now;
@@ -1724,7 +1724,7 @@ csched_schedule(
     else
     {
         /* Update the idle mask if necessary */
-        if ( !cpu_isset(cpu, rqd->idle) )
+        if ( !cpumask_test_cpu(cpu, &rqd->idle) )
             cpu_set(cpu, rqd->idle);
         /* Make sure avgload gets updated periodically even
          * if there's no activity */
@@ -1885,7 +1885,7 @@ static void init_pcpu(const struct scheduler *ops, int cpu)
 
     spin_lock_irqsave(&prv->lock, flags);
 
-    if ( cpu_isset(cpu, prv->initialized) )
+    if ( cpumask_test_cpu(cpu, &prv->initialized) )
     {
         printk("%s: Strange, cpu %d already initialized!\n", __func__, cpu);
         spin_unlock_irqrestore(&prv->lock, flags);
@@ -1912,7 +1912,7 @@ static void init_pcpu(const struct scheduler *ops, int cpu)
     rqd=prv->rqd + rqi;
 
     printk("Adding cpu %d to runqueue %d\n", cpu, rqi);
-    if ( ! cpu_isset(rqi, prv->active_queues) )
+    if ( ! cpumask_test_cpu(rqi, &prv->active_queues) )
     {
         printk(" First cpu on runqueue, activating\n");
         activate_runqueue(prv, rqi);
@@ -1963,7 +1963,7 @@ csched_free_pdata(const struct scheduler *ops, void *pcpu, int cpu)
 
     spin_lock_irqsave(&prv->lock, flags);
 
-    BUG_ON( !cpu_isset(cpu, prv->initialized));
+    BUG_ON(!cpumask_test_cpu(cpu, &prv->initialized));
     
     /* Find the old runqueue and remove this cpu from it */
     rqi = prv->runq_map[cpu];
@@ -1973,7 +1973,7 @@ csched_free_pdata(const struct scheduler *ops, void *pcpu, int cpu)
     /* No need to save IRQs here, they're already disabled */
     spin_lock(&rqd->lock);
 
-    BUG_ON(!cpu_isset(cpu, rqd->idle));
+    BUG_ON(!cpumask_test_cpu(cpu, &rqd->idle));
 
     printk("Removing cpu %d from runqueue %d\n", cpu, rqi);
 
index 6fe7ffa8b2d7656ff40f16d4235f484d02b7cf2d..dfb7ceef1442b7321d35b11ca7b78bd3633c5c96 100644 (file)
@@ -820,7 +820,7 @@ static struct task_slice sedf_do_schedule(
     /* Tasklet work (which runs in idle VCPU context) overrides all else. */
     if ( tasklet_work_scheduled ||
          (list_empty(runq) && list_empty(waitq)) ||
-         unlikely(!cpu_isset(cpu, *SEDF_CPUONLINE(per_cpu(cpupool, cpu)))) )
+         unlikely(!cpumask_test_cpu(cpu, SEDF_CPUONLINE(per_cpu(cpupool, cpu)))) )
     {
         ret.task = IDLETASK(cpu);
         ret.time = SECONDS(1);
index 746bf4b75050c80b7ccbb9f1fae4270f69097a81..5772f248f7b9b37b55a03a9b8b683d5fb82147b2 100644 (file)
@@ -323,7 +323,7 @@ int trace_will_trace_event(u32 event)
                 & ((event >> TRC_SUBCLS_SHIFT) & 0xf )) == 0 )
         return 0;
 
-    if ( !cpu_isset(smp_processor_id(), tb_cpu_mask) )
+    if ( !cpumask_test_cpu(smp_processor_id(), &tb_cpu_mask) )
         return 0;
 
     return 1;
@@ -711,7 +711,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,
                 & ((event >> TRC_SUBCLS_SHIFT) & 0xf )) == 0 )
         return;
 
-    if ( !cpu_isset(smp_processor_id(), tb_cpu_mask) )
+    if ( !cpumask_test_cpu(smp_processor_id(), &tb_cpu_mask) )
         return;
 
     /* Read tb_init_done /before/ t_bufs. */
index 494103570be942bf454241daa7e1981427c7b97f..4aa8933e09039d1b063de29024126ef8eb765e4f 100644 (file)
@@ -19,6 +19,7 @@
  * void cpumask_clear(mask)            clear all bits
  * int cpumask_test_cpu(cpu, mask)     true iff bit 'cpu' set in mask
  * int cpumask_test_and_set_cpu(cpu, mask) test and set bit 'cpu' in mask
+ * int cpumask_test_and_clear_cpu(cpu, mask) test and clear bit 'cpu' in mask
  *
  * void cpumask_and(dst, src1, src2)   dst = src1 & src2  [intersection]
  * void cpumask_or(dst, src1, src2)    dst = src1 | src2  [union]
  * for_each_present_cpu(cpu)           for-loop cpu over cpu_present_map
  *
  * Subtlety:
- * 1) The 'type-checked' form of cpu_isset() causes gcc (3.3.2, anyway)
+ * 1) The 'type-checked' form of cpumask_test_cpu() causes gcc (3.3.2, anyway)
  *    to generate slightly worse code.  Note for example the additional
  *    40 lines of assembly code compiling the "for each possible cpu"
  *    loops buried in the disk_stat_read() macros calls when compiling
  *    drivers/block/genhd.c (arch i386, CONFIG_SMP=y).  So use a simple
- *    one-line #define for cpu_isset(), instead of wrapping an inline
+ *    one-line #define for cpumask_test_cpu(), instead of wrapping an inline
  *    inside a macro, the way we do the other calls.
  */
 
@@ -121,17 +122,12 @@ static inline void cpumask_clear(cpumask_t *dstp)
 /* No static inline type checking - see Subtlety (1) above. */
 #define cpumask_test_cpu(cpu, cpumask) \
        test_bit(cpumask_check(cpu), (cpumask)->bits)
-#define cpu_isset(cpu, cpumask) test_bit((cpu), (cpumask).bits)
 
-#define cpu_test_and_set(cpu, cpumask) \
-       cpumask_test_and_set_cpu(cpu, &(cpumask))
 static inline int cpumask_test_and_set_cpu(int cpu, cpumask_t *addr)
 {
        return test_and_set_bit(cpumask_check(cpu), addr->bits);
 }
 
-#define cpu_test_and_clear(cpu, cpumask) \
-       cpumask_test_and_clear_cpu(cpu, &(cpumask))
 static inline int cpumask_test_and_clear_cpu(int cpu, cpumask_t *addr)
 {
        return test_and_clear_bit(cpumask_check(cpu), addr->bits);
@@ -444,9 +440,9 @@ extern cpumask_t cpu_present_map;
 #define num_online_cpus()      cpumask_weight(&cpu_online_map)
 #define num_possible_cpus()    cpumask_weight(&cpu_possible_map)
 #define num_present_cpus()     cpumask_weight(&cpu_present_map)
-#define cpu_online(cpu)                cpu_isset((cpu), cpu_online_map)
-#define cpu_possible(cpu)      cpu_isset((cpu), cpu_possible_map)
-#define cpu_present(cpu)       cpu_isset((cpu), cpu_present_map)
+#define cpu_online(cpu)                cpumask_test_cpu(cpu, &cpu_online_map)
+#define cpu_possible(cpu)      cpumask_test_cpu(cpu, &cpu_possible_map)
+#define cpu_present(cpu)       cpumask_test_cpu(cpu, &cpu_present_map)
 #else
 #define num_online_cpus()      1
 #define num_possible_cpus()    1