You are not logged in.

#1 2012-06-13 10:56:25

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Systemd and tuning ondemand governor?

I have a DESKTOP machine that I'd like to be a little more responsive. In the Arch wiki there's a good explanation of how to fine tune the ondemand governor which seems to suit my needs perfectly. The performance governor is a bit too much. The manual commands;

echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo -n 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

work very well.

Now I tried to create a systemd service doing the above;

[Unit]
Description=CPU frequency ondemand tuning

[Service]

ExecStart=echo -n 15 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
ExecStart=echo -n 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
[Install]
WantedBy=multi-user.target

When trying to start it systemctl complains "job failed. Invalid argument". I've tried single qoutes after echo, but no success. Is this possible in a service file? Google has no answer unfortunately.

Offline

#2 2012-06-13 11:06:28

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 798

Re: Systemd and tuning ondemand governor?

try this

ExecStart=/bin/bash -c 'echo 6500 > /sys/class/backlight/...'

But i didn't know i could use two ExecStart in a single .service file! Is it really possible?

Offline

#3 2012-06-13 11:20:02

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: Systemd and tuning ondemand governor?

That seems hot ...

Offline

#4 2012-06-13 11:27:43

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: Systemd and tuning ondemand governor?

Nope, no luck. Tried with two ExecStart= ... and with the two commands separated with ; which works in another service file. Error:
Loaded: error (Reason: Invalid argument)
      Active: failed (Result: exit-code) since Wed, 13 Jun 2012 13:23:00 +0200; 3min 52s ago

Since I'm running only systemd units and will not use rc.local.service I really hope tuning the governor is possible from a native unit file.

Hey! One of your commands after the ExecStart= ... works! I'll try the syntax ...

Last edited by swanson (2012-06-13 11:35:05)

Offline

#5 2012-06-13 11:34:56

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,423
Website

Re: Systemd and tuning ondemand governor?

Put it in /etc/rc.local and call that in systemd.  You can find a .service for rc.local on the wiki.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2012-06-13 11:39:36

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: Systemd and tuning ondemand governor?

Nope, no rc.local.servcie for me. This works;

[Unit]
Description=CPU frequency ondemand tuning

[Service]

ExecStart=/bin/bash -c 'echo -n 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ; echo -n 19 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor'
[Install]
WantedBy=multi-user.target

Thanks for the help guys! Now I'll see what it does at boot ...

Last edited by swanson (2012-06-13 11:40:29)

Offline

#7 2012-06-13 11:41:03

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 798

Re: Systemd and tuning ondemand governor?

So it is possible to run two commands in a single ExecStart line, wow! That's wonderful smile

Offline

#8 2012-06-13 12:16:22

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Systemd and tuning ondemand governor?

Multiple ExecStart only works with Type=oneshot

Nevertheless, you should do this with tmpfiles instead:  https://wiki.archlinux.org/index.php/Sy … rary_files


moderator edit. [ewaller]  After this thread was closed, there had been a report that the above link is incorrect.  The assertion is that that link should be https://wiki.archlinux.org/index.php/Sy … rary_files

Last edited by ewaller (2015-10-15 22:38:10)

Offline

#9 2012-06-13 12:30:21

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 798

Re: Systemd and tuning ondemand governor?

Uhm, what's the difference?
I mean, why is it better to use tmpfiles instead of .service to echoing?

Last edited by nierro (2012-06-13 12:30:31)

Offline

#10 2012-06-13 12:36:28

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: Systemd and tuning ondemand governor?

nierro wrote:

Uhm, what's the difference?
I mean, why is it better to use tmpfiles instead of .service to echoing?

Because tmpfiles are meant exactly for this kind of stuff and should be much simpler / shorter.
service files may work as well, but they are not supposed to be used for writing values into files.

Offline

#11 2012-06-13 12:42:12

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 798

Re: Systemd and tuning ondemand governor?

Ah ok. thanks!

Offline

#12 2012-06-13 12:48:21

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: Systemd and tuning ondemand governor?

After a cold boot I can report that the unit file above worked well. No added boot time. And my values are set. I'll look into the tmpfile way as well. Googling "systemd" +tune + governor plus other ways didn't give anything. And by the way, googling systemd without double qoutes just gives a lot of hits on "system". Useless.

(PS I tried two ExecStart but had Type=OneShot, not oneshot)

Offline

#13 2012-06-13 12:52:10

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: Systemd and tuning ondemand governor?

Checked the tmpfile link as recommended by 65kid and that seemed a bit less complicated. I'd recommend that instead of my service file.

Offline

#14 2015-06-24 19:01:55

archlinux38
Member
Registered: 2014-09-27
Posts: 7

Re: Systemd and tuning ondemand governor?

swanson wrote:

Checked the tmpfile link as recommended by 65kid and that seemed a bit less complicated. I'd recommend that instead of my service file.

Hi Swanson,
How exactly did you manage to make this happen using tmpfile? I am a beginner and would love if you (or anyone else) have the time to describe the procedure. Regards.

Offline

#15 2015-06-24 19:11:56

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,350
Website

Re: Systemd and tuning ondemand governor?


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Online

Board footer

Powered by FluxBB