Summary: | cpu plugin causes hang/crash when starting plasma-ksystemstats daemon | ||
---|---|---|---|
Product: | [Frameworks and Libraries] ksystemstats | Reporter: | Jonathan L Hanmann <jhanmann> |
Component: | General | Assignee: | Plasma Bugs List <plasma-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | ahiemstra, nate |
Priority: | NOR | Keywords: | regression |
Version: | 6.1.90 | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/ksystemstats/-/commit/c5bc0067b31f6c2bdee127702c6cc4717c770808 | Version Fixed In: | 6.2.0 |
Sentry Crash Report: | |||
Attachments: |
Patch to ksystemstats/plugins/cpu/linuxcpuplugin.cpp
Improved Patch to ksystemstats/plugins/cpu/linuxcpuplugin.cpp /proc/cpuinfo for Rock-5b/RK3588 |
Description
Jonathan L Hanmann
2024-09-14 03:31:46 UTC
I have attached a patch to fix this problem. The ksystemstats runs ok with this patch now. The CPU count (on my system anyways) is off by one. It reflects cores 0-8 when it should be 0-7. Oddly the core 0 appears to be the invalid one. I am going to look into this further also and see if I can identify and fix this issue as well. For now this patch at least prevents the hang/timeout and enables ksystemstats and the System Monitor app to work ok. Created attachment 173659 [details]
Patch to ksystemstats/plugins/cpu/linuxcpuplugin.cpp
Fix for hang/timeout when loading ksystemstats cpu plugin on Rock-5b (RK3588).
Comment on attachment 173659 [details]
Patch to ksystemstats/plugins/cpu/linuxcpuplugin.cpp
diff --git a/plugins/cpu/linuxcpuplugin.cpp b/plugins/cpu/linuxcpuplugin.cpp
index 6c01e40..ba1b385 100644
--- a/plugins/cpu/linuxcpuplugin.cpp
+++ b/plugins/cpu/linuxcpuplugin.cpp
@@ -90,10 +90,17 @@ LinuxCpuPluginPrivate::LinuxCpuPluginPrivate(CpuPlugin *q)
info.frequency = value.toDouble();
} else if (field == "siblings") {
info.siblings = value.toInt();
- }
+ } else if (field == "Serial")
+ break;
}
- cpus.push_back(info);
+ if((info.id != -1) ||
+ (info.cpu != -1) ||
+ (info.core != -1) ||
+ (info.frequency != 0) ||
+ (info.siblings != -1)) {
+ cpus.push_back(info);
+ }
cpuCount = std::max(cpuCount, info.cpu);
}
Created attachment 173660 [details]
Improved Patch to ksystemstats/plugins/cpu/linuxcpuplugin.cpp
This fixes both the hang/timeout and the extraneous core 0 problem. The core 0 problem was caused by my prior patch. While I am not happy about the conditional on the cpus.push_back(info) I had to add it works. You will likely know a better means of addressing the issue it is addressing.
That issue is that the /proc/cpuinfo for the RK3588 includes a line for the Serial at the end of the cpu info. That is messing up your algorithm and it is being counted as an extra cpu core albeit with no real information. I added the detection of the "Serial" field with a break from the inner for loop and the conditional on the push_back.
There is now no hang and only 8 cores listed. I will attach my /proc/cpuinfo also so you may see the input file causing this difficulty.
Created attachment 173661 [details]
/proc/cpuinfo for Rock-5b/RK3588
This is the offending /proc/cpuinfo input file causing such difficulties for ksystemstats cpu plugin.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/88 A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/89 Git commit 478e766d19b333a7cc2316ed11e002928673ba2c by Arjen Hiemstra. Committed on 02/10/2024 at 11:45. Pushed by ahiemstra into branch 'Plasma/6.2'. plugins/cpu: Ignore invalid CPU info when reading /proc/cpuinfo On some systems, /proc/cpuinfo contains non-core related data. When that happens, we would end up creating an invalid CpuInfo object that would later on crash ksystemstats. Instead, ignore said CpuInfo object properly so we don't crash. Patch based on Jonathan L Hanmann's suggestion from the bug report. (cherry picked from commit c5bc0067b31f6c2bdee127702c6cc4717c770808) Co-authored-by: Arjen Hiemstra <ahiemstra@heimr.nl> M +10 -3 plugins/cpu/linuxcpuplugin.cpp https://invent.kde.org/plasma/ksystemstats/-/commit/478e766d19b333a7cc2316ed11e002928673ba2c Git commit c5bc0067b31f6c2bdee127702c6cc4717c770808 by Arjen Hiemstra. Committed on 30/09/2024 at 09:18. Pushed by ahiemstra into branch 'master'. plugins/cpu: Ignore invalid CPU info when reading /proc/cpuinfo On some systems, /proc/cpuinfo contains non-core related data. When that happens, we would end up creating an invalid CpuInfo object that would later on crash ksystemstats. Instead, ignore said CpuInfo object properly so we don't crash. Patch based on Jonathan L Hanmann's suggestion from the bug report. M +10 -3 plugins/cpu/linuxcpuplugin.cpp https://invent.kde.org/plasma/ksystemstats/-/commit/c5bc0067b31f6c2bdee127702c6cc4717c770808 |