linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Copy-on-write with vmalloc
@ 2018-05-07 22:25 Eric Wheeler
  2018-05-14 15:34 ` Christopher Lameter
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wheeler @ 2018-05-07 22:25 UTC (permalink / raw)
  To: linux-mm

Hello all,

I would like to clone a virtual address space so that the address spaces 
share physical pages until a write happens, at which point it would copy 
to a new physical page.  I've looked around and haven't found any 
documentation. Certainly fork() already does this, but is there already 
simple way to do it with a virtual address space?

That is, does anything already implement the hypothetical vmalloc_clone 
in this example (4k pages):

	v = vmalloc(1024*1024);

	v[0] = 1;
	v[4096] = 2;

	v_copy = vmalloc_clone(v);

	v_copy[0] = 3;     /* copy-on-write */

And then the following expressions would still be true:

	/* different pages */
	v[0] == 1;
	v_copy[0] == 3; 

	/* shared page */
	v[4096] == 2;
	v_copy[4096] == 2; 

Thank you for your help!

--
Eric Wheeler

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Copy-on-write with vmalloc
  2018-05-07 22:25 Copy-on-write with vmalloc Eric Wheeler
@ 2018-05-14 15:34 ` Christopher Lameter
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Lameter @ 2018-05-14 15:34 UTC (permalink / raw)
  To: Eric Wheeler; +Cc: linux-mm

On Mon, 7 May 2018, Eric Wheeler wrote:

> I would like to clone a virtual address space so that the address spaces
> share physical pages until a write happens, at which point it would copy
> to a new physical page.  I've looked around and haven't found any
> documentation. Certainly fork() already does this, but is there already
> simple way to do it with a virtual address space?

The clone() syscall does it (since it is the underlying basis for fork).

The same effect can also be had by using mmap with
MAP_PRIVATE on a shared memory segment.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-14 15:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07 22:25 Copy-on-write with vmalloc Eric Wheeler
2018-05-14 15:34 ` Christopher Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox