[RESPONDED] CPU monitoring application inspired by ThrottleStop

Switching from Windows to Linux, one thing I missed dearly was ThrottleStop. Its a handy tool to get a look at what the CPU is doing. I also found it helpful for troubleshooting all kinds of performance and power related issues.

So I created a terminal application that monitors CPU quantities like frequency, load, temperature, voltage and power draw. Using the ectool it reads the fan speed from the embedded controller. The monitoring application can be found here

I’m curious how well the app works with the P and E cores of 12th Gen CPUs. So far I only tested it with Pop!_OS 22.04 and an i7-1165G7. Suggestions or bugreports are appreciated.

3 Likes

Nice!

Doesn’t appear to work for long on my i7-1260P on Linux Mint 21.1 though:

$ sudo ./cpumon
Error reading CPU model name from /proc/cpuinfo
Error reading CPU model name from /proc/cpuinfo
Error reading CPU model name from /proc/cpuinfo
Error reading CPU model name from /proc/cpuinfo
Model: i7-1260P

		i7-1260P

       f/GHz 	C0%   Temp/°C	U/V
-------------------------------------
Core 0 	1.2	4	32	0.68
Core 1 	2.5	0	32	0.81
Core 2 	2.9	5	38	0.69
Core 3 	2.5	0	38	0.80
Core 4 	1.2	5	37	0.80
Core 5 	2.5	0	37	0.80
Core 6 	1.0	5	34	0.69
Core 7 	2.6	0	34	0.80
Core 8 	2.1	2	34	0.80
Core 9 	0.0	1	34	0.80
Core 10 	0.0	148	34	0.80
Core 11 	0.0	148	34	0.80
Core 12 	0.0	99	34	0.80
Core 13 	0.0	149	34	0.80
Core 14 	0.0	100	34	0.80
Core 15 	0.0	100	34	0.79

CPU	0.0	2	34	0.78	current avg

GPU	300 MHz		23.51 W

		Pkg Power = 1384.45 W
##############################################
Rest of Pkg: 672.33 W  Cores: 688.61 W  GPU: 23.51 W

Power System = 0.00 W
Fan speed 0 % (0 RPM)


		i7-1260P

Floating point exception
$

It can’t read the fan speed and the power is obviously wrong. Although it could be my fan isn’t running right now.

@Fraoch what does head -n5 /proc/cpuinfo return for you?

For me it’s

head -n5 /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 154
model name      : 12th Gen Intel(R) Core(TM) i5-1240P
head -n5 /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 154
model name	: 12th Gen Intel(R) Core(TM) i7-1260P

If the read from the embedded controller fails, there should be an error message.

I made further changes. The app should now work better with arbitrary core counts.

Thank you!

Initial cpuinfo errors are gone, power reading is a little better but still way off and it still exits with a floating point exception:

$ sudo ./cpumon
Model: i7-1260P

		i7-1260P

       f/GHz 	C0%   Temp/°C	U/V
-------------------------------------
Core 0 	1.7	2	30	0.79
Core 1 	2.5	0	30	0.79
Core 2 	1.3	3	27	0.79
Core 3 	2.5	0	27	0.79
Core 4 	3.2	2	35	0.79
Core 5 	2.5	0	35	0.79
Core 6 	1.1	2	31	0.81
Core 7 	2.5	0	31	0.82
Core 8 	2.5	0	29	0.82
Core 9 	0.9	0	29	0.82
Core 10 	2.5	147	29	0.82
Core 11 	2.5	147	29	0.82
Core 12 	2.5	148	29	0.83
Core 13 	2.5	148	29	0.85
Core 14 	2.5	100	29	0.85
Core 15 	1.3	100	29	0.85

CPU	2.2	0	29	0.82	current avg

GPU	300 MHz		2.29 W

		Pkg Power = 490.09 W
##############################################
Rest of Pkg: 222.85 W  Cores: 264.95 W  GPU: 2.29 W

Power System = 0.00 W
Fan speed 0 % (0 RPM)


		i7-1260P

Floating point exception
$

Getting an error when running on Fedora 37 with i7-1165G7. When running as normal user I get a segfault which I narrowed down to the gpu() function (I had to change /sys/class/drm/card0/gt_cur_freq_mhz to /sys/class/drm/card1/gt_cur_freq_mhz). When running as root I get a segfault “Error opening file” as well but I haven’t narrowed that down yet.

Figured it out. The issue is because I don’t have a battery (I’m using a standalone mainboard) so the file “/sys/class/power_supply/BAT1/voltage_now” doesn’t exist. I removed that part of the code and now it works!

1 Like

CPU load reading should work now with double digit core numbers.

Thats odd. The app calculates the power after reading from the energy counters at every second:
/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj = package
/sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0/energy_uj = cores
/sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:1/energy_uj = uncore = gpu

With 490 W your µJ counters should tick upwards with 8 to 9 digits at a time:
490 W * 1 s = 490 J = 490,000,000 µJ

Could you confirm this, e.g. by running the following command and counting the highlighted digits:
watch -d -n 1 sudo cat /sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj

I cannot reproduce the floating point exception. I read online that this exception can happen after dividing by zero. I went through the code and added several checks that should prevent division by zero.

1 Like

It’s hard to interpret what I’m seeing. I slowed it down to 3 seconds so I could count the changed digits, I think it is 8 to 9 digits at a time.

Doesn’t matter I guess, because after a few iterations, the script works perfectly now! :grinning:

		i7-1260P

       f/GHz 	C0%   Temp/°C	U/V
-------------------------------------
Core 0 	2.5	1	26	0.76
Core 1 	2.5	0	26	0.76
Core 2 	0.8	2	24	0.76
Core 3 	2.5	0	24	0.76
Core 4 	0.8	4	26	0.76
Core 5 	2.5	0	26	0.77
Core 6 	2.5	0	26	0.76
Core 7 	2.5	0	26	0.77
Core 8 	2.5	2	26	0.76
Core 9 	2.5	1	26	0.78
Core 10 	2.5	0	26	0.77
Core 11 	0.5	0	26	0.78
Core 12 	2.5	1	26	0.78
Core 13 	2.5	0	26	0.78
Core 14 	2.5	0	26	0.78
Core 15 	2.5	0	26	0.78

CPU	2.2	1	25	0.77	current avg

GPU	300 MHz		0.01 W

		Pkg Power = 1.03 W
###############################################
Rest of Pkg: 0.71 W  Cores: 0.30 W  GPU: 0.01 W

Battery power draw = 5.50 W (Discharging)
Fan speed 0 % (0 RPM)

Power readings look reasonable and no floating point exception.

Thank you!

Well thats nice. I’m surprised about how low your package power is. My i7-1165G7 is usually between 1 W and 2 W. From reading and watching several Laptop reviews, I got the impression that idle power draw got worse with 12th Gen CPUs. Maybe its not bad after all.

1 Like

Just forked this, nice project!

2 Likes