Hello community, here is the log from the commit of package conky for openSUSE:Factory checked in at 2020-04-08 19:56:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/conky (Old) and /work/SRC/openSUSE:Factory/.conky.new.3248 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "conky" Wed Apr 8 19:56:34 2020 rev:29 rq:792354 version:1.11.5 Changes: -------- --- /work/SRC/openSUSE:Factory/conky/conky.changes 2020-02-25 16:06:29.256525800 +0100 +++ /work/SRC/openSUSE:Factory/.conky.new.3248/conky.changes 2020-04-08 19:56:35.197119140 +0200 @@ -1,0 +2,5 @@ +Fri Apr 3 09:24:53 UTC 2020 - Simon Lees <[email protected]> + +- Fix negative ram reporting #877 #878 #909 fix-negative-memory.patch + +------------------------------------------------------------------- @@ -504,2 +508,0 @@ - - New: ---- fix-negative-memory.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ conky.spec ++++++ --- /var/tmp/diff_new_pack.SyyqC6/_old 2020-04-08 19:56:36.125119818 +0200 +++ /var/tmp/diff_new_pack.SyyqC6/_new 2020-04-08 19:56:36.125119818 +0200 @@ -1,5 +1,5 @@ # -# spec file for package tempspec +# spec file for package conky # # Copyright (c) 2020 SUSE LLC # @@ -37,6 +37,7 @@ Source3: README.SUSE Patch1: conky-1.10.1-avoid-git.patch Patch2: conky.timestamp.patch +Patch3: fix-negative-memory.patch BuildRequires: cmake BuildRequires: docbook-xsl-stylesheets BuildRequires: docbook2x ++++++ fix-negative-memory.patch ++++++ commit 0d449029eaee689da88fcf1d0d572188f4e757d6 Author: Shark-Teeth <[email protected]> Date: Tue Aug 27 13:03:41 2019 -0400 Fix negative RAM usage (#878) This seems to be causing some issues with clobbering memory values, and since there is callback functionality already working, this seems unnecessary. * Make all calculations local to function I moved from making the assignments and calculations of certain memory values to doing the calculations on local variables and assigning them at the end of the function for update_meminfo(). This is to keep the info.memX variables from having 'intermediary' values that may give wrong values to other functions if the structure is read from while the function is currently executing. As a matter of keeping the variables consistent across function calls, I removed the zeroing out of certain info struct variables so that if they are read from, they'll still report a sane value. Since the only change to the value a direct assignment at the end of the function, they shouldn't need zeroing out in the first place. diff --git a/src/linux.cc b/src/linux.cc index 57760fac..c1e0634e 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -179,11 +179,18 @@ int update_meminfo(void) { /* unsigned int a; */ char buf[256]; - unsigned long long shmem = 0, sreclaimable = 0; - - info.mem = info.memwithbuffers = info.memmax = info.memdirty = info.swap = - info.swapfree = info.swapmax = info.bufmem = info.buffers = info.cached = - info.memfree = info.memeasyfree = 0; + /* With multi-threading, calculations that require + * multple steps to reach a final result can cause havok + * if the intermediary calculations are directly assigned to the + * information struct (they may be read by other functions in the meantime). + * These variables keep the calculations local to the function and finish off + * the function by assigning the results to the information struct */ + unsigned long long shmem = 0, sreclaimable = 0, curmem = 0, curbufmem = 0, + cureasyfree = 0; + + info.memmax = info.memdirty = info.swap = info.swapfree = info.swapmax = + info.memwithbuffers = info.buffers = info.cached = info.memfree = + info.memeasyfree = 0; if (!(meminfo_fp = open_file("/proc/meminfo", &reported))) { return 0; } @@ -211,8 +218,8 @@ int update_meminfo(void) { } } - info.mem = info.memwithbuffers = info.memmax - info.memfree; - info.memeasyfree = info.memfree; + curmem = info.memwithbuffers = info.memmax - info.memfree; + cureasyfree = info.memfree; info.swap = info.swapmax - info.swapfree; /* Reclaimable memory: does not include shared memory, which is part of cached @@ -220,17 +227,24 @@ int update_meminfo(void) { Note: when shared memory is swapped out, shmem decreases and swapfree decreases - we want this. */ - info.bufmem = (info.cached - shmem) + info.buffers + sreclaimable; + curbufmem = (info.cached - shmem) + info.buffers + sreclaimable; - /* Now (info.mem - info.bufmem) is the *really used* (aka unreclaimable) + /* Now ('info.mem' - 'info.bufmem') is the *really used* (aka unreclaimable) memory. When this value reaches the size of the physical RAM, and swap is full or non-present, OOM happens. Therefore this is the value users want to monitor, regarding their RAM. */ if (no_buffers.get(*state)) { - info.mem -= info.bufmem; - info.memeasyfree += info.bufmem; + curmem -= curbufmem; + cureasyfree += curbufmem; } + + /* Now that we know that every calculation is finished we can wrap up + * by assigning the values to the information structure */ + info.mem = curmem; + info.bufmem = curbufmem; + info.memeasyfree = cureasyfree; + fclose(meminfo_fp); return 0; } diff --git a/src/top.cc b/src/top.cc index d3c5a7ad..a80e3b7a 100644 --- a/src/top.cc +++ b/src/top.cc @@ -390,10 +390,6 @@ static void process_find_top(struct process **cpu, struct process **mem, } int update_top() { - // XXX: this was a separate callback. and it should be again, as soon as it's - // possible - update_meminfo(); - process_find_top(info.cpu, info.memu, info.time #ifdef BUILD_IOSTATS ,
