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

[Debian 12 bookworm] Repeating spikes in temperatures samples #2416

Closed
f18m opened this issue May 15, 2024 · 3 comments
Closed

[Debian 12 bookworm] Repeating spikes in temperatures samples #2416

f18m opened this issue May 15, 2024 · 3 comments

Comments

@f18m
Copy link

f18m commented May 15, 2024

Summary

  • OS: Debian 12 Bookworm
  • Architecture: 64bit
  • Psutil version: 5.9.8
  • Python version: 3.11.2
  • Type: core

Description

I'm running a software that keeps track of CPU temperature over time using psutil.
The platform is a miniPC using Intel CPU N100.
I noticed that for most of the time the temperature readings are consistent over the 24hours. However almost every day there is a period that lasts 1-2 hours where the CPU temperatures show sudden temporary spikes from a value of about 35 celsius degrees up to 50-55 celsius degrees. Such spikes last less than 1sec.
More in details: I've been using the example code from here: https://github.com/giampaolo/psutil/blob/master/scripts/temperatures.py

with small modifications, just to print the timestamp, then print temp sample, sleep 1 sec and repeat.
Here's an example of a temperature spike:

20240515_20:41:59
acpitz
    acpitz               27.8 °C (high = 110.0 °C, critical = 110.0 °C)

coretemp
    Package id 0         37.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 0               32.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 1               32.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 2               32.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 3               32.0 °C (high = 105.0 °C, critical = 105.0 °C)

20240515_20:42:00
acpitz
    acpitz               27.8 °C (high = 110.0 °C, critical = 110.0 °C)

coretemp
    Package id 0         54.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 0               54.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 1               54.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 2               54.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 3               32.0 °C (high = 105.0 °C, critical = 105.0 °C)

20240515_20:42:01
acpitz
    acpitz               27.8 °C (high = 110.0 °C, critical = 110.0 °C)

coretemp
    Package id 0         37.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 0               32.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 1               32.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 2               32.0 °C (high = 105.0 °C, critical = 105.0 °C)
    Core 3               32.0 °C (high = 105.0 °C, critical = 105.0 °C)

As can be seen the 2nd sample, at the time 20:42:00 shows Package temp and Cores 0-3 temp up to 54 degrees while 1sec before the temp was 32degrees and 1sec later it's again 32degrees.
There is no particular load on the CPU at the time of the measurement.
It's hard to believe that a transient of +22 degrees can happen in <1sec.

Is perhaps the problem coming from the kernel module that provides temperature data?
How I do find out where is the source of temperature information used by psutil?

Here's an 'lsmod' that shows some (maybe useful) info:

$ lsmod | grep temp
x86_pkg_temp_thermal    20480  0
coretemp               20480  0

Thanks

@f18m f18m added the bug label May 15, 2024
@github-actions github-actions bot added the linux label May 15, 2024
@giampaolo
Copy link
Owner

You should try to see if sensors command has the same behavior (I suspect yes).

@f18m
Copy link
Author

f18m commented May 15, 2024

Thanks @giampaolo for very fast answer.
I have been running 'watch -n1 sensors' just now and indeed I see some "crazy" sample appearing every now and then.
I guess that sounds like a kernel(module) bug?

Would it make sense to build some 'moving average' filtering on psutil side to handle such buggy sensors?

@giampaolo
Copy link
Owner

Nope. We should always return what the kernel gives us.

To be honest, there is one exception in psutil: net_io_counters() and disk_io_counters(). On long running systems the kernel may wrap the returned numbers and restart from 0, in which case psutil will adjust them so they never go backwards:

psutil/psutil/__init__.py

Lines 2072 to 2075 in 3c518a3

If *nowrap* is True it detects and adjust the numbers which overflow
and wrap (restart from 0) and add "old value" to "new value" so that
the returned numbers will always be increasing or remain the same,
but never decrease.

Calculating a moving average is something different though.

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

2 participants