|
|
fecd69 |
diff -up ./proc/sysinfo.c.ori ./proc/sysinfo.c
|
|
|
fecd69 |
--- ./proc/sysinfo.c.ori 2021-02-09 11:11:25.000000000 +0100
|
|
|
fecd69 |
+++ ./proc/sysinfo.c 2022-07-29 14:08:42.093322509 +0200
|
|
|
fecd69 |
@@ -786,10 +786,8 @@ nextline:
|
|
|
fecd69 |
where such values will be dramatically distorted over those of the host. */
|
|
|
fecd69 |
if (kb_main_available > kb_main_total)
|
|
|
fecd69 |
kb_main_available = kb_main_free;
|
|
|
fecd69 |
- mem_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
|
|
|
fecd69 |
- if (mem_used < 0)
|
|
|
fecd69 |
- mem_used = kb_main_total - kb_main_free;
|
|
|
fecd69 |
- kb_main_used = (unsigned long)mem_used;
|
|
|
fecd69 |
+ mem_used = kb_main_total - kb_main_available;
|
|
|
fecd69 |
+ kb_main_used = mem_used < 0 ? 0 : (unsigned long) mem_used;
|
|
|
fecd69 |
|
|
|
fecd69 |
/* zero? might need fallback for 2.6.27 <= kernel
|
|
|
fecd69 |
if (!kb_main_available) {
|
|
|
fecd69 |
diff -up ./top/top.c.ori ./top/top.c
|
|
|
fecd69 |
--- ./top/top.c.ori 2021-02-09 11:11:25.000000000 +0100
|
|
|
fecd69 |
+++ ./top/top.c 2022-07-29 13:59:04.681966019 +0200
|
|
|
fecd69 |
@@ -6076,12 +6076,16 @@ numa_nope:
|
|
|
fecd69 |
char used[SMLBUFSIZ], util[SMLBUFSIZ], dual[MEDBUFSIZ];
|
|
|
fecd69 |
float pct_used, pct_misc, pct_swap;
|
|
|
fecd69 |
int ix, num_used, num_misc;
|
|
|
fecd69 |
+ unsigned long my_used;
|
|
|
fecd69 |
|
|
|
fecd69 |
- pct_used = (float)kb_main_used * (100.0 / (float)kb_main_total);
|
|
|
fecd69 |
+ // upstream kept old calculation of 'used' here for some reason
|
|
|
fecd69 |
+ // https://gitlab.com/procps-ng/procps/-/commit/047d16ccfda6638eda78f56b67def196a2002b6f
|
|
|
fecd69 |
+ my_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
|
|
|
fecd69 |
+ pct_used = (float)my_used * (100.0 / (float)kb_main_total);
|
|
|
fecd69 |
#ifdef MEMGRAPH_OLD
|
|
|
fecd69 |
pct_misc = (float)(kb_main_buffers + kb_main_cached) * (100.0 / (float)kb_main_total);
|
|
|
fecd69 |
#else
|
|
|
fecd69 |
- pct_misc = (float)(kb_main_total - kb_main_available - kb_main_used) * (100.0 / (float)kb_main_total);
|
|
|
fecd69 |
+ pct_misc = (float)(kb_main_total - kb_main_available - my_used) * (100.0 / (float)kb_main_total);
|
|
|
fecd69 |
#endif
|
|
|
fecd69 |
if (pct_used + pct_misc > 100.0 || pct_misc < 0) pct_misc = 0;
|
|
|
fecd69 |
pct_swap = kb_swap_total ? (float)kb_swap_used * (100.0 / (float)kb_swap_total) : 0;
|