cpu frequency scaling

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

User avatar
Capoeira
Established Member
Posts: 1321
Joined: Tue May 12, 2009 1:01 pm
Location: Brazil
Has thanked: 3 times
Been thanked: 2 times

Re: cpu frequency scaling

Post by Capoeira »

AutoStatic wrote:There are different ways to do this. The easiest I guess would be to add the cpupower to your sudoers file (if your system has one) and allow a user to run it without having to issue a password:

Code: Select all

yourusername ALL=(ALL) NOPASSWD: /path/to/cpupower
Editing the sudoers file is done with the visudo command. Not sure if the sudoers syntax is correct though. There are other ways like using PolicyKit or changing the permissions on cpupower itself (which I wouldn't recommend).

thanks a lot,

I'll try that out later
User avatar
Capoeira
Established Member
Posts: 1321
Joined: Tue May 12, 2009 1:01 pm
Location: Brazil
Has thanked: 3 times
Been thanked: 2 times

Re: cpu frequency scaling

Post by Capoeira »

AutoStatic wrote:

Code: Select all

yourusername ALL=(ALL) NOPASSWD: /path/to/cpupower
Editing the sudoers file is done with the visudo command.
thanks, that worked

sidenote to anybody wanting to do this: comand in the scripting options of qjackctl needs "sudo"
oddy.o.lynx
Established Member
Posts: 115
Joined: Sat Jun 30, 2018 2:54 am
Has thanked: 22 times
Been thanked: 22 times

Re: cpu frequency scaling

Post by oddy.o.lynx »

after using real time config quick scan I was led here for clues on how to set cpu governor to performance permanently

for Debian 11 I was able to set it following these instructions

install cpufrequtils

in the file /etc/default/cpufrequtils

add the following or change to

Code: Select all

GOVERNOR="performance"

then install sysfsutils

in the case of having 4 CPUs, add the following to /etc/sysfs.conf

Code: Select all

devices/system/cpu/cpu0/cpufreq/scaling_governor = performance
devices/system/cpu/cpu1/cpufreq/scaling_governor = performance
devices/system/cpu/cpu2/cpufreq/scaling_governor = performance
devices/system/cpu/cpu3/cpufreq/scaling_governor = performance

reboot

tseaver
Established Member
Posts: 405
Joined: Mon Mar 13, 2017 6:07 am
Has thanked: 11 times
Been thanked: 100 times

Re: cpu frequency scaling

Post by tseaver »

@oddy.o.lynx wrote:

then install sysfsutils

in the case of having 4 CPUs, add the following to /etc/sysfs.conf
...

I don't understand the rationale for using sysfsutils here: my Debian-based systems (Ubuntu Studio, AVL-MX) don't have it, and yet the GOVERNOR=performance bit in /etc/default/cpufrequtils works just fine after a reboot.

Ubuntu, Mixbus32C; acoustic blues / country / jazz
User avatar
Impostor
Established Member
Posts: 1384
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 145 times
Been thanked: 360 times

Re: cpu frequency scaling

Post by Impostor »

To change freq scaling on-the-fly this script works for me (you should at least adapt the number of cpu's, mine's 12):

Code: Select all

#!/bin/bash

File=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

if ! grep -q performance "$File"; then
    for ((x=0 ; x<12 ; x++)); do
        File=/sys/devices/system/cpu/cpu$x/cpufreq/scaling_governor
        echo -n performance | sudo tee $File 1>/dev/null
    done
    echo "CPUs set to performance mode"
    read
    exit 0
else
     for ((x=0 ; x<12 ; x++)); do
        File=/sys/devices/system/cpu/cpu$x/cpufreq/scaling_governor
        echo -n ondemand | sudo tee $File 1>/dev/null
    done
    echo "CPUs set to ondemand mode"
    read
    exit 0
fi
Post Reply