scheduler: Use sequential locks instead of atomic 64 bit access

This commit is contained in:
Pawel Dziepak
2013-12-20 02:18:44 +01:00
parent b258298c70
commit ad6b9a1df8
5 changed files with 25 additions and 7 deletions
+3 -3
View File
@@ -59,9 +59,9 @@ typedef struct {
} seqlock;
#define B_SEQLOCK_INITIALIZER { B_SPINLOCK_INITIALIZER, 0 }
#define B_INITIALIZE_SEQLOCK(seqlock) do { \
B_INITIALIZE_SPINLOCK((seqlock)->lock); \
(seqlock)->count = 0; \
#define B_INITIALIZE_SEQLOCK(seqlock) do { \
B_INITIALIZE_SPINLOCK(&(seqlock)->lock); \
(seqlock)->count = 0; \
} while (false)
/* interrupt handling support for device drivers */
+10 -2
View File
@@ -35,8 +35,16 @@ has_cache_expired(const ThreadData* threadData)
{
ASSERT(!gSingleCore);
return atomic_get64(&threadData->GetCore()->fActiveTime)
- threadData->fWentSleepActive > kCacheExpire;
CoreEntry* core = threadData->GetCore();
bigtime_t activeTime;
uint32 count;
do {
count = acquire_read_seqlock(&core->fActiveTimeLock);
activeTime = core->fActiveTime;
} while (!release_read_seqlock(&core->fActiveTimeLock, count));
return activeTime - threadData->fWentSleepActive > kCacheExpire;
}
@@ -272,6 +272,7 @@ CoreEntry::CoreEntry()
{
B_INITIALIZE_SPINLOCK(&fCPULock);
B_INITIALIZE_SPINLOCK(&fQueueLock);
B_INITIALIZE_SEQLOCK(&fActiveTimeLock);
}
@@ -100,6 +100,7 @@ struct CoreEntry : public MinMaxHeapLinkImpl<CoreEntry, int32>,
spinlock fQueueLock;
bigtime_t fActiveTime;
seqlock fActiveTimeLock;
int32 fLoad;
bool fHighLoad;
+10 -2
View File
@@ -177,8 +177,13 @@ ThreadData::GoesAway()
fLastInterruptTime = 0;
fWentSleep = system_time();
fWentSleepActive = atomic_get64(&fCore->fActiveTime);
fWentSleepCount = atomic_get(&fCore->fStarvationCounter);
uint32 count;
do {
count = acquire_read_seqlock(&fCore->fActiveTimeLock);
fWentSleepActive = fCore->fActiveTime;
} while (!release_read_seqlock(&fCore->fActiveTimeLock, count));
}
@@ -262,7 +267,10 @@ ThreadData::UpdateActivity(bigtime_t active)
{
fMeasureActiveTime += active;
gCPUEntries[smp_get_current_cpu()].fMeasureActiveTime += active;
atomic_add64(&fCore->fActiveTime, active);
WriteSequentialLocker locker(fCore->fActiveTimeLock);
fCore->fActiveTime += active;
locker.Unlock();
}