Sepero / temp-throttle

A shell script for throttling system CPU frequency based on a desired maximum temperature
Other
243 stars 64 forks source link

Line 82: echo: write error: Invalid argument #5

Closed ghost closed 9 years ago

ghost commented 10 years ago

When I run temp_throttle.sh with root privileges, the following error is displayed in the shell terminal: image

Lines 80 - 83 are: echo $FREQ_TO_SET for i in $(seq 0 $CORES); do echo $FREQ_TO_SET > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq done

I'm wondering will this error affect the function of the script? It seems to be working OK, my laptop isn't going above 60c, which is the desired threshold.

I am running Peppermint Linux 3. If you need any other info, let me know!

Sepero commented 10 years ago

Fascinating error. I can try to solve it for you, but I'll need some more info about your system. Run this-

find /sys/ -iname "*freq*" > freq_list.txt

It will save output into a file named "freq_list.txt". I need to view the that output.

ghost commented 10 years ago

Here is the output from that file:

/sys/devices/pnp0/00:05/rtc/rtc0/max_user_freq /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_RP1_freq_mhz /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_min_freq_mhz /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_RPn_freq_mhz /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_RP0_freq_mhz /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_cur_freq_mhz /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_max_freq_mhz /sys/devices/system/cpu/cpu0/cpufreq /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq /sys/devices/system/cpu/cpu1/cpufreq /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_max_freq /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_min_freq /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq /sys/devices/system/cpu/cpu2/cpufreq /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_max_freq /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_min_freq /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq /sys/devices/system/cpu/cpu3/cpufreq /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_max_freq /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_min_freq /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq /sys/class/devfreq /sys/kernel/debug/dri/0/i915_ring_freq_table /sys/kernel/debug/dri/0/i915_delayfreq_table /sys/kernel/debug/dri/0/i915_min_freq /sys/kernel/debug/dri/0/i915_max_freq /sys/kernel/debug/dri/64/i915_ring_freq_table /sys/kernel/debug/dri/64/i915_delayfreq_table /sys/kernel/debug/dri/64/i915_min_freq /sys/kernel/debug/dri/64/i915_max_freq /sys/kernel/debug/tracing/events/i915/intel_gpu_freq_change /sys/kernel/debug/tracing/events/power/cpu_frequency /sys/module/acpi_cpufreq /sys/module/pcc_cpufreq /sys/module/cpufreq_nforce2

Sepero commented 10 years ago

Is it possible that you modified the script or are using an older version?

ghost commented 10 years ago

I am using 2.00, I'll try the newest now. I have made no modifications to the script.

ghost commented 10 years ago

OK, it looks like that issue is no longer occurring with 2.11. Sorry, I hadn't noticed there was an updated version. Thanks for this script btw, I don't know what I would do without it (for some reason my laptop idles at 70c+ in Linux without the script).

Sepero commented 10 years ago

Hey, I have the same problems, haha! Glad I could help. ;)

ghost commented 10 years ago

I spoke too soon. I am getting that error again (see first post above). This time, it's a write error for line 104, in which the frequency is set by writing it to the scaling_max_freq file for each core. I verified that the file exists. I'm wondering if it's actually writing to that file though. There is a frequency listed in that file, but only the frequency in the scaling_max_freq file for cpu0 seems to match the output of temp_throttle.sh in bash. Scaling_max_freq for cpu0 = 1600000, but for cpus 1-3 it = 2900000.

Is this typical behavior? I would think all 4 cores would be scaled equally?

Sepero commented 10 years ago

It appears that your CPU is only allowing you to throttle the first core of your system. I've never seen anyone report this before. It may be possible that throttling the first actually does throttle all cores, and that the other cores cannot be set individually. Give me the output of lscpu, and I'll leave this issue open in case anyone else comes along with more ideas or information.

For now, you should be fine to run the program as it is. To discard any error messages, run it like this-

sudo ./temp_throttle.sh 60 2> /dev/null
ghost commented 10 years ago
-Peppermint ~ $ lscpu:
Architecture:          i686
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 42
Stepping:              7
CPU MHz:               2277.000
BogoMIPS:              4589.76
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K

I'm using Jupiter for power management, which allows me to switch the governor between power saving and on demand. I wonder if that could be interfering, as now that I've disabled it, all the cores seem to be at the same frequency. I'm not even sure I need to be running Jupiter anymore as long as I'm using temp_throttle.sh, anyway. For now I'll just run the temp_throttle.sh output to /dev/null as you suggested.

Sepero commented 10 years ago

Try this: reboot, avoid running Jupiter, and run temp_throttle.sh without outputting to /dev/null. If you no longer get errors, then that will indicate Jupiter is causing the issue.

bandwith commented 10 years ago

I am curious to know what kernel version and kernel module configuration is in use. I hadn't heard of Peppermint OS prior to this.

On May 4, 2014 8:46:48 PM EDT, Sepero notifications@github.com wrote:

Try this: reboot, avoid running Jupiter, and run temp_throttle.sh without outputting to /dev/null. If you no longer get errors, then that will indicate Jupiter is causing the issue.


Reply to this email directly or view it on GitHub: https://github.com/Sepero/temp-throttle/issues/5#issuecomment-42152521

ghost commented 10 years ago

@Sepero OK, this is just tentative, I'll need to run temp_throttle.sh for a few more days before I know for sure, but it looks like Jupiter might have been interfering with the scaling. If anything changes, I'll let you know.

@bandwith it's a "cloud-centric" distro based on Lubuntu. I am running Peppermint 3 (Peppermint 4 is newer but they ditched LXDE/Openbox, and I really prefer that), using kernel 3.11.6 (I can't recall which version it shipped with).

I can give you the output of lsmod if you're interested.

ghost commented 10 years ago

Well, I am still getting that invalid argument error (line 104 now, where it set the max temp for all cores), but the script still works fine. My CPU temp never goes above the temp I set when executing temp-throttle.

Sepero commented 10 years ago

t4exanadu, did you also try rebooting and not running Jupiter? If so, I'll just leave this issue open for awareness to other people.

ghost commented 10 years ago

I have rebooted since then and removed Jupiter completely. I still get those errors when I execute temp-throttle from the command line (as sudo, of course). However, I now have temp-throttle in rc.local so it starts at boot time, and I don't see those errors appearing in any of my logs.

technik007cz commented 10 years ago

What is output of echo "scaling_min_freq=cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq" echo "scaling_max_freq=cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" ? If "scaling_max_freq" is higher than "scaling_min_freq" then system can have problem with it like my system.

technik007cz commented 10 years ago

Or you can try edit script. Find text "echo $FREQ_TO_SET > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq" and put on single line before it "echo $FREQ_TO_SET > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_min_freq". System can sometimes complain, but check temperature of your cpu first if this change helped.

ghost commented 10 years ago

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq: 800000

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: 1000000

I haven't been getting the error I used to get, though. It happens once a month or so, it's strange.

ghost commented 9 years ago

Hello. It seems OS not allowing directly writing to these files. I created a pull request that fixing this error: https://github.com/Sepero/temp-throttle/pull/8

Sepero commented 9 years ago

Hi zlay. I have reviewed your changes. I am not able to apply them as they are currently, because they introduce the dependency for the package "cpufrequtils". I think I will attempt to apply the changes similar to this logic:

try (echo $FREQ_TO_SET > max_freq)
    on fail try (cpufreq-set -c $i --max $FREQ_TO_SET)
        on fail try (echo suggestion to user to try installing cpufrequtils)

Thank you for your submission. :)

Sepero commented 9 years ago

I'm going to close this issue for now. It may be reopened if anyone writes in with future issues concerning this.