kernel/scheduler: enable cpu load tracking after boot
when the cpufreq module is loaded, we let the scheduler update its policy. Improve assert report CoreEntry::GetLoad() could return more than kMaxLoad. Change-Id: I127f9b3e8062b5996872aae30b4021b9904fa179 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3216 Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
@@ -86,6 +86,7 @@ void scheduler_remove_listener(struct SchedulerListener* listener);
|
||||
|
||||
void scheduler_init(void);
|
||||
void scheduler_enable_scheduling(void);
|
||||
void scheduler_update_policy(void);
|
||||
|
||||
bigtime_t _user_estimate_max_scheduling_latency(thread_id thread);
|
||||
status_t _user_analyze_scheduling(bigtime_t from, bigtime_t until, void* buffer,
|
||||
|
||||
@@ -89,6 +89,8 @@ load_cpufreq_module()
|
||||
|
||||
if (sCPUPerformanceModule == NULL)
|
||||
dprintf("no valid cpufreq module found\n");
|
||||
else
|
||||
scheduler_update_policy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -654,12 +654,7 @@ init()
|
||||
|
||||
// disable parts of the scheduler logic that are not needed
|
||||
gSingleCore = coreCount == 1;
|
||||
gTrackCPULoad = increase_cpu_performance(0) == B_OK;
|
||||
gTrackCoreLoad = !gSingleCore || gTrackCPULoad;
|
||||
dprintf("scheduler switches: single core: %s, cpu load tracking: %s,"
|
||||
" core load tracking: %s\n", gSingleCore ? "true" : "false",
|
||||
gTrackCPULoad ? "true" : "false",
|
||||
gTrackCoreLoad ? "true" : "false");
|
||||
scheduler_update_policy();
|
||||
|
||||
gCoreCount = coreCount;
|
||||
gPackageCount = packageCount;
|
||||
@@ -740,6 +735,18 @@ scheduler_enable_scheduling()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
scheduler_update_policy()
|
||||
{
|
||||
gTrackCPULoad = increase_cpu_performance(0) == B_OK;
|
||||
gTrackCoreLoad = !gSingleCore || gTrackCPULoad;
|
||||
dprintf("scheduler switches: single core: %s, cpu load tracking: %s,"
|
||||
" core load tracking: %s\n", gSingleCore ? "true" : "false",
|
||||
gTrackCPULoad ? "true" : "false",
|
||||
gTrackCoreLoad ? "true" : "false");
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - SchedulerListener
|
||||
|
||||
|
||||
|
||||
@@ -326,7 +326,9 @@ CPUEntry::_RequestPerformanceLevel(ThreadData* threadData)
|
||||
}
|
||||
|
||||
int32 load = std::max(threadData->GetLoad(), fCore->GetLoad());
|
||||
ASSERT(load >= 0 && load <= kMaxLoad);
|
||||
ASSERT_PRINT(load >= 0 && load <= kMaxLoad, "load is out of range %"
|
||||
B_PRId32 " (max of %" B_PRId32 " %" B_PRId32 ")", load,
|
||||
threadData->GetLoad(), fCore->GetLoad());
|
||||
|
||||
if (load < kTargetLoad) {
|
||||
int32 delta = kTargetLoad - load;
|
||||
|
||||
@@ -397,7 +397,7 @@ CoreEntry::GetLoad() const
|
||||
SCHEDULER_ENTER_FUNCTION();
|
||||
|
||||
ASSERT(fCPUCount > 0);
|
||||
return fLoad / fCPUCount;
|
||||
return std::min(fLoad / fCPUCount, kMaxLoad);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user