[pve-devel] [PATCH ksm-control-daemon] ksmtuned: fix large number processing
Stefan Lendl
s.lendl at proxmox.com
Thu Feb 29 16:12:37 CET 2024
Roland <devzero at web.de> writes:
> oh, and shouldn't we also add that to total and free_memory calculation,
> even chances are less that the limit is hit there ?
>
> total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo`
>
> free_memory () {
> awk '/^(MemFree|Buffers|Cached):/ {free += $2}; END {print free}' \
> /proc/meminfo
> }
>
> Am 25.01.24 um 11:56 schrieb Stefan Lendl:
>> 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
>> + }
>> +
Hi Roland, as you can see in the patch, I am also adding this to the
free_memory function.
The patches are applied during the build process, hence the actual
source file still looks unchanged if you're looking at it in the repo.
If you install the package, the updated files will be placed at
/usr/sbin/ksmtuned where you can inspect the result.
More information about the pve-devel
mailing list