Skip to content

cpu: priority matching for cpu temp#1930

Open
fxzzi wants to merge 1 commit intoflightlessmango:masterfrom
fxzzi:priority-cpu-temp
Open

cpu: priority matching for cpu temp#1930
fxzzi wants to merge 1 commit intoflightlessmango:masterfrom
fxzzi:priority-cpu-temp

Conversation

@fxzzi
Copy link
Copy Markdown

@fxzzi fxzzi commented Jan 2, 2026

before, mangohud would loop through hwmon's in order, and use the first one it found that had a valid temperature sensor that we were looking for.

however, in some cases, the hwmon for a worse sensor can be read first, and therefore used, over a more accurate cpu temp sensor. On my system:

$ for n in /sys/class/hwmon/hwmon*/name; do echo "$n: $(cat "$n")"; done
/sys/class/hwmon/hwmon0/name: nvme
/sys/class/hwmon/hwmon1/name: nvme
/sys/class/hwmon/hwmon2/name: nct6798
/sys/class/hwmon/hwmon3/name: k10temp
/sys/class/hwmon/hwmon4/name: zenergy
/sys/class/hwmon/hwmon5/name: asusec
/sys/class/hwmon/hwmon6/name: asus

the nct temp sensor would be picked first, and this sensor has very bad accuracy to my real temperature, I've seen it showing upwards of 10C lower than the CPU real temperature, better reported by k10temp.

so, implement a priority system when looping through hwmon.

@fxzzi fxzzi force-pushed the priority-cpu-temp branch from a722b31 to 8c8d65b Compare January 2, 2026 03:01
Copy link
Copy Markdown
Contributor

@soerengrunewald soerengrunewald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, in fact it should work even better than the original solution. Since the current implementation does not always check if find_input is actually successful, while this does. So we can avoid the situation where we think we have found a valid sensor, but actually have not, therefore 👍 from me.

Comment thread src/cpu.cpp Outdated
Comment thread src/cpu.cpp Outdated
@fxzzi fxzzi force-pushed the priority-cpu-temp branch 2 times, most recently from e38ae79 to f2cf88a Compare January 9, 2026 13:16
@fxzzi
Copy link
Copy Markdown
Author

fxzzi commented Jan 9, 2026

rebased on top of main. Commit d24ddd1 conflicted but I think I got it working again

Copy link
Copy Markdown
Contributor

@soerengrunewald soerengrunewald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After actually trying the code, I notice some issues that need to be changed first.

Comment thread src/cpu.cpp Outdated
Comment thread src/cpu.cpp Outdated
Comment thread src/cpu.cpp Outdated
@fxzzi fxzzi force-pushed the priority-cpu-temp branch from f2cf88a to 89351b7 Compare May 1, 2026 17:00
@fxzzi fxzzi force-pushed the priority-cpu-temp branch from 89351b7 to 971477f Compare May 1, 2026 17:02
@fxzzi
Copy link
Copy Markdown
Author

fxzzi commented May 1, 2026

thanks again for the review and recommendations. I have now implemented those changes, as well as rebased on the latest master.

I kept the empty check since it shouldn't hurt.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants