Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: ‘MSR_NHM_TURBO_RATIO_LIMIT’ undeclared #11

Closed
JodiTheTigger opened this issue Oct 17, 2016 · 16 comments
Closed

error: ‘MSR_NHM_TURBO_RATIO_LIMIT’ undeclared #11

JodiTheTigger opened this issue Oct 17, 2016 · 16 comments

Comments

@JodiTheTigger
Copy link

Trying to install from Arch AUR and I get the build error:

aur-corefreq-git/src/CoreFreq/corefreqk.c:824:15: error: ‘MSR_NHM_TURBO_RATIO_LIMIT’ undeclared (first use in this function)
  RDMSR(Turbo, MSR_NHM_TURBO_RATIO_LIMIT);
               ^
==> Starting build()...
make: Entering directory 'aur-corefreq-git/src/CoreFreq'
cc -c corefreqd.c -o corefreqd.o
cc -lpthread -lrt -o corefreqd corefreqd.c
cc -c corefreq-cli.c -o corefreq-cli.o
cc -lrt -o corefreq-cli corefreq-cli.c
make -C /lib/modules/4.8.2-1-ARCH/build M=aur-corefreq-git/src/CoreFreq modules
make[1]: Entering directory '/usr/lib/modules/4.8.2-1-ARCH/build'
  CC [M]  aur-corefreq-git/src/CoreFreq/corefreqk.o
In file included from aur-corefreq-git/src/CoreFreq/corefreqk.c:23:0:
aur-corefreq-git/src/CoreFreq/corefreqk.c: In function ‘Nehalem_Platform_Info’:
aur-corefreq-git/src/CoreFreq/corefreqk.c:824:15: error: ‘MSR_NHM_TURBO_RATIO_LIMIT’ undeclared (first use in this function)
  RDMSR(Turbo, MSR_NHM_TURBO_RATIO_LIMIT);
               ^
aur-corefreq-git/src/CoreFreq/corefreqk.h:51:10: note: in definition of macro ‘RDMSR’
   : "c" (_reg)      \
          ^~~~
aur-corefreq-git/src/CoreFreq/corefreqk.c:824:15: note: each undeclared identifier is reported only once for each function it appears in
  RDMSR(Turbo, MSR_NHM_TURBO_RATIO_LIMIT);
               ^
aur-corefreq-git/src/CoreFreq/corefreqk.h:51:10: note: in definition of macro ‘RDMSR’
   : "c" (_reg)      \
          ^~~~
make[2]: *** [scripts/Makefile.build:296: aur-corefreq-git/src/CoreFreq/corefreqk.o] Error 1
make[1]: *** [Makefile:1471: _module_aur-corefreq-git/src/CoreFreq] Error 2
make[1]: Leaving directory '/usr/lib/modules/4.8.2-1-ARCH/build'
make: *** [Makefile:6: all] Error 2
make: Leaving directory 'aur-corefreq-git/src/CoreFreq'
==> ERROR: A failure occurred in build().
    Aborting...
==> ERROR: Makepkg was unable to build corefreq-git.

cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 60
model name      : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
stepping        : 3
microcode       : 0x19
cpu MHz         : 3902.343
cache size      : 8192 KB
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm xsaveopt dtherm ida arat pln pts
bugs            :
bogomips        : 7198.35
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

<snip for other 7 cores>
@cyring
Copy link
Owner

cyring commented Oct 18, 2016

Hello,
Do you have linux-headers package installed ?
Because MSR_NHM_TURBO_RATIO_LIMIT is defined into /usr/include/asm/msr-index.h which is a header file included in this package.

@oleksandr-oksenenko-zz
Copy link

oleksandr-oksenenko-zz commented Oct 18, 2016

Hey,
I have the same problem building the module on Arch (though not from AUR).
I do have /usr/include/asm/msr-index.h and there's MSR_NHM_TURBO_RATIO_LIMIT in it.

@oleksandr-oksenenko-zz
Copy link

I figured it out, the problem is the custom kernel i use (linux-pf). For some reason, the module builds only with stock Arch kernel.

@oleksandr-oksenenko-zz
Copy link

Hm, seems like the custom kernel is not the issue :)
I installed the Arch stock kernel of version 4.8.2 from testing and the build fails.
So i think the actual reason is the kernel version.

@cyring
Copy link
Owner

cyring commented Oct 18, 2016

Thanks for your return 💯

I have also noticed that you are using a testing version 4.8 of the kernel (as JodiTheTigger's log) whereas I'm compiling with the current version 4.7.6-1 for ArchLinux.

Meanwhile I also found that 2 packages provide the msr definition:

  1. linux-api-headers (/usr/include/asm/msr-index.h)
  2. linux-headers /usr/lib/modules/4.7.6-1-ARCH/build/arch/x86/include/asm/msr-index.h)
    (any diff however between these 2 files).

If you want to stick with the testing kernel, I suggest you to copy/write the few missing definitions into the CoreFreq header file 'intelmsr.h' , such as:

#define MSR_NHM_TURBO_RATIO_LIMIT 0x000001ad

@oleksandr-oksenenko-zz
Copy link

JFYI i found the following patch: https://patchwork.kernel.org/patch/9217367/ .
Seems like MSR_TURBO_RATIO_LIMIT should be used now, what do you think?

@cyring
Copy link
Owner

cyring commented Oct 18, 2016

Indeed, they are duplicated.
So, I have push an updated corefreqk.c to handle this change.
I also test the case (lines #889) that it will style build with previous kernel versions.

@oleksandr-oksenenko-zz
Copy link

Great, thanks :)

@cyring
Copy link
Owner

cyring commented Oct 18, 2016

Btw, I just few CPU to test CoreFreq with (Bloomfield, Core 2 duo T7250, AMD Turion)
I will appreciate if you can post in reply screenshots of corefreq-cli monitoring your processor(s).
That will be a great help.

@oleksandr-oksenenko-zz
Copy link

oleksandr-oksenenko-zz commented Oct 18, 2016

Sure.
I also loaded one core with CPU-bounded task.

screenshot_20161018_160527

@cyring
Copy link
Owner

cyring commented Oct 18, 2016

CoreFreq is running a Haswell, Thank you very much 👍

My 2 ways to reach the max turbo on 1 core:
sol 1. in BIOS, limit your settings to one core only activated
sol 2. disable all cores beside #0 using command
echo 0 > /sys/devices/system/cpu/cpu1/online
echo 0 > /sys/devices/system/cpu/cpu2/online
...
echo 0 > /sys/devices/system/cpu/cpu7/online

solution 2 is easier and CoreFreq is cpu hot-plug aware; thus you can disable/enable as wishes.

Prerequisites:
1- 'intel_idle' is your actual Linux cpudriver
--> you can check it by restarting corefreqk.ko module with the option IdleDriverQuery=1
--> next, in corefreq-cli the cpu driver will be printed beside the Linux version

2- Blacklist the module nmi_watchdog (which consumes permanently one fixed state counter)
--> In your kernel boot argument, you can add: nmi_watchdog=0

3- Decrease the sleep interval of corefreqk to its minimum of 500 ms
--> use the option SleepInterval=500 when starting module
This should provide an almost real time monitoring of the cores.

@oleksandr-oksenenko-zz
Copy link

I don't need max turbo on one core :)
I just ran it so there would be some activity on the screenshot other than just 0-1% jitter.
Anyway, thanks for the tips!

@JodiTheTigger
Copy link
Author

screenshot from 2016-10-19 15-55-18

@JodiTheTigger
Copy link
Author

Ok, so I tried the AUR package again, and it all works! Thanks!

@cyring
Copy link
Owner

cyring commented Oct 19, 2016

@ JodiTheTigger: Thank you for your screenshot, but I can see some layout issues.

  • red turbo bars going out of the view
  • footer line is repeated 3 times
    Do you confirm these layout issues ?

@JodiTheTigger
Copy link
Author

Running it in under fish using konsole under gnome3 on arch linux.

yes, I consistently get both issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants