intel / thermal_daemon

Thermal daemon for IA
GNU General Public License v2.0
539 stars 117 forks source link

thermald generates many udev-worker processes #399

Closed tm4ig closed 1 month ago

tm4ig commented 1 year ago

On my new laptop with intel core i7-1255U and archlinux when thermald 2.5.2 is launched systemd-udevd has 40 child processes udev-worker with overall memory size 100MB. If turn on debug log in systemd-udevd I see many thermal events

...Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: Processing device (SEQNUM=5279, ACTION=change) Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: sd-device: Created db file '/run/udev/data/+thermal:thermal_zone1' for '/devices/virtual/thermal/thermal_zone1' Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: Device processed (SEQNUM=5279, ACTION=change) Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: sd-device-monitor(worker): Passed 238 byte to netlink monitor. Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: Processing device (SEQNUM=5280, ACTION=change) Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: sd-device: Created db file '/run/udev/data/+thermal:thermal_zone1' for '/devices/virtual/thermal/thermal_zone1' Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: Device processed (SEQNUM=5280, ACTION=change) Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: sd-device-monitor(worker): Passed 238 byte to netlink monitor. Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: Processing device (SEQNUM=5281, ACTION=change) Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: sd-device: Created db file '/run/udev/data/+thermal:thermal_zone1' for '/devices/virtual/thermal/thermal_zone1' Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: Device processed (SEQNUM=5281, ACTION=change) Jun 21 22:18:34 sinx (udev-worker)[2743]: thermal_zone1: sd-device-monitor(worker): Passed 238 byte to netlink monitor... There is no this problem on old intel cpus and same system. I think that so many udev-workers and memory usage by thermald on new cpu it is bug.

Udev-worker's count dependents of cpu cores number so with more performance cpus number of udev-workers maybe even more

spandruvada commented 1 year ago

thermald doesn't launch any udev. This seems to be coming from Linux thermel framework for netlink messages which are added to kernel.

tm4ig commented 1 year ago

udev-workers run only if thermald has started so in my case thermald has something to do with

spandruvada commented 1 year ago

Probably caused by bool cthd_kobj_uevent::check_for_event() {}

Thermald has to listen for thermal events which are sent by firmware and Linux thermal subsystem and respond. This is just reading from one netlink socket periodically. On this system, there may be heartbeat event, sent periodically. Can you monitor what udev events you are getting?

Try to stub out and check.

tm4ig commented 1 year ago

what should I do?

spandruvada commented 1 year ago

Build Thermald by removing calls to kobj. remove_kobj.txt you can use "git apply" to apply above diff. The build instructions are in README.txt in the thermald github repo.

spandruvada commented 1 year ago

This is due to linux kernel to user communication is via kobject_uevent. These messages go through udev. Running thermald allowed hardware to send events. But those shouldn't be many. I really want to see all the messages udev is receiving. For that we need debug build.

tm4ig commented 1 year ago

After upgrade linux kernel and/or systemd and/or laptop firmware and/or thermald problem was solved.