Trauma

CPU Frequency scaling for DS918+

Recommended Posts

Posted (edited)

Hi,

 

Since I was not yet able to build a working cpufreq_ondemand.ko to allow automatic frequency scaling for JUN's loader 1.04b (DSM 6.2.2-24922 Update 2), i've written this script to allow dynamic CPU frequency scaling.

 

It's hosted here https://github.com/Trauma/cpufreq-userspace-scaler

 

# cpufreq-userspace-scaler
##### Cpu frequency scaling script for cpufreq userspace governor

## If you're missing ondemand or conservative governors, this script is for you.

This script is scaling cpu frequency according to current average load.
You can set 3 frequency steps : low, mid, high. This 3 thresholds will 
automatically set cpu frequency accordingly :
  - the `lowload` threshold will set the cpu to his minimal frequency, unless you force it to `scalingminfreq`
  - the `midload` threshold will set the cpu to approximate mid range cpu frequency
  - the `highload` threshold will set the cpu to his maximal frequency, unless you force it to `scalingmaxfreq`

If you set `scalingmaxfreq` and/or `scalingminfreq` the cpu will never override those values.

### Usage :
### Parameters :
Variable name   | Default | Type                        | Comments
----------------|---------|-----------------------------|-----------
lowload         | 050     | integer between 000 and 999 | 050 = load average : 0.50
midload         | 065     | integer between 000 and 999 | 065 = load average : 0.65
highload        | 085     | integer between 000 and 999 | 085 = load average : 0.85
scalingminfreq  | auto    | integer in hertz            | 800000 = 800 Mhz
scalingmaxfreq  | auto    | integer in hertz            | 2500000 = 2,5 Ghz

### Default commande line :
`./scaling.sh &`

### Custom command line example :
`lowload=100 highload=200 scalingmaxfreq=2000000 scalingminfreq=1500000 ./scaling.sh &`

Enjoy.

Edited by Trauma
Tags addition
  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites
Posted (edited)
9 hours ago, viettanium said:

how to install this script?

just put it to rc.d folder?

 

Installation in rc.d will not work since this script do not provide start and stop args. As @Olegin spotted you can launch it form the task manager, that's the way i use it.

 

Installation example (from your nas cli) :

sudo curl https://raw.githubusercontent.com/Trauma/cpufreq-userspace-scaler/master/scaler.sh -o /usr/local/bin/scaler.sh && sudo chmod +x /usr/local/bin/scaler.sh

Then run it through a startup triggered task, as root, in your DSM, with the following command :

/usr/local/bin/scaler.sh &

or with parameters :

lowload=100 highload=200 scalingmaxfreq=2000000 scalingminfreq=1500000 /usr/local/bin/scaler.sh &

 

Edited by Trauma
  • Like 2

Share this post


Link to post
Share on other sites
35 minutes ago, Trauma said:

 

Installation in rc.d will not work since this script do not provide start and stop args. As @Olegin spotted you can launch it form the task manager, that's the way i use it.

 

Installation example (from your nas cli) :


sudo curl https://raw.githubusercontent.com/Trauma/cpufreq-userspace-scaler/master/scaler.sh -o /usr/local/bin/scaler.sh && sudo chmod +x /usr/local/bin/scaler.sh

Then run it through a startup triggered task, as root, in your DSM, with the following command :


/usr/local/bin/scaler.sh &

or with parameters :


lowload=100 highload=200 scalingmaxfreq=2000000 scalingminfreq=1500000 /usr/local/bin/scaler.sh &

 

my CPU is J1900 (2.0GHz 4 core) which had only three mode:

powersave performance userspace

does this script work or I must modify some text?

Share this post


Link to post
Share on other sites

Long answer :

Your CPU don not have only 3 modes, synology kernel for DS918+ provides only three cpufreq governors :

  • powersave > set the cpu to its minimal freq
  • performance > set the cpu to its maximal freq
  • userspace > allow you to specify the desired frequency. This script use this governor to modulate the frequency according to system load (that's basically whats explained in the README).

Short answer :

no need to "modify some text", just RTFM ;)

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
6 hours ago, Trauma said:

Long answer :

Your CPU don not have only 3 modes, synology kernel for DS918+ provides only three cpufreq governors :

  • powersave > set the cpu to its minimal freq
  • performance > set the cpu to its maximal freq
  • userspace > allow you to specify the desired frequency. This script use this governor to modulate the frequency according to system load (that's basically whats explained in the README).

Short answer :

no need to "modify some text", just RTFM ;)

 

thank you very much, just put this on Triggered Task at Boot-up and this work like a charm!

from 26W Idle now at 23W.

Edited by viettanium

Share this post


Link to post
Share on other sites

This is a pretty cool script. I really like the fact that it is made to auto-figure out variables. Seems to work well on machine and scales the CPU as needed. While playing around with the files in "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies". I noticed that my J4105 only shows frequencies uptil 1501MHz, but not the boost frequency of 2500MHz. Not that I need the boost, but I wonder if the kernel restricts it

Share this post


Link to post
Share on other sites
On 9/11/2019 at 2:29 AM, Jseinfeld said:

This is a pretty cool script. I really like the fact that it is made to auto-figure out variables.

Thanks !

 

 

On 9/11/2019 at 2:29 AM, Jseinfeld said:

 I noticed that my J4105 only shows frequencies uptil 1501MHz, but not the boost frequency of 2500MHz. Not that I need the boost, but I wonder if the kernel restricts it

Not 100% sure about this but i guess boost frequency is managed by intel_pstate, which seems to be enabled in the kernel, but the default cpu frequency driver is set to cpu_freq. I did not succeed to make it work on my rig. I've tried intel_pstate=enable in the grub cmd_line, but no luck. I've also tried to load a compiled module, and it don't load.

 

I guess some guys here have proven it's actually working, while benchmarking the NAS with turbo boost enabled or disabled in bios (they use geekbench in a docker container I guess).

Edited by Trauma

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.