We have written many articles about CPU monitoring tools in past. Today we are going to discuss about CoreFreq, a powerful CPU monitoring software designed for the 64-bits Processors which I came across recently.
CoreFreq is a CPU monitoring software designed for Intel 64-bits Processors and supported architectures are Atom, Core2, Nehalem, SandyBridge and superior, AMD Family 0F.
CoreFreq provides a framework to retrieve CPU data with a high degree of precision.
- Core frequencies & ratios; SpeedStep (EIST), Turbo Boost, Hyper-Threading (HTT) and Base Clock
- Performance counters including Time Stamp Counter (TSC), Unhalted Core Cycles (UCC), Unhalted Reference Cycles (URC)
- Number of instructions per cycle or second, IPS, IPC, or CPI
- CPU C-States C0 C1 C3 C6 C7 – C1E – Auto/UnDemotion of C1 C3
- DTS Temperature and Tjunction Max, Thermal Monitoring TM1 TM2 state
- Topology map including Caches for boostrap & application CPU
- Processor features, brand & architecture strings
Suggested Read : Check Available Monitoring Tools for Linux
CoreFreq implements a Linux Kernel module which employs the followings.
- asm code to keep as near as possible readings of the performance counters;
- per-CPU, implements slab data memory and high-resolution timer;
- compliant with suspend / resume and CPU Hot-Plug;
- a shared memory to protect kernel from the user-space part of the software;
- atomic synchronization of threads to avoid mutexes and deadlock.
How to install CoreFreq in Linux
Linux distributions doesn’t ship with CoreFreq packages by default and there is no official distribution packages too. So the only option to build from source.
Arch Linux users can install from AUR repository with help of yaourt or packer command.
$ yaourt -S corefreq-git or $ packer -S corefreq-git
First you have to install the prerequisite packages, in order to compile the program from source.
For CentOS/RHEL systems.
$ sudo yum groupinstall 'Development Tools'
For Fedora system.
$ sudo dnf groupinstall 'Development Tools'
For openSUSE system.
zypper install -t pattern devel_C_C++
For Debian based system.
$ sudo apt-get install build-essential dkms git libpthread-stubs0-dev
Clone the github repository then compile it by navigating to CoreFreq directory.
$ git clone https://github.com/cyring/CoreFreq.git $ cd CoreFreq $ make
Run the following command to load Linux kernel module from local directory
$ sudo insmod ./corefreqk.ko
Now, start the daemon in background.
sudo ./corefreqd &
Finally, start the client
$ ./corefreq-cli
Press F2
to display a usage menu for CoreFreq. Use Right
& Left
arrows to move over the menu tabs. Use Up
& Down
arrows to select a menu item, then hit Enter
to bring the corresponding information.
Open a quick reference by hitting h
and Hit F4
to close the utility.
Add -s
option followed by corefreq command to print the system information.
$ ./corefreq-cli -s Processor [Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz] |- Vendor ID [GenuineIntel] |- Signature [06_5E] |- Stepping [ 3] |- Architecture [Skylake/S] |- Online CPU [2/2] |- Base Clock [ 98] |- Ratio Boost: | Min Max 8C 7C 6C 5C 4C 3C 2C 1C | 26 26 - - - - 42 42 42 42 Instruction set: |- 3DNow!/Ext [N,N] AES [Y] AVX/AVX2 [Y/N] BMI1/BMI2 [N/N] |- CLFSH [Y] CMOV [Y] CMPXCH8 [Y] CMPXCH16 [Y] |- F16C [N] FPU [Y] FXSR [Y] LAHF/SAHF [Y] |- MMX/Ext [Y/N] MONITOR [N] MOVBE [Y] PCLMULDQ [Y] |- POPCNT [Y] RDRAND [Y] RDTSCP [Y] SEP [Y] |- SSE [Y] SSE2 [Y] SSE3 [Y] SSSE3 [Y] |- SSE4.1/4A [Y/N] SSE4.2 [Y] SYSCALL [Y] Features: |- 1 GB Pages Support 1GB-PAGES [Missing] |- 100 MHz multiplier Control 100MHzSteps [Missing] |- Advanced Configuration & Power Interface ACPI [Missing] |- Advanced Programmable Interrupt Controller APIC [Present] |- Core Multi-Processing CMP Legacy [Missing] |- L1 Data Cache Context ID CNXT-ID [Missing] |- Direct Cache Access DCA [Missing] |- Debugging Extension DE [Present] |- Debug Store & Precise Event Based Sampling DS, PEBS [Missing] |- CPL Qualified Debug Store DS-CPL [Missing] |- 64-Bit Debug Store DTES64 [Missing] |- Fast-String Operation Fast-Strings [Missing] |- Fused Multiply Add FMA|FMA4 [Missing] |- Hardware Lock Elision HLE [Missing] |- Long Mode 64 bits IA64|LM [Present]
Add -h
option followed by corefreq command to print the available option in CoreFreq.
$ ./corefreq-cli -h CoreFreq. Copyright (C) 2015-2017 CYRIL INGENIERIE usage: corefreq-cli [-option ] -t Show Top (default) -d Show Dashboard arguments: -c Monitor Counters -i Monitor Instructions -s Print System Information -M Print Memory Controller -m Print Topology -u Print CPUID -k Print Kernel -h Print out this message Exit status: 0 if OK, 1 if problems, >1 if serious trouble. Report bugs to labs[at]cyring.fr
Enable client traces counters by adding -c
option with corefreq.
$ ./corefreq-cli -c CPU Freq(MHz) Ratio Turbo C0(%) C1(%) C3(%) C6(%) C7(%) Min TMP:TS Max #00 0.00 ( 0.00) 0.00 0.00 100.00 0.00 0.00 0.00 100/100:0 /100 #01 0.00 ( 0.00) 0.00 0.00 100.00 0.00 0.00 0.00 100/100:0 /100 Averages: Turbo C0(%) C1(%) C3(%) C6(%) C7(%) TjMax: 0.00 0.00 100.00 0.00 0.00 0.00 100 C CPU Freq(MHz) Ratio Turbo C0(%) C1(%) C3(%) C6(%) C7(%) Min TMP:TS Max #00 0.00 ( 0.00) 0.00 0.00 100.00 0.00 0.00 0.00 100/100:0 /100 #01 0.00 ( 0.00) 0.00 0.00 100.00 0.00 0.00 0.00 100/100:0 /100 Averages: Turbo C0(%) C1(%) C3(%) C6(%) C7(%) TjMax: 0.00 0.00 100.00 0.00 0.00 0.00 100 C CPU Freq(MHz) Ratio Turbo C0(%) C1(%) C3(%) C6(%) C7(%) Min TMP:TS Max #00 0.00 ( 0.00) 0.00 0.00 100.00 0.00 0.00 0.00 100/100:0 /100 #01 0.00 ( 0.00) 0.00 0.00 100.00 0.00 0.00 0.00 100/100:0 /100 Averages: Turbo C0(%) C1(%) C3(%) C6(%) C7(%) TjMax: 0.00 0.00 100.00 0.00 0.00 0.00 100 C
Print CPU topology by adding -m
option with corefreq.
$ ./corefreq-cli -m CPU Apic Core Thread Caches (w)rite-Back (i)nclusive # ID ID ID L1-Inst Way L1-Data Way L2 Way L3 Way 00:BSP 0 0 0 32768 8 32768 8 262144 4 6291456 12 i 01:AP 1 1 0 32768 8 32768 8 262144 4 6291456 12 i
Traces the number of instructions per second / cycle by adding -i
option with corefreq.
$ ./corefreq-cli -i CPU IPS IPC CPI #00 0.000000/s 0.000000/c 0.000000/i #01 0.000000/s 0.000000/c 0.000000/i CPU IPS IPC CPI #00 0.000000/s 0.000000/c 0.000000/i #01 0.000000/s 0.000000/c 0.000000/i CPU IPS IPC CPI #00 0.000000/s 0.000000/c 0.000000/i #01 0.000000/s 0.000000/c 0.000000/i CPU IPS IPC CPI #00 0.000000/s 0.000000/c 0.000000/i #01 0.000000/s 0.000000/c 0.000000/i
Print CPU identification information by adding -u
option with corefreq.
$ ./corefreq-cli -u CPU #0 function EAX EBX ECX EDX |- 00000000:00000000 00000016 756e6547 6c65746e 49656e69 |- Largest Standard Function=00000016 |- 80000000:00000000 80000008 00000000 00000000 00000000 |- Largest Extended Function=80000008 |- 00000001:00000000 000506e3 00020800 def82203 178bfbff |- 00000002:00000000 76036301 00f0b5ff 00000000 00c30000 |- 00000003:00000000 00000000 00000000 00000000 00000000 |- 00000004:00000000 04000121 01c0003f 0000003f 00000000 |- 00000004:00000001 04000122 01c0003f 0000003f 00000000 |- 00000004:00000002 04000143 00c0003f 000003ff 00000000 |- 00000004:00000003 04000163 02c0003f 00001fff 00000006 |- 00000005:00000000 00000000 00000000 00000000 00000000 |- 00000006:00000000 00000000 00000000 00000000 00000000 |- 00000007:00000000 00000000 00842000 00000000 00000000 |- 00000009:00000000 00000000 00000000 00000000 00000000 |- 0000000a:00000000 00000000 00000000 00000000 00000000 |- 0000000b:00000000 00000000 00000001 00000100 00000000 |- 0000000d:00000000 00000007 00000440 00000440 00000000 |- 0000000d:00000001 00000000 000003c0 00000000 00000000 |- 0000000f:00000000 00000000 00000000 00000000 00000000 |- 0000000f:00000001 00000000 00000000 00000000 00000000 |- 00000010:00000000 00000000 00000000 00000000 00000000 |- 00000010:00000001 00000000 00000000 00000000 00000000 |- 00000014:00000000 00000000 00000000 00000000 00000000 |- 00000014:00000001 00000000 00000000 00000000 00000000 |- 00000015:00000000 00000000 00000000 00000000 00000000 |- 00000016:00000000 00000000 00000000 00000000 00000000 |- 80000001:00000000 00000000 00000000 00000121 28100800 |- 80000006:00000000 00000000 00000000 01006040 00000000 |- 80000007:00000000 00000000 00000000 00000000 00000100 |- 80000008:00000000 00003027 00000000 00000000 00000000 . .
Print Kernel informaton by adding -k
option with corefreq.
$ ./corefreq-cli -k Linux: |- Release [4.8.0-39-generic] |- Version [#42-Ubuntu SMP Mon Feb 20 11:47:27 UTC 2017] |- Machine [x86_64] Memory: |- Total RAM 2047752 KB |- Shared RAM 79204 KB |- Free RAM 85828 KB |- Buffer RAM 5200 KB |- Total High 0 KB |- Free High 0 KB
Is anyone still using this? Or not being maintained or used?
Anybody? Thanks, that would be great!
Hi all. I’m using Kernel Release: 4.12.4-1-ARCH obviously, on my ARCH install and Processor Typeis : Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
This really looks interesting and would love to get it to work, would someone perhaps spoon feed me a bit and give me a hand to see if I can get this to work?
(1/1) installing corefreq-git [########################################] 100%
Creating symlink /var/lib/dkms/corefreq-git/1.10/source ->
/usr/src/corefreq-git-1.10
Kernel preparation unnecessary for this kernel. Skipping…
Building module:
cleaning build area…
make -j4 KERNELRELEASE=4.12.4-1-ARCH -C /usr/lib/modules/4.12.4-1-ARCH/build M=/var/lib/dkms/corefreq-git/1.10/build…
cleaning build area…
Kernel cleanup unnecessary for this kernel. Skipping…
DKMS: build completed.
corefreqk.ko:
Running module version sanity check.
– Original module
– No original module exists within this kernel
– Installation
– Installing to /usr/lib/modules/4.12.4-1-ARCH/kernel/drivers/misc//
depmod…
DKMS: install completed.
modprobe or insmod the kernel module corefreqk.ko
before starting the daemon corefreqd
then run the client corefreq-cli
:: Running post-transaction hooks…
(1/2) Install DKMS modules
==> dkms install corefreq-git/1.10 -k 4.12.4-1-ARCH
So as per instructions ran:
Get this error:
sudo insmod ./corefreqk.ko
insmod: ERROR: could not load module ./corefreqk.ko: No such file or directory
Thanks.
Ok figured it out, all working now was just being a bit slow. Thanks for the article pretty neat!
Some macros and inline functions have been removed from linux/cpu.h for the kernel 4.10 preventing to compile the corefreq.c file.
Missing macros/functions are :
CPU_DOWN_FAILED
CPU_DOWN_PREPARE
register_hotcpu_notifier
unregister_hotcpu_notifier
I don’t know how I can go around this… Since these are rather essential values…
Hello Daniel,
I will check again but I’m rather surprise because as an Archlinux user, I’m compiling against the latest and standard kernel.
Meanwhile, as a quick workaround, in corefreqk.c you can comment the all part of code which deals with hot-plugin; the followings :
function CoreFreqK_hotplug
structure notifier_block
register_hotcpu_notifier in function CoreFreqK_init
unregister_hotcpu_notifier in function CoreFreqK_cleanup
You won’t miss a lot beside the ability to suspend/resume monitoring of a cpu dynamically disable/enable
You can also open an issue if bug is confirmed @ github.com/cyring/CoreFreq/issues
However please check that the hot-plugin kernel build directive is well defined in your distro.
CyrIng
Cyrlng,
Thank’s for the fast repy ! I doubled checked the content of /usr/src$ more linux-headers-4.10.1-041001/include/linux/cpu.h and found this :
#define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN)
However, some CPU_* macros are not defined in this file. Besides, it’s rather strange to have CPU_DOWN_FAILED_FROZEN referencing CPU_DOWN_FAILED which is not defined… This may be a bug…
I tried to complement to missing macros (from the values found in the 4.8.0 cpu.h), but I then banged on the “register_hotcpu_notifier” declaration/function not found. This all seems related to the HOTPLUG_CPU flag…
For the time being, I think I’ll disable the hot_plugin section in corefrek.c
Regards,
dc
Daniel,
Thanks for helping.
I have browsed the version 4.10 of the kernel source code and it looks like changes have been applied to the cpu hotplug.
I’m still trying to find module examples or documentation of the new hot-plug framework but so far I only found patches & mailing list.
To my understanding the switch statement (with the concerned macro definitions) has evolved to a callbacks model.
To be short, 4.10 claims modifications in CoreFreq.
If you want to go fast, I suggest you to comment those sections (not tested yet) or boot temporary a 4.9.x kernel version.
Cyrlng,
Thank’s for all your work ! I’ve been trying to reply several times, but my posts couldn’t be sent (hiccup of 2daygeek or my browser…). I was very busy for the last few days and didn’t have the time to try commenting the lines in corefreq. I’ll do it asap and will let you know; eventhough I know it’ll work 🙂
dc
Hello Daniel,
CoreFreq is now compatible with 4.10 (and also retrocompatible with previous kernel versions)
So you don’t need to comment lines of code.
Just build and enjoy.
CyrIng
Cyrlng,
Great, it’s working !!! I disabled the NMI whatchdog and I just need to reboot (some coredumps).
I like it a lot. This is a really fantastic tool. Congratulation for this work…
Looking at instruction counters… shouldn’t the IPS represent the IPC x freq ? I have values below 1 and I hardly believe my CPU is running 0.043484 instructions per second… 🙂
dc
I’m sending you the formula
IPS = Delta.INST / Delta.TSC
where:
Delta is the difference of two counter values sampled every second.
Delta.TSC TimeStamp Counter when invariant will compute the frequency in Hertz in the interval.
Delta.INST computes the number of retired instructions (read from the fixed performance counter #0)
Hello Daniel,
Last commit allows to build CoreFreq against kernel version 4.10 and 4.9.x. Using 4.10, you loose CPU hot-plug until next implementation.
https://uploads.disquscdn.com/images/16e1b18acbb426ed8afcd47f1045ae1bedb99ba632509f20336fa60a2f7dd170.png
Fyi, best answer found at https://pkgs.rpmfusion.org/cgit/nonfree/nvidia-kmod.git/plain/kernel_4.10.patch
CyrIng
Thanks for your article.
Before starting the driver you must disable NMI Watchdog: in your kernel boot loader (grub, syslinux) add the argument:
nmi_watchdog=0
Next reboot, you can now insmod corefreqk.ko
Secondly, don’t run CoreFreq in a VM (VirtualBox, vmware, kvm,…)
Third, the client corefreq-cli shoud now display values instead of zeros, and you see frequencies, turbo, idle states, temperatures in action.
Feel free to ask me if you need more help.
Regards
CyrIng
Thanks for your update, NMI Watchdog was disabled but I have tested in VirtualBOX VM. Will try with my primary system.
Your welcome.
When done, may you update your screenshots ?
I would like to check CoreFreq results against SkyLake specs.
Regards
CyrIng