Re: [PATCH v2] ksm: allow dedup all tasks memory
From: Timofey Titovets
Date: Mon Nov 12 2018 - 11:16:54 EST
ÐÐ, 12 ÐÐÑÐ. 2018 Ð. Ð 6:58, Matthew Wilcox <willy@xxxxxxxxxxxxx>:
>
> On Mon, Nov 12, 2018 at 12:26:10AM +0300, Timofey Titovets wrote:
> > ksm by default working only on memory that added by
> > madvice().
> >
> > And only way get that work on other applications:
> > - Use LD_PRELOAD and libraries
> > - Patch kernel
> >
> > Lets use kernel task list in ksm_scan_thread and add logic to allow ksm
> > import VMA from tasks.
> > That behaviour controlled by new attribute: mode
> > I try mimic hugepages attribute, so mode have two states:
> > - normal - old default behaviour
> > - always [new] - allow ksm to get tasks vma and try working on that.
> >
> > To reduce CPU load & tasklist locking time,
> > ksm try import VMAs from one task per loop.
> >
> > So add new attribute "mode"
> > Two passible values:
> > - normal [default] - ksm use only madvice
> > - always [new] - ksm will search vma over all processes memory and
> > add it to the dedup list
>
> Do you have any numbers for how much difference this change makes with
> various different workloads?
Yep, i got some non KVM numbers,
Formulas:
Percentage - (pages_sharing - pages_shared)/pages_unshared
Memory saved - (pages_sharing - pages_shared)*4/1024 MiB
- My working laptop: 5% - ~100 MiB saved ~2GiB used
Many different chrome based apps + KDE
- K8s test VM: 40% - ~160 MiB saved ~920MiB used
With some small running docker images
- Ceph test VM: 20% - ~60MiB saved ~600MiB used
With ceph mon, osd.
Develop cluster servers:
- K8s server backend: 72%, ~5800 MiB saved ~35.7 GiB used
(With backend apps: C, java, go & etc server apps)
- K8s server processing: 55%, ~2600 MiB saved ~28 GiB used
(90% of load many instance of one CPU intensive application)
- Ceph node: 2%, ~190 MiB saved ~11.7 GiB used
(OSD only)
So numbers, as always depends on the load.
Thanks!
- - -
P.S.
On recent kernels (4.19) i see BUG_ON message, that ksmd scheduled
while in critical section/atomic context,
not sure how to properly fix that.
(If i understood correctly, i can use preempt_disable(); but that
looks more like hack, not a fix).
Any feedback are welcome.