1

Is it possible to control the CPU P-states programmatically on Linux from userspace?

For example an app wants to ensure the CPU is running at its highest performance capability, there's no power-saving etc.

6
  • Do you mean P states? C states are sleep states that only get used when a core has no work to do. Or do you need low wakeup latency for a workload that doesn't occupy all cores all the time, and need to stop cores from sleeping as deeply? (At the expense of not having as much thermal headroom to turbo as high when your code is running, potentially.) You can set governors, like governor = performance and/or echo performance | sudo tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference to encourage HW P-state management to be aggressive, not running at idle clocks. Commented Sep 7 at 4:14
  • @PeterCordes Yes I probably meant P states. I know the OS should be tuned but I like this being controlled by the code. I have some threads which run at 100% cpu and I wanted to make sure the CPU is at it's fastest performance settings. Commented Sep 7 at 4:47
  • 2
    I wouldn't want an app to decide on maximum performance, when I might prefer the battery to last until I get home. Commented Sep 7 at 10:37
  • See my answer: How to get Maximum CPU frequency Commented Sep 7 at 14:28
  • @BoP: Unless the purpose of the application was to benchmark things at different CPU frequencies. Or possibly as optional behaviour of an application, not on by default, if typical system behaviour is known to cause problems for some users, like perhaps stuttering or dropouts in a low-latency real-time audio/video processing application or something. (Although I don't think there are any per-process power-management things except maybe some cgroups stuff?) For anything else, hell no. Document some system-wide config recommendations for root, but don't try to do it from within the program. Commented Sep 8 at 8:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.