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