undervolting (e.g. skylake) in linux

Discussion in 'Hardware Components and Aftermarket Upgrades' started by conker_ts, Aug 13, 2017.

  1. conker_ts

    conker_ts Notebook Enthusiast

    Reputations:
    5
    Messages:
    30
    Likes Received:
    36
    Trophy Points:
    26
    Hi everyone,
    I don't know the best location to post this, so I chose this Forum, as the throttlestop guide is also here.

    How much interest is there in undervolting (e.g. skylake) in linux ?

    (Update: For the tl;dr people: read the last paragraph of this post)

    I like the skylake processors and I'm satisfied with the performance.
    Even though sometimes annoying with Intels Bugs (like HT) and no µCode updates from my manufacturer (Asus).
    So I'd like to switch finally to Linux, but I also like the improved/lower temperatures through undervolting.

    I'm quite annoyed that Intel didn't release the full documentation of the model-specific registers for voltage regulation. (I had a look at Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 4: Model-Specific Registers)

    So, there is only Intel XTU or this throttlestop tool and the developer doesn't plan a linux version and doesn't want to share the needed information. (I don't blame him, that he doesn't want to make his program open source). http://forum.notebookreview.com/threads/the-throttlestop-guide.531329/page-608#post-10542530

    Anyway, this leads to the following situation:

    I informed myself about the current state and possible solutions. As I don't have that much time, my main goal is to find other people, who are intrested in this and we can discuss things and split the workload.

    There are only old threads as I found.
    http://forum.notebookreview.com/threads/undervolting-the-thinkpad-x120e-in-linux-rev-1.600939/

    At least the second part of it is using the linux msrtool:
    http://forum.notebookreview.com/threads/throttlestop-for-linux.539117/
    So that should be done with some lines of python code, when we have the desired values and know the correct registers.


    So my current ideas are:

    * Method 1: Full brute force approach:
    There are tools like rweverything, msr tool for windows which can read the msr registers (maybe there are some better tools)
    https://rweverything.com/ (Interesting tool, but strange UI and don't know if cmd line working)
    https://01.org/msr-tools (update: this is for linux, I thought of another tool, but can't find the link ...)
    (maybe there are some other & better tools)

    1. Make a full MSR dump.
    2. Change a parameter/voltage with throttlestop/Intel XTU
    3. look, what changed in the MSR dump


    * Method 2: Sniff throttlestop/Intel XTU
    That would mean place a hook on the dll with the read/write MSR function, and sniff all the commands the application sends to the processor. Then we get the values and registers.
    http://forum.notebookreview.com/threads/the-throttlestop-guide.531329/page-278

    1. hook dll
    2. Change a parameter/voltage with throttlestop/Intel XTU
    3. then look at the intercepted commands

    Both approaches would create a database for our specific CPUs.


    So what do you think ?


    ---------------------------
    Update for the tl;dr people:
    The first results start here
    http://forum.notebookreview.com/thr...-skylake-in-linux.807953/page-4#post-10589204
     
    Last edited: Sep 7, 2017
    _pk, alfazaz, Vasudev and 1 other person like this.
  2. Vasudev

    Vasudev Notebook Virtuoso

    Reputations:
    594
    Messages:
    2,839
    Likes Received:
    1,338
    Trophy Points:
    181
    No undervolting can be done in Linux w/o saving settings using XTU in windows. I found that temps in linux are far lower in Linux than Windows w/ undervolted settings.
    Make sure your are on Ubuntu 16.04 or higher w/ kernel 4.10, then install tlp. Yours temps will be fine. As for microcode update just install the deb file from this link and use GDebi to install it and microcode is updated to latest.
    The file will be intel-microcode_3.20170707.1~ubuntu17.04.0_amd64.deb (64bit) and i386 for x86.
     
    hmscott likes this.
  3. conker_ts

    conker_ts Notebook Enthusiast

    Reputations:
    5
    Messages:
    30
    Likes Received:
    36
    Trophy Points:
    26
    Yeah, temps are "ok" most of the time.
    But there is a difference under load: I undervolted -180mV, this makes 40W vs. 27W (says AIDA) and is the difference between thermal throttling and no throttling ;)

    And yeah, I know this HT bug is solved in the latest µCode update in Ubuntu. That's why I want to switch.
     
    alfazaz and hmscott like this.
  4. Vasudev

    Vasudev Notebook Virtuoso

    Reputations:
    594
    Messages:
    2,839
    Likes Received:
    1,338
    Trophy Points:
    181
    Even on Windows its fixed using VMWARE cpu ucode updater.
     
    hmscott likes this.
  5. conker_ts

    conker_ts Notebook Enthusiast

    Reputations:
    5
    Messages:
    30
    Likes Received:
    36
    Trophy Points:
    26
    Ok, that's a valid point. But it is linked to additional work on my side (besides using OO shut-up and stuff) while Ubuntu does this out of the box.
    The only real reason for windows is some casual gaming, if any.
    So yeah, I have to invest the work somewhere else, but at least I have a not spying OS ;)
     
    hmscott likes this.
  6. Vasudev

    Vasudev Notebook Virtuoso

    Reputations:
    594
    Messages:
    2,839
    Likes Received:
    1,338
    Trophy Points:
    181
    Naah, ubuntu doesn't patch it by default because sometimes it ruins UEFI secure boot. However, you can install synaptic package Manager and install Intel CPU microcode, extended addons etc..
     
    hmscott likes this.
  7. Vasudev

    Vasudev Notebook Virtuoso

    Reputations:
    594
    Messages:
    2,839
    Likes Received:
    1,338
    Trophy Points:
    181
  8. fasterlighterthinner

    fasterlighterthinner Newbie

    Reputations:
    0
    Messages:
    3
    Likes Received:
    2
    Trophy Points:
    6
    I would also be interested in some way to undervolt and overclock in linux, but have no real experience with it.

    The answer from the throttlestop author here

    https://askubuntu.com/questions/337147/throttlestop-for-ubuntu

    suggests doing the change in Windows, reading the values with MSR Tool and then writing the same values to the CPU-registers from within Linux.
     
    alfazaz and Vasudev like this.
  9. conker_ts

    conker_ts Notebook Enthusiast

    Reputations:
    5
    Messages:
    30
    Likes Received:
    36
    Trophy Points:
    26
    Hi,
    ok that's nice for a start. I didn't find that post ...
    The problem is, this post is from 2013 and is about Intel Gen2/3.

    That's basically my first approach, but he has named one of the registers.

    I'm not that keen to run this msr exe from some mediafire link on my NB, especially because it will require admin rights.
    I'll test, if the tools from the ms debugging sdk will work: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/rdmsr--read-msr-

    My plan:
    Step 1 would be to find the relevant registers. By making some 1, 2, 5, 20, 50, 100 mV change and then look what changed in the dump.

    So I need to find 4 values:
    CPU Core
    CPU Cache

    Intel GPU
    System Agent

    Afterwards, in step 2 I'd set directly to my desired undervolted values and store them. Later we could try to find the calculation formula for voltage->register, but that is totally optional.

    I don't know if we need BD PROCHOT, maybe as an addon ...
    I don't use all the other settings. (Turbo Time Limit maybe, too)

    Also some debugging infos would be nice, like the current FID & VID, to check, if the change actually worked.
    The problem with my dump method is, that these state infos always change, so there will be regions in the dump, which will always change, too.
    Nothing too difficult, but that will cost time to identify them.


    I think the second approch is way cooler, but I first need to find the correct tools, and other users probably wouldn't be able to repeat the steps ...


    Implementation stuff / details:

    The link also seems quite useful, if you want to make a complete tool like throttlestop.
    I'd be happy even with a lite version / batch script, which will just set the values to the windows settings (because that's a lot less work ;) )

    I think, the linux part won't be that difficult.
    Either using some basis like this,
    https://github.com/01org/msr-tools
    or the previousl mentioned repo package
    or the sorche seems to hint, that we just need to the following file.

    char msr_file_name[64];
    sprintf(msr_file_name, "/dev/cpu/%d/msr", cpu);
    fd = open(msr_file_name, O_WRONLY);

    That's easy, as long the linux interface is there.

    I can code in python, so that shouldn't be a problem either. (As there is nothing time critical in setting the registers)

    Basically, I use two profiles:
    * maximum undervolt (cpu is -180mV, which is totally fine, until I start a 3d application on my nvidia, then I get a bsod :p)
    * stable uv (cpu is -145mV, works always)
    (both graphics are always -125mV)

    So storing these values in a profile file would be no problem.


    And as I probably wrote somewhere, I've got Skylake (i7-6700hq to be precise). I don't know, how similar the other processors / generations will be.

    So which processor do you have ?
     
    Last edited: Aug 16, 2017
    alfazaz and Vasudev like this.
  10. Vasudev

    Vasudev Notebook Virtuoso

    Reputations:
    594
    Messages:
    2,839
    Likes Received:
    1,338
    Trophy Points:
    181
    Its skylake.
     
Loading...

Share This Page