Bug 509428 - "System Activtity" monitor (Ctrl+Esc) shows negative memory usage
Summary: "System Activtity" monitor (Ctrl+Esc) shows negative memory usage
Status: RESOLVED UNMAINTAINED
Alias: None
Product: plasmashell
Classification: Plasma
Component: System Monitor widgets (other bugs)
Version First Reported In: master
Platform: Other Linux
: NOR minor
Target Milestone: 1.0
Assignee: Christoph Feck
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-12 17:51 UTC by Christoph Feck
Modified: 2025-10-10 14:14 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
x86-64 Linux ELF executable that demonstrates the issue. It opens an empty X11 window and waits for the close button. (1.64 KB, application/x-executable)
2025-09-12 17:51 UTC, Christoph Feck
Details
Output of /proc/PID/status (1.64 KB, text/plain)
2025-09-25 12:36 UTC, Christoph Feck
Details
Output of /proc/PID/smaps_rollup (698 bytes, text/plain)
2025-09-25 12:50 UTC, Christoph Feck
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Feck 2025-09-12 17:51:34 UTC
Created attachment 184915 [details]
x86-64 Linux ELF executable that demonstrates the issue. It opens an empty X11 window and waits for the close button.

Steps to reproduce:
- do NOT follow these steps if you never heard my name
- never start an untrusted executable you downloaded from the internet
- start the attached executable using the X11 session;  an X11 window should appear
- use Ctrl+Esc to show the "System Activity" window
- make sure the "Memory" column is enabled
- read the value in the "Memory" column for the started "x11minimal" executable

Expected result:
- shows "0 K" or more Memory usage

Actual result:
- shows "-4 K" Memory usage

Version information:
- Plasma master from yesterday
- openSUSE Tumbleweed from yesterday
Comment 1 Nate Graham 2025-09-17 22:59:44 UTC
Hmm, when I try this, it says "15 KiB" for the memory usage. I'm on Wayland though, using KDE Linux. Do you have to be on X11 to reproduce the issue?
Comment 2 Arjen Hiemstra 2025-09-25 12:14:33 UTC
So the memory calculations were changed a while back, so now what we do is read a "rough" value from `/proc/$PID/statm` and a "precise" value from `/proc/$PID/smaps_rollup`, with the latter updating on a much more reduced frequency (as its a CPU intensive operation to read that file). We then calculate the difference between precise and rough value and when we read a new value from `statm` we add the previously calculated difference to get at a more "precise" value. I assumed these numbers would always result in a positive number, but apparently you found a corner case where that's incorrect. Ensuring it's at least 0 should be fairly trivial.
Comment 3 Arjen Hiemstra 2025-09-25 12:23:26 UTC
.... except it already does that: https://invent.kde.org/plasma/libksysguard/-/blob/master/processcore/memoryinfo_p.h?ref_type=heads#L116

So there's more to this bug report than just that. Can you give me the output of `/proc/$PID/smaps_rollup` and `/proc/$PID/status` (with PID being the PID of x11minimal) when this happens? I can't reproduce myself.
Comment 4 Christoph Feck 2025-09-25 12:36:37 UTC
Created attachment 185248 [details]
Output of /proc/PID/status
Comment 5 Christoph Feck 2025-09-25 12:43:48 UTC
If it helps, here is the /proc/maps output:

00400000-00401000 r-xp 00000000 103:07 661979                            /PATH/x11minimal
7f4c4a5b3000-7f4c4a5b7000 r--p 00000000 00:00 0                          [vvar]
7f4c4a5b7000-7f4c4a5b9000 r-xp 00000000 00:00 0                          [vdso]
7ffd81469000-7ffd8148b000 rw-p 00000000 00:00 0                          [stack]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]

libksysguard6 at eef71de
Comment 6 Christoph Feck 2025-09-25 12:50:17 UTC
Created attachment 185253 [details]
Output of /proc/PID/smaps_rollup
Comment 7 Arjen Hiemstra 2025-09-25 13:27:45 UTC
Hmm, and `/proc/PID/statm`? Both of the other files look like what I also get here, so this is getting increasingly confusing. Maybe you can also show a screenshot with Proportional/Resident/Shared/Private memory usage columns active?
Comment 8 Christoph Feck 2025-10-10 14:14:28 UTC
I don't have all memory columns you mentioned, so I assume those come from the newer (QtQuick based) system monitor. I'm using ksysguard6, which is not maintained upstream.