Re: [PATCH V3] KSM: allow dedup all tasks memory

From: Oleksandr Natalenko
Date: Tue Nov 13 2018 - 06:06:12 EST


Hi.

ksm by default working only on memory that added by
madvise().

And only way get that work on other applications:
* Use LD_PRELOAD and libraries
* Patch kernel

Lets use kernel task list and add logic to import VMAs from tasks.

That behaviour controlled by new attributes:
* mode:
I try mimic hugepages attribute, so mode have two states:
* madvise - old default behaviour
* always [new] - allow ksm to get tasks vma and
try working on that.
* seeker_sleep_millisecs:
Add pauses between imports tasks VMA

For rate limiting proporses and tasklist locking time,
ksm seeker thread only import VMAs from one task per loop.

Some numbers from different not madvised workloads.
Formulas:
Percentage ratio = (pages_sharing - pages_shared)/pages_unshared
Memory saved = (pages_sharing - pages_shared)*4/1024 MiB
Memory used = free -h

* Name: My working laptop
Description: Many different chrome/electron apps + KDE
Ratio: 5%
Saved: ~100 MiB
Used: ~2000 MiB

* Name: K8s test VM
Description: Some small random running docker images
Ratio: 40%
Saved: ~160 MiB
Used: ~920 MiB

* Name: Ceph test VM
Description: Ceph Mon/OSD, some containers
Ratio: 20%
Saved: ~60 MiB
Used: ~600 MiB

* Name: BareMetal K8s backend server
Description: Different server apps in containers C, Java, GO & etc
Ratio: 72%
Saved: ~5800 MiB
Used: ~35.7 GiB

* Name: BareMetal K8s processing server
Description: Many instance of one CPU intensive application
Ratio: 55%
Saved: ~2600 MiB
Used: ~28.0 GiB

* Name: BareMetal Ceph node
Description: Only OSD storage daemons running
Raio: 2%
Saved: ~190 MiB
Used: ~11.7 GiB

Out of curiosity, have you compared these results with UKSM [1]?

Thanks.

--
Oleksandr Natalenko (post-factum)

[1] https://github.com/dolohow/uksm