public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH ksm-control-daemon] ksmtuned: fix large number processing
@ 2024-01-25 10:56 Stefan Lendl
       [not found] ` <c3d7bba9-73b0-46b0-ad72-94139afc0559@web.de>
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stefan Lendl @ 2024-01-25 10:56 UTC (permalink / raw)
  To: pve-devel

awk internally uses float for every calculation, printing a large float
with awk results in 1.233e+09 format which causes the script to fail afterwards.
Instead I am printing the float without decimals.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
---
 debian/patches/awk-printf.diff | 16 ++++++++++++++++
 debian/patches/series          |  1 +
 2 files changed, 17 insertions(+)
 create mode 100644 debian/patches/awk-printf.diff

diff --git a/debian/patches/awk-printf.diff b/debian/patches/awk-printf.diff
new file mode 100644
index 0000000..11a957f
--- /dev/null
+++ b/debian/patches/awk-printf.diff
@@ -0,0 +1,16 @@
+--- ksm-control-scripts/ksmtuned	2024-01-25 11:33:03.485039813 +0100
++++ ksm-control-scripts.new/ksmtuned	2024-01-25 11:37:40.544751316 +0100
+@@ -72,11 +72,11 @@
+     # calculate how much memory is committed to running qemu processes
+     local progname
+     progname=${1:-kvm}
+-    ps -C "$progname" -o vsz= | awk '{ sum += $1 }; END { print sum }'
++    ps -C "$progname" -o vsz= | awk '{ sum += $1 }; END { printf ("%.0f", sum) }'
+ }
+ 
+ free_memory () {
+-    awk '/^(MemFree|Buffers|Cached):/ {free += $2}; END {print free}' \
++    awk '/^(MemFree|Buffers|Cached):/ {free += $2}; END { printf ("%.0f", free) }' \
+                 /proc/meminfo
+ }
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 7aaec2c..63aba40 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@ init-script.diff
 ksmtuned.diff
 adjust-ksm-slepp.diff
 use-vsz-instead-of-rsz.diff
+awk-printf.diff
-- 
2.43.0





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-08 13:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 10:56 [pve-devel] [PATCH ksm-control-daemon] ksmtuned: fix large number processing Stefan Lendl
     [not found] ` <c3d7bba9-73b0-46b0-ad72-94139afc0559@web.de>
2024-02-29  7:52   ` Thomas Lamprecht
2024-04-08 12:04     ` Stefan Lendl
2024-04-08 12:22       ` Thomas Lamprecht
2024-04-08 13:02         ` Stefan Lendl
     [not found] ` <6104c230-7e2e-43ae-8598-6c458b979ae1@web.de>
2024-02-29 15:12   ` Stefan Lendl
2024-02-29 15:16   ` Stefan Lendl
     [not found] ` <813667cc-81b6-46db-b144-54ee4cc578f6@web.de>
2024-02-29 15:23   ` Stefan Lendl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal