2

I would like to edit /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed to change its content from 800000 to 1600000.

  1. I first try with emacs

    $ sudo emacs -nw /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
    

    In emacs I have changed the value to 1600000 in the file, and when I save the changes, the message buffer says:

    Saving file /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed...
    Wrote /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
    

    But after I exit emacs and read the file again, the value is still 800000

  2. Then I try another way

    $ sudo less /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
    

    wherein I hit v to invoke default editor which is nano, and then I change the value. After I exit nano and less, and check the file again, the file has been changed successfully.

I wonder why the first way doesn't work while the second does?

I am running Ubuntu 16.04 on a Thinkpad T400. Thanks.

  • Emacs doesn't complain anything about it? – ilkkachu Jan 25 '18 at 22:15
  • 1
    Possible duplicate of Why do I get Fsync failed error? – Olorin Jan 26 '18 at 3:02
  • When Emacs saves a file, it renames the old file so that it becomes a backup file, and then creates a new file with the original name. I don't know what happened in your case, and why Emacs didn't complain, but Emacs is clearly the wrong tool for this. – Johan Myréen Jan 26 '18 at 6:29
  • @JohanMyréen what are the options for the right tools? – Tim Jan 26 '18 at 13:32
  • echo 1600000 | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed – Mark Plotnick Jan 27 '18 at 18:06
3

From the comments:

When Emacs saves a file, it renames the old file so that it becomes a backup file, and then creates a new file with the original name. I don't know what happened in your case, and why Emacs didn't complain, but Emacs is clearly the wrong tool for this. – Johan Myréen

The right tool would be anything that just overwrites the original file (or even just appends to it), rather than trying to rename the old file.

Remember: nothing under /sys is a real, persistent file. They are all kernel parameters and status information, presented in the form of files. You should not be able to move, rename or delete them.

There used to be commands named cpufreq-info and cpufreq-set for manipulating these settings; in more recent releases, the commands may now (or soon) be cpupower frequency-info and cpupower frequency-set respectively.

  • cpufreq-info and cpufreq-set belong to cpufrequtils, Are you sure that cpufrequtils is replaced with cpupower? – Tim Jan 26 '18 at 18:09
  • The upstream of the cpufrequtils package hasn't been updated since 2015, and the cpupower utility is included in the kernel source package, in the tools/power directory. Though it may not be quite replaced yet, it sure looks like it will be soon. – telcoM Jan 26 '18 at 19:58
  • But why I can't find cpupower in synaptic package manager? – Tim Jan 26 '18 at 20:13
  • Your distribution is apparently not on the bleeding edge :-) – telcoM Jan 26 '18 at 20:14
  • which distribution has cpupower? – Tim Jan 26 '18 at 20:18
0

As mentioned in comments, the conventional method to set 1600 MHz speed is:

echo 1600000 | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed

To verify it's effect use:

$ cd /sys/devices/system/cpu/cpu0/cpufreq/
$ paste <(ls *) <(cat *) | column -s $'\t' -t
affected_cpus                             0
cpuinfo_max_freq                          3500000
cpuinfo_min_freq                          800000
cpuinfo_transition_latency                4294967295
energy_performance_available_preferences  default performance balance_performance balance_power power 
energy_performance_preference             balance_performance
related_cpus                              0
scaling_available_governors               performance powersave
scaling_cur_freq                          807325
scaling_driver                            intel_pstate
scaling_governor                          powersave
scaling_max_freq                          3500000
scaling_min_freq                          800000
scaling_setspeed                          <unsupported>

On my machine scaling_setspeed cannot be set as I have an i7-6700HQ. The same is true on my old 3rd generation i7-3630QM.

So on these platforms I would set scaling_min_freq and scaling_max_freq to the same level and p_state would never fluctuate. The same setting I would likely apply across all CPU's in .../cpu0/... through .../cpu7/...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.