Re: KSM For All Via LD_PRELOAD?

2010-06-10 Thread Dor Laor
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

Re: KSM For All Via LD_PRELOAD?

2010-06-10 Thread Jes Sorensen
On 06/08/10 20:43, Gordan Bobic wrote: Is this plausible? I'm trying to work out if it's even worth considering this approach to enable all memory used by in a system to be open to KSM page merging, rather than only memory used by specific programs aware of it (e.g. kvm/qemu). Something

Re: KSM For All Via LD_PRELOAD?

2010-06-10 Thread Gordan Bobic
On 06/10/2010 08:33 AM, Dor Laor wrote: 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

Re: KSM For All Via LD_PRELOAD?

2010-06-10 Thread Gordan Bobic
On 06/10/2010 08:44 AM, Jes Sorensen wrote: On 06/08/10 20:43, Gordan Bobic wrote: Is this plausible? I'm trying to work out if it's even worth considering this approach to enable all memory used by in a system to be open to KSM page merging, rather than only memory used by specific programs

Re: KSM For All Via LD_PRELOAD?

2010-06-10 Thread Jes Sorensen
On 06/10/10 11:09, Gordan Bobic wrote: On 06/10/2010 08:44 AM, Jes Sorensen wrote: Not sure if it is worth it, but you might want to look at ElectricFence which does malloc wrapping in a somewhat similar way. It might save you some code :) I'll look into it, but I don't see this requiring

Re: KSM For All Via LD_PRELOAD?

2010-06-09 Thread Dor Laor
On 06/08/2010 09:43 PM, Gordan Bobic wrote: Is this plausible? I'm trying to work out if it's even worth considering this approach to enable all memory used by in a system to be open to KSM page merging, rather than only memory used by specific programs aware of it (e.g. kvm/qemu). Something

Re: KSM For All Via LD_PRELOAD?

2010-06-09 Thread Paolo Bonzini
On 06/09/2010 10:33 AM, Dor Laor wrote: What I'm thinking about is somehow intercepting malloc() and wrapping it so that all malloc()-ed memory gets madvise()-d as well. You can also operate at a lower level and intercept mmap and brk, not malloc. (But see below). Or is this too crazy an

Re: KSM For All Via LD_PRELOAD?

2010-06-09 Thread Gordan Bobic
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

KSM For All Via LD_PRELOAD?

2010-06-08 Thread Gordan Bobic
Is this plausible? I'm trying to work out if it's even worth considering this approach to enable all memory used by in a system to be open to KSM page merging, rather than only memory used by specific programs aware of it (e.g. kvm/qemu). Something like this would address the fact that