Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: How would you change cpu governor permanently?

  1. #1

    Default How would you change cpu governor permanently?

    I wonder how would you change CPU governor on Leap permanently?
    I know how to do change it manually for duration of the session:

    Code:
    echo governor | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
    - but I'm not sure what would be a best way to set it up so it would survive reboots .
    By default it is set to powersave, but "performance" makes more sense in my use case.
    Last edited by malcolmlewis; 20-Jan-2018 at 09:00. Reason: Fix prefix version

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,380

    Default Re: How would you change cpu governor permanently?

    That is something set in the running kernel. You cannot make that permanent (except maybe by compiling a changed kernel), but you can set it at every boot.

    That is in these days done by creating a systemd service.

    Create a file /etc/systemd/system/cpugov.service (or another name before the .). Contents something like:
    Code:
    [Unit]
    Description=Change CPU governor
    
    [Service]
    Type=forking
    
    ExecStart=echo governor | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
    
    [Install]
    WantedBy=multi-user.target
    Adapt the ExecStart statement to need (do you realy need the tee there?)
    Also you might want to have it at a different target.

    Enable so it will be used at boot:
    Code:
    systemctl enable cpugov.service
    Start manually:
    Code:
    systemctl start cpugov.service
    Ask status:
    Code:
    systemctl status cpugov.service
    To understand more:
    Code:
    man systemd
    man systemctl
    Henk van Velden

  3. #3
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,463
    Blog Entries
    2

    Default Re: How would you change cpu governor permanently?

    The traditional way to persist core system modifications like custom proc settings is to either modify the /etc/sysctl file or do one of the methods described in the comments of the /etc/sysctl file.

    Long ago,
    I wrote an article that describes doing this to persist modifications to the default TCP/IP buffer settings

    https://sites.google.com/site/4techs...orithm-changes

    Yes, this is pre-systemd, but generally speaking I would still do the same for its simplicity compared to creating a systemd service for anything that modifies the core system at a low level. Although I haven't checked, I would also expect that any such changes would be implemented very early in the boot process and before anything invoked by systemd can start up.

    Note that both the sysctl method and systemd don't actually write changes to a system's defaults, in both cases a custom configuration is read and implemented on each bootup.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  4. #4

    Default Re: How would you change cpu governor permanently?

    Quote Originally Posted by hcvv View Post
    do you realy need the tee there?
    in all honesty - I don't know. I'm just blatantly copying and pasting command that from what I know does the trick without really understanding how it works .
    I've tried :

    Code:
    echo performance >/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
    but I got this error:
    Code:
    bash: /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor: ambiguous redirect

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,380

    Default Re: How would you change cpu governor permanently?

    Quote Originally Posted by Pshemas View Post
    in all honesty - I don't know. I'm just blatantly copying and pasting command that from what I know does the trick without really understanding how it works .
    That is a rather dangerous starting point
    Quote Originally Posted by Pshemas View Post
    I've tried :

    Code:
    echo performance >/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
    but I got this error:
    Code:
    bash: /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor: ambiguous redirect
    logicaly, because cpu* expands into several items. Which one to choose (in human terms), complete nonsense (to the shell).

    I have no experience with this at all, but I see that, on my system(!), there is a /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor and a
    /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor. Thus for every CPU one.

    I guess the author of the text you try to copy/paste assumed some understanding by the reader to interprete cpu* as "for every cpu".

    Mind that I am only making comments on your shell statments. Not on your original questions "
    How would you change cpu governor permanently?". (My answer to that would be: I would not, but that would not help you at all).
    Last edited by hcvv; 20-Jan-2018 at 07:05.
    Henk van Velden

  6. #6

    Default Re: How would you change cpu governor permanently?

    Quote Originally Posted by hcvv View Post
    That is a rather dangerous starting point
    yeah , I know - but as I can't find an easier way to do it I have to use what works. Really I'm not an IT specialist, as much as I'd love to understand the system a bit more (and I'm learning) , I have to focus first on things that pays for my bills. Which in this case means having a working desktop for design work and a bit of rendering.
    There should be an easier way to do it for regular Joe like me (as default setting is not good for me - I need to every bit of power I can get, every second shoved from rendering a frame quickly adds up when you render an animation).
    I understand what * means - and I hoped that system would understand it as well (exactly like it would understand if you use it in ls command for example - ls whateeverterm*).
    With tee it works as expected and changes cpu governor on all cores with a single command. It would so bad if it would have to be repeated for every core.

    I've tried the systemd approach and sadly it does not work. I get:
    Code:
    The unit files have no [Install] section. They are not meant to be enabledusing systemctl.
    Which is puzzling for me as there is this part:
    Code:
    [Install]
    WantedBy=multi-user.target
    is there anything more I should add?
    I've also found this:
    https://unix.stackexchange.com/quest...power-governor

    Maybe that would be a solution? There is cpupower package but I don't see a service file for it.

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    27,213
    Blog Entries
    15

    Default Re: How would you change cpu governor permanently?

    Quote Originally Posted by Pshemas View Post
    in all honesty - I don't know. I'm just blatantly copying and pasting command that from what I know does the trick without really understanding how it works .
    I've tried :

    Code:
    echo performance >/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
    but I got this error:
    Code:
    bash: /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor: ambiguous redirect
    Hi
    Use the cpupower command?
    Code:
    cpupower -c all frequency-set -g performance
    cpupower -c all frequency-info |grep "governor \""
    The first one sets all the cpu's available to performance, the other just show what it is.. so depending on what governors you have you can change it back.

    Perhaps you might want to describe what your trying to achieve that needs you to set the performance governor?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  8. #8
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    27,213
    Blog Entries
    15

    Default Re: How would you change cpu governor permanently?

    Hi
    OK rendering... so what GPU are you using? Oh the above command needs to be done as root..

    PS, only a couple of weeks left for Leap 42.2... in your busy schedule consider a backup and upgrade
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,380

    Default Re: How would you change cpu governor permanently?

    Quote Originally Posted by Pshemas View Post
    yeah , I know - but as I can't find an easier way to do it I have to use what works. Really I'm not an IT specialist, as much as I'd love to understand the system a bit more (and I'm learning) , I have to focus first on things that pays for my bills. Which in this case means having a working desktop for design work and a bit of rendering.
    There should be an easier way to do it for regular Joe like me (as default setting is not good for me - I need to every bit of power I can get, every second shoved from rendering a frame quickly adds up when you render an animation).
    I understand what * means - and I hoped that system would understand it as well (exactly like it would understand if you use it in ls command for example - ls whateeverterm*).
    With tee it works as expected and changes cpu governor on all cores with a single command. It would so bad if it would have to be repeated for every core.

    I've tried the systemd approach and sadly it does not work. I get:
    Code:
    The unit files have no [Install] section. They are not meant to be enabledusing systemctl.
    Which is puzzling for me as there is this part:
    Code:
    [Install]
    WantedBy=multi-user.target
    is there anything more I should add?
    I've also found this:
    https://unix.stackexchange.com/quest...power-governor

    Maybe that would be a solution? There is cpupower package but I don't see a service file for it.
    First, please look at the other suggestions/advice given above (as you alraedy do). I will continue a bit in the background on this post.

    Please do post complete sequencies, not only the error or (part of) output. That is the prompt and command (the line before the output), the output and the line after (which will contain the prompt again). That will show us who you are, where yoyu wwre, what you did and waht you got and that it is complete. Only so can we sse what you saw.

    Now we have an error message without context .

    Also, do not post just that part that you think is important of the systemd file. Post it complete. It isn't that big! It is the only way we may see if it is correct.

    And yes, the tee will address the several instances of cpu*. That is correct. When you want to know what tee does:
    Code:
    man tee
    I only asked you in my first post above a clarification in the assumption that you knew what you wetre doing.. That was not meant to confuse you.
    Henk van Velden

  10. #10
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    27,213
    Blog Entries
    15

    Default Re: How would you change cpu governor permanently?

    Hi
    And a systemd service file...

    Code:
    # /etc/systemd/system/cpugov.service
    #
    
    [Unit]
    Description=Change CPU governor
    
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/sh -c "/usr/bin/cpupower -c all frequency-set -g performance"
    
    [Install]
    WantedBy=multi-user.target
    As root user;
    Code:
    systemctl status cpugov
    systemctl start cpugov
    systemctl status cpugov
    
    If all ok, enable;
    systemctl enable cpugov
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •