mprime-phc-setup - find best vids for undervolting, without crashing

Here’s a bash script that automatically finds the lowest vids your CPU can handle, hopefully without crashing your computer. It uses mprime to check for stability, unlike “linux-phc-optimize” that uses cpuburn/burnMMX (I found that linux-phc-optimize was not adequate to detect safe voltages on my Atom N270 and that led to application crashes very quickly.)

The phc_intel module has been built and successfully installed for my current kernel, which is 3.4.7-1-ARCH. I'm not sure if it'd be of any help, but cat /sys/devices/system/cpu/cpu0/cpufreq/phc_controls, as suggested on the PHC wiki article, outputs: 31:0 22:0 20:0 19:0 18:0 17:0 16:0 15:0 14:0 13:0 12:0 11:0 10:0 9:0 8:0.

Also, while this isn't necessarily the place to discuss the wiki article, I saw that you edited it significantly a few days ago, and I was wondering if the instruction (in the installation section) to add "acpi-cpufreq" as a module to be loaded at boot is correct. It seems, in the case of phc-intel, that /usr/lib/modprobe.d/phc-intel.conf modprobes acpi-cpufreq automatically.

I don’t think the default vids of your Core i7 are supposed to be 0 indeed… Maybe you should try the “TESTRELEASE” version 0.4 of PHC. (I haven’t tried it; just tried to build it but it complained about missing kernel sources. Maybe adapting the PKGBUILD of phc-intel would work.)

Also, while this isn't necessarily the place to discuss the wiki article, I saw that you edited it significantly a few days ago, and I was wondering if the instruction (in the installation section) to add "acpi-cpufreq" as a module to be loaded at boot is correct. It seems, in the case of phc-intel, that /usr/lib/modprobe.d/phc-intel.conf modprobes acpi-cpufreq automatically.

I didn’t change that part, and I don’t know if it’s needed or not. I had no idea there was a “/usr/lib/modprobe.d/” directory in addition to “/etc/modprobe.d/”… And then there’s this “/etc/modules-load.d/”… I’m lost.

Re: mprime-phc-setup - find best vids for undervolting, without crashing

Thanks. I was able to build and install this version, but I get the same results.Edit: Turns out I didn't successfully install it. I ran "make brave", "make", and "make install" but

cat /sys/devices/system/cpu/cpu0/cpufreq/phc_version

still reports 0.3.2:2. I must be missing something.

I didn’t change that part, and I don’t know if it’s needed or not. I had no idea there was a “/usr/lib/modprobe.d/” directory in addition to “/etc/modprobe.d/”… And then there’s this “/etc/modules-load.d/”… I’m lost.

Don't worry, I wasn't accusing you of anything. I figured you'd know more about it than myself, so I wanted to double-check before updating the article. I just took the plunge and edited that section.Edit: Apparently since kernel 3.4 the appropriate CPU frequency driver is loaded automatically, so the aforementioned discrepancy is null and void.

Re: mprime-phc-setup - find best vids for undervolting, without crashing

$ sudo sh vid_find
Password:
Warning: this might crash your computer or applications.
Please save all your work and don't do anything while the test is running.
You can stop the test at any time with CTRL-C.
Press RETURN to go on or CTRL-C to cancel.
Estimated time to completion: between 17 min and 52 min
Testing frequency 0 (2101000)…
Default vid: 39
Trying vid 38 for 20 seconds
.
ERROR: Wrong frequency! Is scaling_max_freq ignored?
Restoring state…

It's a C2D processor.

On a related note - is there a way to make it start from lower VID than the default? Would save quite some time and heat.

Re: mprime-phc-setup - find best vids for undervolting, without crashing

Lockheed wrote:

ERROR: Wrong frequency! Is scaling_max_freq ignored?

It's a C2D processor.

The wiki says C2D should work, but I don’t know… Does linux-phc-optimize work? It uses the userspace governor, while my script uses ondemand. Also you could try to set debug=1 to check some values (though it doesn’t display everything that could be useful.)

Frequency 0 is the highest one (2.1GHz is the max speed of your processor, right?) so it looks like mprime is not causing your processor to go up to the max frequency… Can you check that mprime uses all cores of your CPU and that the load is close to 100%?

Edit: just run “mprime -t” to check that.

Lockheed wrote:

On a related note - is there a way to make it start from lower VID than the default? Would save quite some time and heat.

I don’t think it would save that much time, but it could start from the current vids instead of the default vids. And/or I could add a “starting_vid” parameter… Edit: but in your case, starting for example from vid 20 instead of 38 would save 6 min, which while significant is also not very important for a test ran once in a lifetime.

Re: mprime-phc-setup - find best vids for undervolting, without crashing

I currently have phc running on lubuntu and a mobile core 2 duo but I used the "linux-phc-optimize 0.1-5" script which I feel resulted in some unstable voltages as my computer crashes quite frequently. I would really like to use your script but cannot get it to work. I have mprime and your script in the same folder. mprime works and phc is loaded. When I sudo run your script which I have called mprimescript I get many errors

mprimescript: 30: mprimescript: cannot open 15: No such file
mprimescript: 30: mprimescript: short_test_length: not found
mprimescript: 34: mprimescript: cannot open 30: No such file
mprimescript: 34: mprimescript: long_test_length: not found
mprimescript: 38: mprimescript: cannot open 1: No such file
mprimescript: 38: mprimescript: safety_vid_delta: not found
mprimescript: 44: mprimescript: [[: not found
mprimescript: 51: mprimescript: 0: not found
mprimescript: 65: mprimescript: [[: not found
Warning: this might crash your computer or applications.
Please save all your work and don't do anything while the test is running.
You can stop the test at any time with CTRL-C.
Press RETURN to go on or CTRL-C to cancel.
mprimescript: 76: read: arg count
mprimescript: 86: mprimescript: [[: not found
mprimescript: 93: mprimescript: function: not found
mprimescript: 97: mprimescript: cannot create /sys/devices/system/cpu/cpu0/cpufreq/: Is a directory
mprimescript: 97: mprimescript: cannot create /sys/devices/system/cpu/cpu1/cpufreq/: Is a directory
mprimescript: 101: mprimescript: function: not found
Restoring state…
mprimescript: 111: mprimescript: set_sys_val: not found
mprimescript: 114: mprimescript: set_sys_val: not found
mprimescript: 117: mprimescript: set_sys_val: not found
mprimescript: 120: mprimescript: [[: not found
mprimescript: 133: mprimescript: freq[nb_freqs]=2800000: not found
mprimescript: 134: mprimescript: nb_freqs++: not found
mprimescript: 133: mprimescript: freq[nb_freqs]=2133000: not found
mprimescript: 134: mprimescript: nb_freqs++: not found
mprimescript: 133: mprimescript: freq[nb_freqs]=1600000: not found
mprimescript: 134: mprimescript: nb_freqs++: not found
mprimescript: 133: mprimescript: freq[nb_freqs]=800000: not found
mprimescript: 134: mprimescript: nb_freqs++: not found
mprimescript: 140: mprimescript: vid[nb_vids]=37: not found
mprimescript: 141: mprimescript: nb_vids++: not found
mprimescript: 140: mprimescript: vid[nb_vids]=30: not found
mprimescript: 141: mprimescript: nb_vids++: not found
mprimescript: 140: mprimescript: vid[nb_vids]=23: not found
mprimescript: 141: mprimescript: nb_vids++: not found
mprimescript: 140: mprimescript: vid[nb_vids]=17: not found
mprimescript: 141: mprimescript: nb_vids++: not found
mprimescript: 144: mprimescript: [[: not found
mprimescript: 158: mprimescript: Bad substitution
mprimescript: 1: mprimescript: cleanup: not found

Re: mprime-phc-setup - find best vids for undervolting, without crashing

GFB wrote:

This script doesn't work with my Lenovo T500. A kernel panic occures and the state is not saved. After reboot it starts from scratch.

Indeed the state is not saved, as the idea was that the script wouldn’t crash… I see that the Lenovo T500 has a Core 2 Duo, so according to the wiki it should work. Did you try changing the values at the start of the script? Since you’re talking about starting from scratch, I assume that the script at least started correctly? Did it crash while testing the first frequency or did it crash later? Did you try the other script mentionned in the wiki and did it work better?

Edit: if you want to try changing the default settings, I suggest increasing short_test_length. But maybe the crash is due to something else.

Re: mprime-phc-setup - find best vids for undervolting, without crashing

OdinEidolon wrote:

Without commenting those lines the script does not work. Would it be possible to fix it?

Oooookay… I just spent way too many hours on this.

I made a few changes to the script:- use the userspace governor instead of ondemand (like linux-phc-optimize)- fix a bug (?): I was only changing the first core’s governor- read scaling_cur_freq instead of cpuinfo_cur_freq (here, cpuinfo_cur_freq never shows the freq I’m trying to set)- explicitely kill mprime at exit because sometimes it was still running- minor other changes

Re: mprime-phc-setup - find best vids for undervolting, without crashing

stqn wrote:

Here’s a bash script that automatically finds the lowest vids your CPU can handle, without crashing your computer. It uses mprime to check for stability, as opposed to cpuburn/burnMMX as used by the “linux-phc-optimize” script. I found that that script was not adequate to detect safe voltages on my Atom N270 and that led to application crashes very quickly.

I have used it succesfully on my Atom N270 netbook (running Xubuntu 12.04), and semi-succesfully on my Core i3 550 (running Arch). “Semi”-succesfully because I couldn’t make it lock the Core i3 frequency; writes to scaling_max_freq are ignored and the frequency always goes to the max, so only the highest frequency can be tested.

It requires mprime to be installed or in the current directory, and of course PHC must be installed and loaded.

Sometimes mprime is still running after the test has ended. It is not supposed to happen and I don’t know why it does.

I’m leaving the original version below for reference, at least until the new version is proven to be an improvement…

Hi there,

I wanted to use your script but it always fails during the process of finding the values. I first assumed tlp to be the cause of the failure as it might adjust the govenor and the frequency in the background. However, even stopping tlp still causes the same error:

Re: mprime-phc-setup - find best vids for undervolting, without crashing

Seems like a nice idea but be aware that mprime is the end-all in determining stability. In fact, depending on how the voltage is controlled by the BIOS, a minimal vcore setting that leads to stable priming may not be stable for other tasks that don't require the full vcore such as compiling or x264 encoding since they are not as demanding. For more, see: https://wiki.archlinux.org/index.php/St … g_Programs

Re: mprime-phc-setup - find best vids for undervolting, without crashing

graysky wrote:

Seems like a nice idea but be aware that mprime is the end-all in determining stability. In fact, depending on how the voltage is controlled by the BIOS, a minimal vcore setting that leads to stable priming may not be stable for other tasks that don't require the full vcore such as compiling or x264 encoding since they are not as demanding. For more, see: https://wiki.archlinux.org/index.php/St … g_Programs

This wiki entry does not mention which cpu governor was used, and if the frequency was fixed or not… Does that machine change CPU voltage for a given fixed frequency depending on load?

Re: mprime-phc-setup - find best vids for undervolting, without crashing

orschiro wrote:

I wanted to use your script but it always fails during the process of finding the values. I first assumed tlp to be the cause of the failure as it might adjust the govenor and the frequency in the background. However, even stopping tlp still causes the same error:

What is tlp?It looks like something is changing your frequency in the middle of the test.