if (cpu != current->processor)
return;
local_irq_save(flags);
- if (!spin_trylock(&per_cpu(schedule_data, cpu).schedule_lock))
+ if (!spin_trylock(per_cpu(schedule_data, cpu).schedule_lock))
goto bail2;
if (v->processor != cpu)
goto bail1;
ia64_dv_serialize_data();
args->vcpu = NULL;
bail1:
- spin_unlock(&per_cpu(schedule_data, cpu).schedule_lock);
+ spin_unlock(per_cpu(schedule_data, cpu).schedule_lock);
bail2:
local_irq_restore(flags);
}
do {
cpu = v->processor;
if (cpu != current->processor) {
- spin_barrier(&per_cpu(schedule_data, cpu).schedule_lock);
+ spin_barrier(per_cpu(schedule_data, cpu).schedule_lock);
/* Flush VHPT on remote processors. */
smp_call_function_single(cpu, &ptc_ga_remote_func, &args, 1);
} else {
spc->runq_sort_last = sort_epoch;
- spin_lock_irqsave(&per_cpu(schedule_data, cpu).schedule_lock, flags);
+ spin_lock_irqsave(per_cpu(schedule_data, cpu).schedule_lock, flags);
runq = &spc->runq;
elem = runq->next;
elem = next;
}
- spin_unlock_irqrestore(&per_cpu(schedule_data, cpu).schedule_lock, flags);
+ spin_unlock_irqrestore(per_cpu(schedule_data, cpu).schedule_lock, flags);
}
static void
* cause a deadlock if the peer CPU is also load balancing and trying
* to lock this CPU.
*/
- if ( !spin_trylock(&per_cpu(schedule_data, peer_cpu).schedule_lock) )
+ if ( !spin_trylock(per_cpu(schedule_data, peer_cpu).schedule_lock) )
{
CSCHED_STAT_CRANK(steal_trylock_failed);
continue;
* Any work over there to steal?
*/
speer = csched_runq_steal(peer_cpu, cpu, snext->pri);
- spin_unlock(&per_cpu(schedule_data, peer_cpu).schedule_lock);
+ spin_unlock(per_cpu(schedule_data, peer_cpu).schedule_lock);
if ( speer != NULL )
return speer;
}
s_time_t delta;
ASSERT(v->runstate.state != new_state);
- ASSERT(spin_is_locked(&per_cpu(schedule_data,v->processor).schedule_lock));
+ ASSERT(spin_is_locked(per_cpu(schedule_data,v->processor).schedule_lock));
vcpu_urgent_count_update(v);
/* Switch to new CPU, then unlock old CPU. */
v->processor = new_cpu;
spin_unlock_irqrestore(
- &per_cpu(schedule_data, old_cpu).schedule_lock, flags);
+ per_cpu(schedule_data, old_cpu).schedule_lock, flags);
/* Wake on new CPU. */
vcpu_wake(v);
sd = &this_cpu(schedule_data);
- spin_lock_irq(&sd->schedule_lock);
+ spin_lock_irq(sd->schedule_lock);
stop_timer(&sd->s_timer);
if ( unlikely(prev == next) )
{
- spin_unlock_irq(&sd->schedule_lock);
+ spin_unlock_irq(sd->schedule_lock);
trace_continue_running(next);
return continue_running(prev);
}
ASSERT(!next->is_running);
next->is_running = 1;
- spin_unlock_irq(&sd->schedule_lock);
+ spin_unlock_irq(sd->schedule_lock);
perfc_incr(sched_ctx);
for_each_possible_cpu ( i )
{
- spin_lock_init(&per_cpu(schedule_data, i).schedule_lock);
+ spin_lock_init(&per_cpu(schedule_data, i)._lock);
+ per_cpu(schedule_data, i).schedule_lock
+ = &per_cpu(schedule_data, i)._lock;
init_timer(&per_cpu(schedule_data, i).s_timer, s_timer_fn, NULL, i);
}
for_each_online_cpu ( i )
{
- spin_lock(&per_cpu(schedule_data, i).schedule_lock);
+ spin_lock(per_cpu(schedule_data, i).schedule_lock);
printk("CPU[%02d] ", i);
SCHED_OP(dump_cpu_state, i);
- spin_unlock(&per_cpu(schedule_data, i).schedule_lock);
+ spin_unlock(per_cpu(schedule_data, i).schedule_lock);
}
local_irq_restore(flags);
#include <xen/percpu.h>
+/*
+ * In order to allow a scheduler to remap the lock->cpu mapping,
+ * we have a per-cpu pointer, along with a pre-allocated set of
+ * locks. The generic schedule init code will point each schedule lock
+ * pointer to the schedule lock; if the scheduler wants to remap them,
+ * it can simply modify the schedule locks.
+ *
+ * For cache betterness, keep the actual lock in the same cache area
+ * as the rest of the struct. Just have the scheduler point to the
+ * one it wants (This may be the one right in front of it).*/
struct schedule_data {
- spinlock_t schedule_lock; /* spinlock protecting curr */
+ spinlock_t *schedule_lock,
+ _lock;
struct vcpu *curr; /* current task */
struct vcpu *idle; /* idle task for this cpu */
void *sched_priv;
for ( ; ; )
{
+ /* NB: For schedulers with multiple cores per runqueue,
+ * a vcpu may change processor w/o changing runqueues;
+ * so we may release a lock only to grab it again.
+ *
+ * If that is measured to be an issue, then the check
+ * should be changed to checking if the locks pointed to
+ * by cpu and v->processor are still the same.
+ */
cpu = v->processor;
- spin_lock(&per_cpu(schedule_data, cpu).schedule_lock);
+ spin_lock(per_cpu(schedule_data, cpu).schedule_lock);
if ( likely(v->processor == cpu) )
break;
- spin_unlock(&per_cpu(schedule_data, cpu).schedule_lock);
+ spin_unlock(per_cpu(schedule_data, cpu).schedule_lock);
}
}
static inline void vcpu_schedule_unlock(struct vcpu *v)
{
- spin_unlock(&per_cpu(schedule_data, v->processor).schedule_lock);
+ spin_unlock(per_cpu(schedule_data, v->processor).schedule_lock);
}
#define vcpu_schedule_unlock_irq(v) \