You are not logged in.

#1 2012-08-04 21:38:40

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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.)

I have used mprime-phc-setup succesfully on my Atom N270 netbook (running Xubuntu 12.04), and on my Core i3 550 (running Arch).

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

The latest version of this script can be found on bitbucket.

To use the script, just right-click on the link above and save the file, then flag it as executable (chmod +x mprime-phc-setup) and run it (sudo ./mprime-phc-setup).

2013-08-14 update: added resume after crash (re-run the script after a crash and it will continue from the point it stopped at) and a couple tiny tweaks to help not crash.

Last edited by stqn (2013-08-14 12:05:57)

Offline

#2 2012-08-10 16:05:58

Supplantr
Member
From: a state of sunshine
Registered: 2011-12-12
Posts: 149
Website

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

Hello, I tried your script and it runs on my Core i7-2670QM, but it doesn't seem to do anything. Its final output is:

All done.
Default vids: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
Final vids:   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

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 use linux and I dont understand nothing in this post.

Offline

#3 2012-08-10 16:50:36

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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

Hi Supplantr, thanks for the feedback.

Supplantr wrote:

Hello, I tried your script and it runs on my Core i7-2670QM, but it doesn't seem to do anything. Its final output is:

All done.
Default vids: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
Final vids:   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

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.)

Edit: Get the archive from http://www.linux-phc.org/forum/viewtopic.php?f=7&t=267 instead, this one builds fine. (Type “make brave” then “make”.)

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.

Last edited by stqn (2012-08-10 17:14:23)

Offline

#4 2012-08-12 18:41:54

Supplantr
Member
From: a state of sunshine
Registered: 2011-12-12
Posts: 149
Website

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

stqn wrote:

Edit: Get the archive from http://www.linux-phc.org/forum/viewtopic.php?f=7&t=267 instead, this one builds fine. (Type “make brave” then “make”.)

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. wink 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.

Last edited by Supplantr (2012-08-13 22:33:26)


I use linux and I dont understand nothing in this post.

Offline

#5 2012-08-28 16:51:29

Lockheed
Member
Registered: 2010-03-16
Posts: 1,427

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.

Last edited by Lockheed (2012-08-28 16:52:20)


Laptop: ThinkPad W500, C2D P9500, 8GB, Radeon RV635 (HD3650), Arch | Server/fw: Zotac AQ01, A4-5000 Kabini, 4GB, Arch/pfSense VM

Offline

#6 2012-08-28 18:00:40

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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.

Last edited by stqn (2012-08-28 18:09:32)

Offline

#7 2012-08-28 22:48:21

Lockheed
Member
Registered: 2010-03-16
Posts: 1,427

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

No, 0 is the voltage, not frequency. On my setup 0=0.95V and 23=1V
And yes, mprime stresses it to 100%

I already have a working phc undervolting since over a year, I just wanted to see if with this script I will be able to improve on it.


Laptop: ThinkPad W500, C2D P9500, 8GB, Radeon RV635 (HD3650), Arch | Server/fw: Zotac AQ01, A4-5000 Kabini, 4GB, Arch/pfSense VM

Offline

#8 2012-10-23 19:51:26

gridmuncher
Member
Registered: 2012-10-23
Posts: 2

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

Any help would be appreciated! Thanks

Offline

#9 2012-10-23 19:57:54

gridmuncher
Member
Registered: 2012-10-23
Posts: 2

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

I'm a bit of an idiot. A quick google has shown the problem to be using the sh command instead of bash. I'm leaving my original post in case there are any other noobs as simple as me.

(not likely! wink)

Offline

#10 2012-10-23 20:49:22

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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

Well I hope it worked in the end gridmuncher wink

Offline

#11 2012-11-19 00:15:12

impact
Member
Registered: 2012-10-28
Posts: 55

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

stqn wrote:

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.

Do you think using that: http://code.google.com/p/i7z/ (package in Arch common) could solve this issue?
Check out the last post here: http://www.linux-phc.org/forum/viewtopic.php?f=8&t=339

I have an i3 to undervolt and want to get some opinions before I start.

Offline

#12 2012-11-19 12:59:27

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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

impact wrote:

Do you think using that: http://code.google.com/p/i7z/ (package in Arch common) could solve this issue?

I don’t see how this relates, the i7z tool seems to only display information…

Offline

#13 2012-12-29 19:59:19

OdinEidolon
Member
From: Belluno - Italy
Registered: 2011-01-31
Posts: 316

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

My PC (sig) actually crashed where linux-phc-optimize didn't while running this script. I also had to comment the lines where it checked for the scaling_max_freq issue.


Hardware: 2016 Dell XPS15 - FullHD - i5-6300HQ - 8GB DDR4 - Nvidia GTX960M - Samsung 840EVO 250GB SSD - 56Wh
Software: Plasma 5 - rEFInd - linux-ck - preload - prelink - verynice - psd - bumblebee

Offline

#14 2013-01-30 13:43:00

GFB
Member
Registered: 2012-06-01
Posts: 10

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

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.

Offline

#15 2013-01-30 17:16:37

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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.

Last edited by stqn (2013-01-30 17:20:02)

Offline

#16 2013-01-31 18:17:29

GFB
Member
Registered: 2012-06-01
Posts: 10

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

The script worked, i had to comment some line mentioned above. The crash (kernel panic) was forced by the low voltage smile

The other script worked, too. But I wanted to get better values.

Offline

#17 2013-01-31 19:05:40

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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

GFB wrote:

The script worked, i had to comment some line mentioned above. The crash (kernel panic) was forced by the low voltage smile

If by this you refer to

OdinEidolon wrote:

I also had to comment the lines where it checked for the scaling_max_freq issue.

then of course that caused problems. Please don’t make bug reports when you have changed the source code and without mentionning it… Sigh…

Offline

#18 2013-01-31 19:32:11

OdinEidolon
Member
From: Belluno - Italy
Registered: 2011-01-31
Posts: 316

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

stqn wrote:
GFB wrote:

The script worked, i had to comment some line mentioned above. The crash (kernel panic) was forced by the low voltage smile

If by this you refer to

OdinEidolon wrote:

I also had to comment the lines where it checked for the scaling_max_freq issue.

then of course that caused problems. Please don’t make bug reports when you have changed the source code and without mentionning it… Sigh…

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


Hardware: 2016 Dell XPS15 - FullHD - i5-6300HQ - 8GB DDR4 - Nvidia GTX960M - Samsung 840EVO 250GB SSD - 56Wh
Software: Plasma 5 - rEFInd - linux-ck - preload - prelink - verynice - psd - bumblebee

Offline

#19 2013-02-01 01:33:27

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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

I also setup a git repository on bitbucket in order to keep the history in case someone finds that the previous version worked better… You can get the new version of the script here.

Tell me if it helps… in case of failure a log (with debug=1) would be appreciated, but I’m afraid I can’t do much more than that anyway.

Last edited by stqn (2013-02-01 01:36:41)

Offline

#20 2013-06-09 08:02:16

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

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.

EDIT: The latest version of this script can be found on bitbucket. It contains significant changes that may or may not make it work better on your computers.

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:

Switching to the userspace governor. userspace will be restored later.
Estimated time to completion: between 18 min and 45 min

Testing frequency 0 (1867000)…
Default vid: 41
Trying vid 40 for 20 seconds
....................
Trying vid 39 for 20 seconds
....................
Trying vid 38 for 20 seconds
....................
Trying vid 37 for 20 seconds
....................
Trying vid 36 for 20 seconds
....................
Trying vid 35 for 20 seconds
.....
ERROR: Wrong frequency! (800000 instead of 1867000)
cpu0/cpufreq/scaling_governor = userspace
cpu1/cpufreq/scaling_governor = userspace
cpu0/cpufreq/cpuinfo_cur_freq = 800000
cpu1/cpufreq/cpuinfo_cur_freq = 800000
cpu0/cpufreq/scaling_cur_freq = 800000
cpu1/cpufreq/scaling_cur_freq = 800000
cpu0/cpufreq/phc_vids = 35 30 23 17 
cpu1/cpufreq/phc_vids = 35 30 23 17 

Restoring state…

Offline

#21 2013-06-09 10:47:30

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

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


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

Offline

#22 2013-06-09 19:20:06

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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?

Edit: clarification.

Last edited by stqn (2013-06-10 12:51:28)

Offline

#23 2013-06-09 19:22:37

stqn
Member
Registered: 2010-03-19
Posts: 1,189
Website

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.

Offline

#24 2013-06-10 07:34:36

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

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

tlp is an advanced power management tool: https://wiki.archlinux.org/index.php/TLP

But what else could change the frequency apart from tlp which I have disabled?

Offline

#25 2013-06-11 05:39:32

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

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

Can it be a problem with your script?

cpupower reports me the correct frequency:

Testing frequency 0 (1867000)…
Default vid: 41
Trying vid 40 for 20 seconds
....................
Trying vid 39 for 20 seconds
....................
Trying vid 38 for 20 seconds
....................
Trying vid 37 for 20 seconds
....................
Trying vid 36 for 20 seconds
..............
ERROR: Wrong frequency! (800000 instead of 1867000)
cpu0/cpufreq/scaling_governor = userspace
cpu1/cpufreq/scaling_governor = userspace
cpu0/cpufreq/cpuinfo_cur_freq = 1866000
cpu1/cpufreq/cpuinfo_cur_freq = 1866000
cpu0/cpufreq/scaling_cur_freq = 1867000
cpu1/cpufreq/scaling_cur_freq = 1867000
cpu0/cpufreq/phc_vids = 36 30 23 17 
cpu1/cpufreq/phc_vids = 36 30 23 17 

Restoring state…
[orschiro@thinkpad ~]$ cpupower frequency-info
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 800 MHz - 1.87 GHz
  available frequency steps: 1.87 GHz, 1.87 GHz, 1.60 GHz, 800 MHz
  available cpufreq governors: userspace, ondemand, performance
  current policy: frequency should be within 800 MHz and 1.87 GHz.
                  The governor "userspace" may decide which speed to use
                  within this range.
  current CPU frequency is 1.87 GHz.

Offline

Board footer

Powered by FluxBB