kernel: Update cpu_ent::active_time atomically
This commit is contained in:
parent
453bf75027
commit
d6efe8ee75
@ -74,12 +74,7 @@ cpu_get_active_time(int32 cpu)
|
|||||||
if (cpu < 0 || cpu > smp_get_num_cpus())
|
if (cpu < 0 || cpu > smp_get_num_cpus())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// We need to grab the scheduler lock here, because the thread activity
|
return atomic_get64(&gCPU[cpu].active_time);
|
||||||
// time is not maintained atomically (because there is no need to).
|
|
||||||
|
|
||||||
InterruptsSpinLocker schedulerLocker(gSchedulerLock);
|
|
||||||
|
|
||||||
return gCPU[cpu].active_time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1213,7 +1213,7 @@ affine_track_cpu_activity(Thread* oldThread, Thread* nextThread, int32 thisCore)
|
|||||||
= (oldThread->kernel_time - oldThread->cpu->last_kernel_time)
|
= (oldThread->kernel_time - oldThread->cpu->last_kernel_time)
|
||||||
+ (oldThread->user_time - oldThread->cpu->last_user_time);
|
+ (oldThread->user_time - oldThread->cpu->last_user_time);
|
||||||
|
|
||||||
oldThread->cpu->active_time += active;
|
atomic_add64(&oldThread->cpu->active_time, active);
|
||||||
sCoreEntries[thisCore].fActiveTime += active;
|
sCoreEntries[thisCore].fActiveTime += active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,9 +634,9 @@ simple_reschedule(void)
|
|||||||
|
|
||||||
// track CPU activity
|
// track CPU activity
|
||||||
if (!thread_is_idle_thread(oldThread)) {
|
if (!thread_is_idle_thread(oldThread)) {
|
||||||
oldThread->cpu->active_time +=
|
atomic_add64(&oldThread->cpu->active_time,
|
||||||
(oldThread->kernel_time - oldThread->cpu->last_kernel_time)
|
(oldThread->kernel_time - oldThread->cpu->last_kernel_time)
|
||||||
+ (oldThread->user_time - oldThread->cpu->last_user_time);
|
+ (oldThread->user_time - oldThread->cpu->last_user_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thread_is_idle_thread(nextThread)) {
|
if (!thread_is_idle_thread(nextThread)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user