From 0d1dfc2e08dbdde9c5bf30ca8172833867151a79 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Tue, 5 Nov 2013 12:33:03 +0400 Subject: [PATCH] crtools: move all stuff about vma together Signed-off-by: Andrey Vagin Signed-off-by: Pavel Emelyanov --- arch/arm/vdso-pie.c | 1 + arch/x86/vdso-pie.c | 1 + arch/x86/vdso.c | 2 +- cr-dump.c | 1 + cr-exec.c | 1 + cr-restore.c | 1 + include/crtools.h | 34 ---------------------------------- include/image.h | 4 ---- include/sk-queue.h | 5 ----- include/vma.h | 41 +++++++++++++++++++++++++++++++++++++++++ mem.c | 1 + parasite-syscall.c | 1 + pie/restorer.c | 1 + proc_parse.c | 1 + shmem.c | 2 ++ sk-packet.c | 2 +- util.c | 2 ++ 17 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 include/vma.h diff --git a/arch/arm/vdso-pie.c b/arch/arm/vdso-pie.c index ed7413cae..1f094cb3a 100644 --- a/arch/arm/vdso-pie.c +++ b/arch/arm/vdso-pie.c @@ -1,6 +1,7 @@ #include #include "vdso.h" +#include "vma.h" #include "log.h" #ifdef LOG_PREFIX diff --git a/arch/x86/vdso-pie.c b/arch/x86/vdso-pie.c index 778e84a4d..c96360b78 100644 --- a/arch/x86/vdso-pie.c +++ b/arch/x86/vdso-pie.c @@ -15,6 +15,7 @@ #include "compiler.h" #include "crtools.h" #include "vdso.h" +#include "vma.h" #include "log.h" #ifdef LOG_PREFIX diff --git a/arch/x86/vdso.c b/arch/x86/vdso.c index d879eefb9..1beac24d7 100644 --- a/arch/x86/vdso.c +++ b/arch/x86/vdso.c @@ -15,12 +15,12 @@ #include "parasite-syscall.h" #include "parasite.h" #include "compiler.h" -#include "crtools.h" #include "kerndat.h" #include "vdso.h" #include "util.h" #include "log.h" #include "mem.h" +#include "vma.h" #ifdef LOG_PREFIX # undef LOG_PREFIX diff --git a/cr-dump.c b/cr-dump.c index ffd5ca38f..58a39c736 100644 --- a/cr-dump.c +++ b/cr-dump.c @@ -66,6 +66,7 @@ #include "page-pipe.h" #include "posix-timer.h" #include "vdso.h" +#include "vma.h" #include "cr-service.h" #include "asm/dump.h" diff --git a/cr-exec.c b/cr-exec.c index 1bf616b95..c33381659 100644 --- a/cr-exec.c +++ b/cr-exec.c @@ -3,6 +3,7 @@ #include "crtools.h" #include "ptrace.h" #include "parasite-syscall.h" +#include "vma.h" struct syscall_exec_desc { char *name; diff --git a/cr-restore.c b/cr-restore.c index 377c0e502..ace2b38aa 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -63,6 +63,7 @@ #include "vdso.h" #include "stats.h" #include "tun.h" +#include "vma.h" #include "kerndat.h" #include "rst-malloc.h" diff --git a/include/crtools.h b/include/crtools.h index a48e785d9..87b6f3e90 100644 --- a/include/crtools.h +++ b/include/crtools.h @@ -111,34 +111,6 @@ struct cr_fdset *cr_glob_fdset_open(int mode); void close_cr_fdset(struct cr_fdset **cr_fdset); -struct vm_area_list { - struct list_head h; - unsigned nr; - unsigned long priv_size; /* nr of pages in private VMAs */ - unsigned long longest; /* nr of pages in longest VMA */ -}; - -#define VM_AREA_LIST(name) struct vm_area_list name = { .h = LIST_HEAD_INIT(name.h), .nr = 0, } - -int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list); -void free_mappings(struct vm_area_list *vma_area_list); -bool privately_dump_vma(struct vma_area *vma); - -struct vma_area { - struct list_head list; - VmaEntry vma; - - union { - int vm_file_fd; - int vm_socket_id; - }; - unsigned long *page_bitmap; /* existent pages */ - unsigned long *ppage_bitmap; /* parent's existent pages */ -}; - -#define vma_area_is(vma_area, s) vma_entry_is(&((vma_area)->vma), s) -#define vma_area_len(vma_area) vma_entry_len(&((vma_area)->vma)) - struct fdt { int nr; /* How many tasks share this fd table */ pid_t pid; /* Who should restore this fd table */ @@ -171,12 +143,6 @@ struct rst_info { }; }; -static inline int in_vma_area(struct vma_area *vma, unsigned long addr) -{ - return addr >= (unsigned long)vma->vma.start && - addr < (unsigned long)vma->vma.end; -} - /* * When we have to restore a shared resource, we mush select which * task should do it, and make other(s) wait for it. In order to diff --git a/include/image.h b/include/image.h index 862aaf044..cd2da8704 100644 --- a/include/image.h +++ b/include/image.h @@ -49,10 +49,6 @@ #define VMA_AREA_SYSVIPC (1 << 10) #define VMA_AREA_SOCKET (1 << 11) -#define vma_premmaped_start(vma) ((vma)->shmid) -#define vma_entry_is(vma, s) (((vma)->status & (s)) == (s)) -#define vma_entry_len(vma) ((vma)->end - (vma)->start) - #define CR_CAP_SIZE 2 #define TASK_COMM_LEN 16 diff --git a/include/sk-queue.h b/include/sk-queue.h index 4a82571e1..9044de0b0 100644 --- a/include/sk-queue.h +++ b/include/sk-queue.h @@ -1,11 +1,6 @@ #ifndef __CR_SK_QUEUE_H__ #define __CR_SK_QUEUE_H__ -#include "asm/types.h" -#include "list.h" -#include "crtools.h" -#include "image.h" - extern int read_sk_queues(void); extern int dump_sk_queue(int sock_fd, int sock_id); extern int restore_sk_queue(int fd, unsigned int peer_id); diff --git a/include/vma.h b/include/vma.h new file mode 100644 index 000000000..e85fc462b --- /dev/null +++ b/include/vma.h @@ -0,0 +1,41 @@ +#ifndef __CR_VMA_H__ +#define __CR_VMA_H__ + +struct vm_area_list { + struct list_head h; + unsigned nr; + unsigned long priv_size; /* nr of pages in private VMAs */ + unsigned long longest; /* nr of pages in longest VMA */ +}; + +#define VM_AREA_LIST(name) struct vm_area_list name = { .h = LIST_HEAD_INIT(name.h), .nr = 0, } + +struct vma_area { + struct list_head list; + VmaEntry vma; + + union { + int vm_file_fd; + int vm_socket_id; + }; + unsigned long *page_bitmap; /* existent pages */ + unsigned long *ppage_bitmap; /* parent's existent pages */ +}; + +int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list); +void free_mappings(struct vm_area_list *vma_area_list); +bool privately_dump_vma(struct vma_area *vma); + +#define vma_area_is(vma_area, s) vma_entry_is(&((vma_area)->vma), s) +#define vma_area_len(vma_area) vma_entry_len(&((vma_area)->vma)) +#define vma_premmaped_start(vma) ((vma)->shmid) +#define vma_entry_is(vma, s) (((vma)->status & (s)) == (s)) +#define vma_entry_len(vma) ((vma)->end - (vma)->start) + +static inline int in_vma_area(struct vma_area *vma, unsigned long addr) +{ + return addr >= (unsigned long)vma->vma.start && + addr < (unsigned long)vma->vma.end; +} + +#endif diff --git a/mem.c b/mem.c index 5d53ed1ff..bebd9386f 100644 --- a/mem.c +++ b/mem.c @@ -13,6 +13,7 @@ #include "log.h" #include "kerndat.h" #include "stats.h" +#include "vma.h" #include "protobuf.h" #include "protobuf/pagemap.pb-c.h" diff --git a/parasite-syscall.c b/parasite-syscall.c index fb529d8e4..133afeb01 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -25,6 +25,7 @@ #include "posix-timer.h" #include "net.h" #include "mem.h" +#include "vma.h" #include "proc_parse.h" #include diff --git a/pie/restorer.c b/pie/restorer.c index 2e96584c4..daec74d9e 100644 --- a/pie/restorer.c +++ b/pie/restorer.c @@ -20,6 +20,7 @@ #include "util.h" #include "image.h" #include "sk-inet.h" +#include "vma.h" #include "crtools.h" #include "lock.h" diff --git a/proc_parse.c b/proc_parse.c index ea59cf72f..a33371623 100644 --- a/proc_parse.c +++ b/proc_parse.c @@ -21,6 +21,7 @@ #include "posix-timer.h" #include "kerndat.h" #include "vdso.h" +#include "vma.h" #include "proc_parse.h" #include "protobuf.h" diff --git a/shmem.c b/shmem.c index 843073c3f..e37581bad 100644 --- a/shmem.c +++ b/shmem.c @@ -8,6 +8,8 @@ #include "page-pipe.h" #include "page-xfer.h" #include "rst-malloc.h" +#include "vma.h" + #include "protobuf.h" #include "protobuf/pagemap.pb-c.h" diff --git a/sk-packet.c b/sk-packet.c index aa64056b0..dcc7af3d9 100644 --- a/sk-packet.c +++ b/sk-packet.c @@ -4,13 +4,13 @@ #include #include #include -#include "crtools.h" #include "asm/types.h" #include "files.h" #include "sockets.h" #include "libnetlink.h" #include "sk-packet.h" #include "packet_diag.h" +#include "vma.h" #include "protobuf.h" #include "protobuf/packet-sock.pb-c.h" diff --git a/util.c b/util.c index 50a8acb56..1d0e18abe 100644 --- a/util.c +++ b/util.c @@ -36,6 +36,8 @@ #include "list.h" #include "util.h" #include "rst-malloc.h" +#include "image.h" +#include "vma.h" #include "crtools.h" #include "servicefd.h"