uksm icon indicating copy to clipboard operation
uksm copied to clipboard

5.4.60 uksm doesn't save the memory for KVM images

Open hailumeng opened this issue 2 years ago • 6 comments

I have launched 4 same type of KVM images in Ubuntu 20.04 patched with 5.4.60 uksm. The memory saving is only 4%. Tested with other different KVM images, the saving is around 50%. I also find out the non-working KVM does use 5.15.38 kernel. Maybe I need Ubuntu 22.04 to host this KVM with uksm-5.15.patch? Any guidance? Thank you.

hailumeng avatar Jul 27 '22 15:07 hailumeng

You could disable memory randomize in newly kernel

echo 0 > /proc/sys/kernel/randomize_va_space

bhzhu203 avatar Jul 29 '22 07:07 bhzhu203

Thank you bhzhu203 for the advice here. Before I give it a try, do you have any other recommendations for tuning? The reason I’m asking is the guest VM I have uses 18G memory each. When testing with them, the saving is much less compared to the VM which only has 4 or 8G memory. I wonder if I need to tune uksm to work on big memory VM. Thoughts? Thank you!

hailumeng avatar Jul 29 '22 12:07 hailumeng

Thank you bhzhu203 for the advice here. Before I give it a try, do you have any other recommendations for tuning? The reason I’m asking is the guest VM I have uses 18G memory each. When testing with them, the saving is much less compared to the VM which only has 4 or 8G memory. I wonder if I need to tune uksm to work on big memory VM. Thoughts? Thank you!

You could try to use zram and save some memory of cache (compresion)

echo 3G >  /sys/block/zram0/disksize
mkswap  /dev/zram0
swapon --priority 100 /dev/zram0

cat /sys/block/zram0/comp_algorithm lzo [lzo-rle] lz4 lz4hc 842 zstd (lzo-rle better)

#then flush the cache quickly

cat /etc/sysctl.conf

vm.min_free_kbytes=162164 # 1% total memory in M vm.dirty_background_ratio=5 vm.dirty_ratio = 10 vm.dirty_expire_centisecs = 1500 vm.dirty_writeback_centisecs = 300 vm.vfs_cache_pressure=150 vm.swappiness=85

bhzhu203 avatar Aug 05 '22 08:08 bhzhu203

how about the randomize_va_space option now?

bhzhu203 avatar Aug 05 '22 08:08 bhzhu203

Thank you bhzhu203. randomize_va_space didn’t make much difference at all. I’ll try these setting you mentioned above. Thank you so much for the help!

On Fri, Aug 5, 2022 at 3:31 AM bhzhu203 @.***> wrote:

how about the randomize_va_space option now?

— Reply to this email directly, view it on GitHub https://github.com/dolohow/uksm/issues/82#issuecomment-1206188867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD4HJQ4RV3RGQDE4IZG7NELVXTGMRANCNFSM542BQ5NA . You are receiving this because you authored the thread.Message ID: @.***>

hailumeng avatar Aug 05 '22 12:08 hailumeng

I also wonder if there is any pages_to_scan setting like ksm I can tweak since the memory required for VM is around 20G. It’s a lot of pages to scan.

On Fri, Aug 5, 2022 at 7:21 AM Hailu Meng @.***> wrote:

Thank you bhzhu203. randomize_va_space didn’t make much difference at all. I’ll try these setting you mentioned above. Thank you so much for the help!

On Fri, Aug 5, 2022 at 3:31 AM bhzhu203 @.***> wrote:

how about the randomize_va_space option now?

— Reply to this email directly, view it on GitHub https://github.com/dolohow/uksm/issues/82#issuecomment-1206188867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD4HJQ4RV3RGQDE4IZG7NELVXTGMRANCNFSM542BQ5NA . You are receiving this because you authored the thread.Message ID: @.***>

hailumeng avatar Aug 05 '22 12:08 hailumeng