Out of curiosity, is the end result very different from KSM? (as in
Kernel SamePage Merging)

While I'm no expert with this, KSM scans for memory areas selected in
userspace via madvise (madvise(addr, size, MADV_MERGEABLE)) then
deduplicate it in a similar fashion and set the page as COW (it can also
rerun the deduplication several times AFAIR, so if more identical pages
are found overtime [that have been madvised] those would be dedup'd too)


Guillaume

On 05/03/2013 12:57 AM, Thinker K.F. Li wrote:
> In bug 850175 and previous discussion at this list, we learnt memory
> duplications eating out devices memory in some cases.  Ting-Yuan had
> mentioned about KSM that can merge pages with same content to avoid
> duplication.  But, it takes CPU times and is not reliable while it can
> not merge pages in time/immediately during memory peaks.  So, to
> trigger it for OOM can not solve our issues.
> 
> After some discussions, Ting-Yuan is trying to implement a COW
> mechanism at userspace for sharing pages of source and target memory
> blocks passed to memcpy.  He expect to use a memdup() function to
> replace all malloc() & memcpy() paired function calls.  So, we do some
> tricky magic to make COW applied.  (I believe he will explain it
> later.)
> 
> Last few days, I am working on a kernel module to implement COW; call
> it memcow.  memcow provides a function that user space processes can
> map a block of annonymous memory block to another annonymous memory
> block, so they are sharing the same set of pages but COW; page aligned
> of course.  In another word, you can use memcow to map pages of A
> block to the address range of B block, A and B are allocated through
> malloc(), instead of calling memcpy.  It saves a lot of memory,
> especially for the cases like bug 850175.
> 
> So, what do you think?
> 
>  - https://bitbucket.org/thinker/memcow
> _______________________________________________
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to