https://bugs.kde.org/show_bug.cgi?id=526595

            Bug ID: 526595
           Summary: changing Sensor.sensorId does not unsubscribe the
                    previous sensor
    Classification: Frameworks and Libraries
           Product: ksystemstats
      Version First 6.7.5
       Reported In:
          Platform: NixOS
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: General
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

Created attachment 196793
  --> https://bugs.kde.org/attachment.cgi?id=196793&action=edit
QML reproducer; run with "-- clear-id": sets sensorId to "" after 5 s

DESCRIPTION
Changing the sensorId of a Sensor (for example setting it to "") does not
unsubscribe the previous sensor, so it stays subscribed for the lifetime of the
process. On an NVIDIA laptop this keeps `nvidia-smi dmon` running and the dGPU
never runtime-suspends.

STEPS TO REPRODUCE
1. On a system with an NVIDIA GPU, make sure nothing else uses gpu/gpu0 sensors
(no nvidia-smi process running).
2. Run the attached libksysguard-stale-subscriptions.qml with `qml
libksysguard-stale-subscriptions.qml -- clear-id`. It creates a Sensor for
gpu/gpu0/usage and sets its sensorId to "" after 5 seconds.
3. Watch for the `nvidia-smi dmon` process started by ksystemstats.

OBSERVED RESULT
nvidia-smi dmon keeps running after sensorId is cleared. It stops only when the
qml process exits.

EXPECTED RESULT
The old sensor is unsubscribed when sensorId changes, so nvidia-smi dmon stops.

SOFTWARE/OS VERSIONS
Operating System: NixOS 26.11
KDE Plasma Version: 6.7.5
KDE Frameworks Version: 6.30.0
Qt Version: 6.11.2
Kernel Version: 7.2.8 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 260 w/ Radeon 780M Graphics
Memory: 24 GiB of RAM (22.8 GiB usable)
Graphics Processor 1: AMD Radeon 780M Graphics
Graphics Processor 2: NVIDIA GeForce RTX 5050 Laptop GPU
libksysguard / ksystemstats: 6.7.5
NVIDIA driver: 615.71.09 (open kernel module), PRIME offload with runtime D3
power management

ADDITIONAL INFORMATION
Filed under ksystemstats because I could not find a libksysguard product.

Sensor::setSensorId() in sensors/Sensor.cpp subscribes to the new id but never
unsubscribes from the old one. Only disabling the Sensor or destroying it
unsubscribes. Same code on master.

QML code that stops using a sensor by clearing or changing sensorId leaks the
subscription for the lifetime of the process. I found this through the SysPeek
plasmoid, which scans gpu/gpu0..gpu8 this way at startup and kept the NVIDIA
dGPU awake (nvidia-smi running, no D3cold, about 7 W extra on battery).
Related: bug 497024.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to