[pve-devel] [PATCH ksm-control-daemon] ksmtuned: fix large number processing

Roland devzero at web.de
Wed Feb 28 23:47:51 CET 2024


hi,

any reason why this did not get a response ?  (i do not see rejection of
this  ,nor did it appear in
https://git.proxmox.com/?p=ksm-control-daemon.git;a=summary )

and, while we are at ksmtuned, i think it's is broken, especially when
run on ZFS based installations, as it's totally mis-calculating ram
ressources.

https://forum.proxmox.com/threads/ksm-is-needlessly-burning-cpu-because-of-using-vzs-and-ignoring-arcsize.142397/

regards
roland


Am 25.01.24 um 11:56 schrieb Stefan Lendl:
> 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 at 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



More information about the pve-devel mailing list