! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
CPU freq is incorrect when hyperthreading is disabled
Status:
RESOLVED: FIXED
Product:
Xfce4-cpufreq-plugin
Component:
General

Comments

Description 520dhh 2018-08-30 14:02:03 CEST
When SMT is disabled Intel CPU, the average and the min cpu frequencies are incorrect.
Comment 1 Andre Miranda editbugs 2018-09-05 14:26:03 CEST
What do you mean by incorrect? Is it stuck on the same value or is it different than cat /proc/cpuinfo | grep "MHz"?
Which governor are you using?

You can also compare the average results with watch -n1 "cat /proc/cpuinfo | grep 'MHz' | cut -d: -f2 | awk '{a+=\$1+0} END{print a/NR}'"
Comment 2 520dhh 2018-09-12 15:08:33 CEST
(In reply to Andre Miranda from comment #1)
> What do you mean by incorrect? Is it stuck on the same value or is it
> different than cat /proc/cpuinfo | grep "MHz"?
> Which governor are you using?
> 
> You can also compare the average results with watch -n1 "cat /proc/cpuinfo |
> grep 'MHz' | cut -d: -f2 | awk '{a+=\$1+0} END{print a/NR}'"

My laptop has 8 logical cores. When Hyperthreading is disabled, only 4 physical cores have frequencies. /proc/cpuinfo is correctly showing 4 cpu info. But apparently the plugin didn't get freq from /proc/cpuinfo. There are 4 disabled cores which have 0 freq. And they are being calculated for avg and min freq.
Comment 3 Andre Miranda editbugs 2018-09-13 03:18:37 CEST
You're right, /proc/cpuinfo is not the first place cpufreq-plugin looks for core count.
Please check the output of find /sys/devices/system/cpu -maxdepth 1 -name "cpu[0-9]*" when HT is disabled.
Sorry, but the two machines I have around are Core i5, no way to test that.
Comment 4 520dhh 2018-09-13 06:07:15 CEST
(In reply to Andre Miranda from comment #3)
> You're right, /proc/cpuinfo is not the first place cpufreq-plugin looks for
> core count.
> Please check the output of find /sys/devices/system/cpu -maxdepth 1 -name
> "cpu[0-9]*" when HT is disabled.
> Sorry, but the two machines I have around are Core i5, no way to test that.

That gives me 8 cpus when HT is disabled. 0-3 are online and 4-7 are offline.
Comment 5 Andre Miranda editbugs 2018-09-20 03:10:02 CEST
I was able to simulating this by toggle cpus with:
# echo 0 > /sys/devices/system/cpu/cpu1/online
# echo 0 > /sys/devices/system/cpu/cpu2/online
# echo 0 > /sys/devices/system/cpu/cpu3/online

This enhancement is present on this branch: https://git.xfce.org/users/andre/xfce4-cpufreq-plugin/
It would be awesome if you are able to test before I push to master.
Comment 6 520dhh 2018-09-20 05:30:48 CEST
Yep. I tested it using s-tui to stress my laptop. It's displaying the right avg freq. Problem solved. Thank you.
Although, it's a bit hard to tell from watch -n1 'cat /proc/cpuinfo | grep "MHz"' when idle. They are not quite the same. But generally it's good enough.
Comment 7 Git Bot editbugs 2018-09-21 15:21:43 CEST
Andre Miranda referenced this bugreport in commit 6c34eee3c07529529900230d32476ac840be11af

Check if each cpu is online (Bug #14641)

https://git.xfce.org/panel-plugins/xfce4-cpufreq-plugin/commit?id=6c34eee3c07529529900230d32476ac840be11af
Comment 8 Andre Miranda editbugs 2018-09-21 15:40:18 CEST
I think the following script should yield a result similar to cpufreq-plugin, since it reads from the same source:
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq | awk '{printf "%3.2f\n", $0/1000}' | jq -s add/length

I my case the results vary a lot, even if you run watch somewhat synchronized to cpufreq update interval, most of the readings will diverge.

Closing this bug, the fix will be available in 1.2.1.

Bug #14641

Reported by:
520dhh
Reported on: 2018-08-30
Last modified on: 2018-09-21

People

Assignee:
Harald Judt
CC List:
2 users

Version

Attachments

Additional information