COW in userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear mm folks,

I have an issue, where it would be great to have a COW-backed virtual
memory area within an userspace process. I know there's the possibility
to have a file-backed MAP_SHARED vma, which is later duplicated with
MAP_PRIVATE, but that's not exactly what I'm looking for.

Say I have an anonymous page-aligned VMA a, with MAP_PRIVATE and
PROT_RW. Userspace happily writes to/reads from it. At some point in
time, I want to 'snapshot' that single VMA within the context of the
process and without the need to fork(). Say there's something like

  a = mmap(0, len, PROT_RW, MAP_ANON | MAP_POPULATE, -1, 0);
  [... fill a ...]

  b = mmdup(a, len, PROT_READ);

b shall be the new base pointer of a new VMA that is backed by COW
mechanisms. After mmdup, those regular COW mechanisms do the rest: both
VMAs (a and b) will fault on subsequent writes and duplicate the
previously shared physical mapping, pretty much what cow_fault or
shared_fault does.

Afaict, this, or at least something like this is currently not supported
by the kernel. Is that correct? If so, why? Generally spoken, is it a
bad idea?

I digged a bit into the mm code, and I think all the stuff that would be
required is already there, so I wonder what I'm missing.


This is some related work I found on that topic:

https://sfb876.tu-dortmund.de/PublicPublicationFiles/kotthaus_2016a.pdf

They implement mmapcopy(), which pretty much would fulfill my
requirements. However, I still wonder why the kernel doesn't support
something like that by default, so maybe some mm expert could shed light
on this.

Any suggestions welcome!

Thanks
  Ralf




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux