From: Dor Laor <dlaor@redhat.com>
To: Gordan Bobic <gordan@bobich.net>
Cc: kvm@vger.kernel.org
Subject: Re: KSM For All Via LD_PRELOAD?
Date: Thu, 10 Jun 2010 10:33:13 +0300 [thread overview]
Message-ID: <4C109539.1070401@redhat.com> (raw)
In-Reply-To: <4C0F6D8A.5080305@bobich.net>
On 06/09/2010 01:31 PM, Gordan Bobic wrote:
> On 06/09/2010 09:56 AM, Paolo Bonzini wrote:
>>>> Or is this too crazy an idea?
>>>
>>> It should work. Note that the the malloced memory should be aligned in
>>> order to get better sharing.
>>
>> Within glibc malloc large blocks are mmaped, so they are automatically
>> aligned. Effective sharing of small blocks would take too much luck or
>> too much wasted memory, so probably madvising brk memory is not too
>> useful.
>>
>> Of course there are exceptions. Bitmaps are very much sharable, but not
>> big. And some programs have their own allocator, using mmap in all
>> likelihood and slicing the resulting block. Typically these will be
>> virtual machines for garbage collected languages (but also GCC for
>> example does this). They will store a lot of pointers in there too, so
>> in this case KSM would likely work a lot for little benefit.
>>
>> So if you really want to apply it to _all_ processes, it comes to mind
>> to wrap both mmap and malloc so that you can set a flag only for
>> mmap-within-malloc... It will take some experimentation and heuristics
>> to actually not degrade performance (and of course it will depend on the
>> workload), but it should work.
>
> Arguably, the way QEMU KVM does it for the VM's entire memory block
> doesn't seem to be distinguishing the types of memory allocation inside
> the VM, so simply covering all mmap()/brk() calls would probably do no
> worse in terms of performance. Or am I missing something?
There won't be drastic effect for qemu-kvm since the non guest ram areas
are minimal. I thought you were trying to trap mmap/brk/malloc for other
general applications regardless of virt.
>
> Gordan
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-06-10 7:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 18:43 KSM For All Via LD_PRELOAD? Gordan Bobic
2010-06-09 8:33 ` Dor Laor
2010-06-09 8:56 ` Paolo Bonzini
2010-06-09 10:31 ` Gordan Bobic
2010-06-10 7:33 ` Dor Laor [this message]
2010-06-10 9:03 ` Gordan Bobic
2010-06-10 7:44 ` Jes Sorensen
2010-06-10 9:09 ` Gordan Bobic
2010-06-10 11:27 ` Jes Sorensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C109539.1070401@redhat.com \
--to=dlaor@redhat.com \
--cc=gordan@bobich.net \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox