linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH V1 0/6] mm: add a new option MREMAP_DUP to mmrep syscall
@ 2013-05-09  9:50 wenchaolinux
  2013-05-09  9:50 ` [RFC PATCH V1 1/6] mm: add parameter remove_old in move_huge_pmd() wenchaolinux
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: wenchaolinux @ 2013-05-09  9:50 UTC (permalink / raw)
  To: linux-mm
  Cc: akpm, mgorman, hughd, walken, viro, kirill.shutemov,
	xiaoguangrong, anthony, stefanha, Wenchao Xia

From: Wenchao Xia <wenchaolinux@gmail.com>

  This serial try to enable mremap syscall to cow some private memory region,
just like what fork() did. As a result, user space application would got a
mirror of those region, and it can be used as a snapshot for further processing.

This patch is based on the commit 
a12183c62717ac4579319189a00f5883a18dff08 pulled from upstream (linux 3.9) on
2013-04-04, but I hope to sent it first to see if some case I missed to handle
correctly, will try rebase to latest upstream code in next version.

simple test code:

#define _GNU_SOURCE
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

int main(void)
{
    int len = 4096 * 2 ;
    void *old_addr = malloc(len);
    old_addr = ((unsigned long)(old_addr + 4096) & (~0x3FF));
    printf("mapping addr %p with len %d.\n", old_addr, len);
    char *oldc = old_addr;
    oldc[0] = 0;
    oldc[1] = 1;
    oldc[2] = 2;
    oldc[3] = 3;
    void *new_addr;
    unsigned long new_addr_l;
    new_addr = mremap(old_addr, len, 0, 4);
    printf("result new addr %lx %p.\n", new_addr_l, new_addr);
    char *newc = new_addr;
    printf("old value is 0x%lx.\n", *((unsigned long *)oldc));
    printf("new value is 0x%lx.\n", *((unsigned long *)newc));
    newc[0] = 6;
    printf("old value is 0x%lx.\n", *((unsigned long *)oldc));
    printf("new value is 0x%lx.\n", *((unsigned long *)newc));
    oldc[0] = 9;
    printf("old value is 0x%lx.\n", *((unsigned long *)oldc));
    printf("new value is 0x%lx.\n", *((unsigned long *)newc));
    assert(0 == munmap(new_addr, len));

}

Wenchao Xia (6):
  mm: add parameter remove_old in move_huge_pmd()
  mm : allow copy between different addresses for copy_one_pte()
  mm : export rss vec helper functions
  mm : export is_cow_mapping()
  mm : add parameter remove_old in move_page_tables
  mm : add new option MREMAP_DUP to mremap() syscall

 fs/exec.c                 |    2 +-
 include/linux/huge_mm.h   |    2 +-
 include/linux/mm.h        |    9 ++-
 include/uapi/linux/mman.h |    1 +
 mm/huge_memory.c          |    6 +-
 mm/memory.c               |   33 ++++----
 mm/mremap.c               |  200 +++++++++++++++++++++++++++++++++++++++++++--
 7 files changed, 224 insertions(+), 29 deletions(-)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2014-01-06  7:42 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-09  9:50 [RFC PATCH V1 0/6] mm: add a new option MREMAP_DUP to mmrep syscall wenchaolinux
2013-05-09  9:50 ` [RFC PATCH V1 1/6] mm: add parameter remove_old in move_huge_pmd() wenchaolinux
2013-05-09  9:50 ` [RFC PATCH V1 2/6] mm : allow copy between different addresses for copy_one_pte() wenchaolinux
2013-05-09  9:50 ` [RFC PATCH V1 3/6] mm : export rss vec helper functions wenchaolinux
2013-05-09  9:50 ` [RFC PATCH V1 4/6] mm : export is_cow_mapping() wenchaolinux
2013-05-09  9:50 ` [RFC PATCH V1 5/6] mm : add parameter remove_old in move_page_tables wenchaolinux
2013-05-09  9:50 ` [RFC PATCH V1 6/6] mm : add new option MREMAP_DUP to mremap() syscall wenchaolinux
2013-05-09 14:13 ` [RFC PATCH V1 0/6] mm: add a new option MREMAP_DUP to mmrep syscall Mel Gorman
2013-05-10  2:28   ` wenchao
2013-05-10  5:11     ` Stefan Hajnoczi
2013-12-17  5:59       ` Xiao Guangrong
2013-12-30 20:23         ` Marcelo Tosatti
2013-12-31 12:06           ` Xiao Guangrong
2013-12-31 18:53             ` Marcelo Tosatti
2014-01-06  7:41               ` Xiao Guangrong
2013-05-10  9:22     ` Kirill A. Shutemov
2013-05-11 14:16       ` Pavel Emelyanov
2013-05-13  2:40         ` wenchao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).