kernel: Relax cpu_ent::interrupt_time locking

The value isn't accessed by the other CPUs and all writes and reads are
done with interrupts disabled.
This commit is contained in:
Pawel Dziepak
2014-01-07 02:12:39 +01:00
parent c37c2aa45f
commit c2a02dee65
4 changed files with 13 additions and 19 deletions
+6 -4
View File
@@ -359,14 +359,16 @@ int_io_interrupt_handler(int vector, bool levelTriggered)
if (!sVectors[vector].no_lock_vector)
release_spinlock(&sVectors[vector].vector_lock);
SpinLocker locker(sVectors[vector].load_lock);
SpinLocker vectorLocker(sVectors[vector].load_lock);
bigtime_t deltaTime = system_time() - start;
sVectors[vector].last_measure_active += deltaTime;
locker.Unlock();
vectorLocker.Unlock();
atomic_add64(&get_cpu_struct()->interrupt_time, deltaTime);
cpu_ent* cpu = get_cpu_struct();
cpu->interrupt_time += deltaTime;
if (sVectors[vector].type == INTERRUPT_TYPE_IRQ)
atomic_add64(&get_cpu_struct()->irq_time, deltaTime);
cpu->irq_time += deltaTime;
update_int_load(vector);
if (levelTriggered)
+1 -2
View File
@@ -393,8 +393,7 @@ reschedule(int32 nextState)
ThreadData* oldThreadData = oldThread->scheduler_data;
// return time spent in interrupts
oldThreadData->IncreaseStolenTime(
gCPU[thisCPU].interrupt_time - oldThreadData->LastInterruptTime());
oldThreadData->SetStolenInterruptTime(gCPU[thisCPU].interrupt_time);
bool enqueueOldThread = false;
bool putOldThreadAtBack = false;
@@ -166,13 +166,6 @@ ThreadData::ComputeLoad()
SCHEDULER_ENTER_FUNCTION();
ASSERT(gTrackLoad);
if (fLastInterruptTime > 0) {
bigtime_t interruptTime = gCPU[smp_get_current_cpu()].interrupt_time;
interruptTime -= fLastInterruptTime;
fMeasureActiveTime -= interruptTime;
}
compute_load(fMeasureTime, fMeasureActiveTime, fLoad);
}
@@ -51,12 +51,9 @@ public:
bool ChooseCoreAndCPU(CoreEntry*& targetCore,
CPUEntry*& targetCPU);
inline bigtime_t LastInterruptTime() const
{ return fLastInterruptTime; }
inline void SetLastInterruptTime(bigtime_t interruptTime)
{ fLastInterruptTime = interruptTime; }
inline void IncreaseStolenTime(bigtime_t stolenTime);
inline void SetStolenInterruptTime(bigtime_t interruptTime);
inline void GoesAway();
inline bigtime_t WentSleep() const { return fWentSleep; }
@@ -226,10 +223,13 @@ ThreadData::ShouldCancelPenalty() const
inline void
ThreadData::IncreaseStolenTime(bigtime_t stolenTime)
ThreadData::SetStolenInterruptTime(bigtime_t interruptTime)
{
SCHEDULER_ENTER_FUNCTION();
fStolenTime += stolenTime;
interruptTime -= fLastInterruptTime;
fStolenTime += interruptTime;
fMeasureActiveTime -= interruptTime;
}