@@ -221,6 +221,9 @@ config ARGO
menu "Schedulers"
visible if EXPERT = "y"
+config TACC_NEEDS_LOCK
+ bool
+
config SCHED_CREDIT
bool "Credit scheduler support"
default y
@@ -1562,6 +1562,14 @@ static void schedule(void)
context_switch(prev, next);
}
+#ifdef CONFIG_TACC_NEEDS_LOCK
+#define tacc_lock(tacc) spin_lock(&tacc->tacc_lock)
+#define tacc_unlock(tacc) spin_unlock(&tacc->tacc_lock)
+#else
+#define tacc_lock(tacc)
+#define tacc_unlock(tacc)
+#endif
+
DEFINE_PER_CPU(struct tacc, tacc);
static void tacc_state_change(enum TACC_STATES new_state)
@@ -1571,6 +1579,7 @@ static void tacc_state_change(enum TACC_STATES new_state)
unsigned long flags;
local_irq_save(flags);
+ tacc_lock(tacc);
now = NOW();
delta = now - tacc->state_entry_time;
@@ -1584,6 +1593,7 @@ static void tacc_state_change(enum TACC_STATES new_state)
tacc->state = new_state;
tacc->state_entry_time = now;
+ tacc_unlock(tacc);
local_irq_restore(flags);
}
@@ -1621,7 +1631,9 @@ void tacc_irq_enter(int place)
if ( tacc->irq_cnt == 0 )
{
+ tacc_lock(tacc);
tacc->irq_enter_time = NOW();
+ tacc_unlock(tacc);
}
tacc->irq_cnt++;
@@ -1636,8 +1648,10 @@ void tacc_irq_exit(int place)
ASSERT(tacc->irq_cnt > 0);
if ( tacc->irq_cnt == 1 )
{
+ tacc_lock(tacc);
tacc->irq_time = NOW() - tacc->irq_enter_time;
tacc->irq_enter_time = 0;
+ tacc_unlock(tacc);
}
tacc->irq_cnt--;
@@ -1653,6 +1667,36 @@ s_time_t tacc_get_guest_time(struct tacc *tacc)
return guest_time;
}
+#ifdef CONFIG_TACC_NEEDS_LOCK
+s_time_t tacc_get_guest_time_cpu(int cpu)
+{
+ struct tacc* tacc = &per_cpu(tacc, cpu);
+ s_time_t guest_time;
+ s_time_t now;
+
+ tacc_lock(tacc);
+
+ now = NOW();
+ guest_time = tacc_get_guest_time(tacc);
+ if (tacc->state == TACC_GUEST || tacc->state == TACC_GSYNC)
+ {
+ guest_time += NOW() - tacc->state_entry_time;
+ }
+
+ if (tacc->irq_enter_time)
+ {
+ guest_time -= NOW() - tacc->irq_enter_time;
+ }
+
+ guest_time -= tacc->irq_time;
+
+ tacc_unlock(tacc);
+
+ return guest_time;
+}
+#endif
+
+
void context_saved(struct vcpu *prev)
{
/* Clear running flag /after/ writing context to memory. */
@@ -1028,6 +1028,9 @@ struct tacc
s_time_t irq_enter_time;
s_time_t irq_time;
int irq_cnt;
+#ifdef CONFIG_TACC_NEEDS_LOCK
+ spinlock_t tacc_lock;
+#endif
};
DECLARE_PER_CPU(struct tacc, tacc);
@@ -1041,6 +1044,14 @@ inline s_time_t tacc_get_guest_time_delta(void)
return tacc_get_guest_time(&this_cpu(tacc)) - current->pcpu_guest_time;
}
+#ifdef CONFIG_TACC_NEEDS_LOCK
+s_time_t tacc_get_guest_time_cpu(int cpu);
+inline s_time_t tacc_get_guest_time_delta_vcpu(struct vcpu* vcpu)
+{
+ return tacc_get_guest_time_cpu(vcpu->processor) - vcpu->pcpu_guest_time;
+}
+#endif
+
#endif /* __SCHED_H__ */
/*