#16517: cpufreq modules' performance hooks are never used
--------------------------------+-----------------------------
Reporter: madmax | Owner: nobody
Type: bug | Status: new
Priority: normal | Milestone: Unscheduled
Component: System/Kernel | Version: R1/Development
Keywords: cpufreq, scheduler | Blocked By:
Blocking: | Platform: All
--------------------------------+-----------------------------
I was adding my model to intel_pstates (the only current cpufreq module)
list of supported cpus, included some tracing and saw that, apart from the
initial setting of performance mode, no change happened ever.
cpufreq modules have three specific hooks: cpu_set_scheduler_mode,
increase_cpu_performance and decrease_cpu_performance.
The first one can be triggered through ProcessController, but that's only
a policy change and in intel_pstates case it doesn't even adjust frequency
(I guess that if everything was working, one of the other hooks would be
called sooner than later and the new policy would be taken into account).
The other two are called to change the performance level from [https://git
.haiku-
os.org/haiku/tree/src/system/kernel/scheduler/scheduler_cpu.cpp?h=hrev54555#n319
_RequestPerformanceLevel] in scheduler_cpu.cpp, which is called from
[https://git.haiku-
os.org/haiku/tree/src/system/kernel/scheduler/scheduler_cpu.cpp?h=hrev54555#n284
TrackActivity], but only when we are tracking the cpu (`gTrackCPULoad`).
`increase_cpu_performance` is also called from the scheduler
initialization as [https://git.haiku-
os.org/haiku/tree/src/system/kernel/scheduler/scheduler.cpp?h=hrev54555#n657
a test to activate cpu tracking]. I guess tracking doesn't make sense if
you are not going to use the data.
Now we have a problem. That's the only place where tracking is set. It is
called from [https://git.haiku-
os.org/haiku/tree/src/system/kernel/scheduler/scheduler.cpp?h=hrev54555#n718
scheduler_init], which is called from [https://git.haiku-
os.org/haiku/tree/src/system/kernel/main.cpp?h=hrev54555#n202 kernel
start], and by that time we don't have cpufreq modules yet (they are
loaded from a thread spawned a bit later: [https://git.haiku-
os.org/haiku/tree/src/system/kernel/main.cpp?h=hrev54555#n227 spawn] ->
[https://git.haiku-
os.org/haiku/tree/src/system/kernel/main.cpp?h=hrev54555#n350 main2] ->
[https://git.haiku-
os.org/haiku/tree/src/system/kernel/cpu.cpp?h=hrev54555#n135
cpu_init_post_modules]). So [https://git.haiku-
os.org/haiku/tree/src/system/kernel/cpu.cpp?h=hrev54555#n303
increase_cpu_performance] returns `B_NOT_SUPPORTED` and `gTrackCPULoad`
stays `false`.
--
Ticket URL: <https://dev.haiku-os.org/ticket/16517>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.