mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-23 10:28:05 +00:00
Adding --pre-dump-mode option
Two modes of pre-dump algorithm: 1) splicing memory by parasite --pre-dump-mode=splice (default) 2) using process_vm_readv syscall --pre-dump-mode=read Signed-off-by: Abhishek Dubey <dubeyabhishek777@gmail.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
parent
576a99f492
commit
20d4920a8b
@ -156,6 +156,12 @@ In addition, *page-server* options may be specified.
|
|||||||
Turn on memory changes tracker in the kernel. If the option is
|
Turn on memory changes tracker in the kernel. If the option is
|
||||||
not passed the memory tracker get turned on implicitly.
|
not passed the memory tracker get turned on implicitly.
|
||||||
|
|
||||||
|
*--pre-dump-mode*='mode'::
|
||||||
|
There are two 'mode' to operate pre-dump algorithm. The 'splice' mode
|
||||||
|
is parasite based, whereas 'read' mode is based on process_vm_readv
|
||||||
|
syscall. The 'read' mode incurs reduced frozen time and reduced
|
||||||
|
memory pressure as compared to 'splice' mode. Default is 'splice' mode.
|
||||||
|
|
||||||
*dump*
|
*dump*
|
||||||
~~~~~~
|
~~~~~~
|
||||||
Performs a checkpoint procedure.
|
Performs a checkpoint procedure.
|
||||||
|
@ -276,6 +276,7 @@ void init_opts(void)
|
|||||||
opts.empty_ns = 0;
|
opts.empty_ns = 0;
|
||||||
opts.status_fd = -1;
|
opts.status_fd = -1;
|
||||||
opts.log_level = DEFAULT_LOGLEVEL;
|
opts.log_level = DEFAULT_LOGLEVEL;
|
||||||
|
opts.pre_dump_mode = PRE_DUMP_SPLICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deprecated_ok(char *what)
|
bool deprecated_ok(char *what)
|
||||||
@ -517,6 +518,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
|
|||||||
BOOL_OPT("tls", &opts.tls),
|
BOOL_OPT("tls", &opts.tls),
|
||||||
{"tls-no-cn-verify", no_argument, &opts.tls_no_cn_verify, true},
|
{"tls-no-cn-verify", no_argument, &opts.tls_no_cn_verify, true},
|
||||||
{ "cgroup-yard", required_argument, 0, 1096 },
|
{ "cgroup-yard", required_argument, 0, 1096 },
|
||||||
|
{ "pre-dump-mode", required_argument, 0, 1097},
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -818,6 +820,14 @@ int parse_options(int argc, char **argv, bool *usage_error,
|
|||||||
case 1096:
|
case 1096:
|
||||||
SET_CHAR_OPTS(cgroup_yard, optarg);
|
SET_CHAR_OPTS(cgroup_yard, optarg);
|
||||||
break;
|
break;
|
||||||
|
case 1097:
|
||||||
|
if (!strcmp("read", optarg)) {
|
||||||
|
opts.pre_dump_mode = PRE_DUMP_READ;
|
||||||
|
} else if (strcmp("splice", optarg)) {
|
||||||
|
pr_err("Unable to parse value of --pre-dump-mode\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
pr_msg("Version: %s\n", CRIU_VERSION);
|
pr_msg("Version: %s\n", CRIU_VERSION);
|
||||||
if (strcmp(CRIU_GITID, "0"))
|
if (strcmp(CRIU_GITID, "0"))
|
||||||
|
@ -473,6 +473,19 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
|
|||||||
opts.lazy_pages = req->lazy_pages;
|
opts.lazy_pages = req->lazy_pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req->has_pre_dump_mode) {
|
||||||
|
switch (req->pre_dump_mode) {
|
||||||
|
case CRIU_PRE_DUMP_MODE__SPLICE:
|
||||||
|
opts.pre_dump_mode = PRE_DUMP_SPLICE;
|
||||||
|
break;
|
||||||
|
case CRIU_PRE_DUMP_MODE__READ:
|
||||||
|
opts.pre_dump_mode = PRE_DUMP_READ;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (req->ps) {
|
if (req->ps) {
|
||||||
opts.port = (short)req->ps->port;
|
opts.port = (short)req->ps->port;
|
||||||
|
|
||||||
|
@ -428,6 +428,8 @@ usage:
|
|||||||
" pages images of previous dump\n"
|
" pages images of previous dump\n"
|
||||||
" when used on restore, as soon as page is restored, it\n"
|
" when used on restore, as soon as page is restored, it\n"
|
||||||
" will be punched from the image\n"
|
" will be punched from the image\n"
|
||||||
|
" --pre-dump-mode splice - parasite based pre-dumping (default)\n"
|
||||||
|
" read - process_vm_readv syscall based pre-dumping\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Page/Service server options:\n"
|
"Page/Service server options:\n"
|
||||||
" --address ADDR address of server or service\n"
|
" --address ADDR address of server or service\n"
|
||||||
|
@ -38,6 +38,12 @@ struct cg_root_opt {
|
|||||||
char *newroot;
|
char *newroot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pre-dump variants
|
||||||
|
*/
|
||||||
|
#define PRE_DUMP_SPLICE 1 /* Pre-dump using parasite */
|
||||||
|
#define PRE_DUMP_READ 2 /* Pre-dump using process_vm_readv syscall */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cgroup management options.
|
* Cgroup management options.
|
||||||
*/
|
*/
|
||||||
@ -81,6 +87,7 @@ struct cr_options {
|
|||||||
int evasive_devices;
|
int evasive_devices;
|
||||||
int link_remap_ok;
|
int link_remap_ok;
|
||||||
int log_file_per_pid;
|
int log_file_per_pid;
|
||||||
|
int pre_dump_mode;
|
||||||
bool swrk_restore;
|
bool swrk_restore;
|
||||||
char *output;
|
char *output;
|
||||||
char *root;
|
char *root;
|
||||||
|
13
criu/mem.c
13
criu/mem.c
@ -482,7 +482,18 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
|
|||||||
if (mdc->lazy)
|
if (mdc->lazy)
|
||||||
memcpy(pargs_iovs(args), pp->iovs,
|
memcpy(pargs_iovs(args), pp->iovs,
|
||||||
sizeof(struct iovec) * pp->nr_iovs);
|
sizeof(struct iovec) * pp->nr_iovs);
|
||||||
ret = drain_pages(pp, ctl, args);
|
|
||||||
|
/*
|
||||||
|
* Faking drain_pages for pre-dump here. Actual drain_pages for pre-dump
|
||||||
|
* will happen after task unfreezing in cr_pre_dump_finish(). This is
|
||||||
|
* actual optimization which reduces time for which process was frozen
|
||||||
|
* during pre-dump.
|
||||||
|
*/
|
||||||
|
if (mdc->pre_dump && opts.pre_dump_mode == PRE_DUMP_READ)
|
||||||
|
ret = 0;
|
||||||
|
else
|
||||||
|
ret = drain_pages(pp, ctl, args);
|
||||||
|
|
||||||
if (!ret && !mdc->pre_dump)
|
if (!ret && !mdc->pre_dump)
|
||||||
ret = xfer_pages(pp, &xfer);
|
ret = xfer_pages(pp, &xfer);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -47,6 +47,11 @@ enum criu_cg_mode {
|
|||||||
DEFAULT = 6;
|
DEFAULT = 6;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum criu_pre_dump_mode {
|
||||||
|
SPLICE = 1;
|
||||||
|
READ = 2;
|
||||||
|
};
|
||||||
|
|
||||||
message criu_opts {
|
message criu_opts {
|
||||||
required int32 images_dir_fd = 1;
|
required int32 images_dir_fd = 1;
|
||||||
optional int32 pid = 2; /* if not set on dump, will dump requesting process */
|
optional int32 pid = 2; /* if not set on dump, will dump requesting process */
|
||||||
@ -121,6 +126,7 @@ message criu_opts {
|
|||||||
optional bool tls = 58;
|
optional bool tls = 58;
|
||||||
optional bool tls_no_cn_verify = 59;
|
optional bool tls_no_cn_verify = 59;
|
||||||
optional string cgroup_yard = 60;
|
optional string cgroup_yard = 60;
|
||||||
|
optional criu_pre_dump_mode pre_dump_mode = 61 [default = SPLICE];
|
||||||
/* optional bool check_mounts = 128; */
|
/* optional bool check_mounts = 128; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
lib/c/criu.c
15
lib/c/criu.c
@ -336,6 +336,21 @@ int criu_set_parent_images(const char *path)
|
|||||||
return criu_local_set_parent_images(global_opts, path);
|
return criu_local_set_parent_images(global_opts, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int criu_local_set_pre_dump_mode(criu_opts *opts, enum criu_pre_dump_mode mode)
|
||||||
|
{
|
||||||
|
opts->rpc->has_pre_dump_mode = true;
|
||||||
|
if (mode == CRIU_PRE_DUMP_SPLICE || mode == CRIU_PRE_DUMP_READ) {
|
||||||
|
opts->rpc->pre_dump_mode = mode;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int criu_set_pre_dump_mode(enum criu_pre_dump_mode mode)
|
||||||
|
{
|
||||||
|
return criu_local_set_pre_dump_mode(global_opts, mode);
|
||||||
|
}
|
||||||
|
|
||||||
void criu_local_set_track_mem(criu_opts *opts, bool track_mem)
|
void criu_local_set_track_mem(criu_opts *opts, bool track_mem)
|
||||||
{
|
{
|
||||||
opts->rpc->has_track_mem = true;
|
opts->rpc->has_track_mem = true;
|
||||||
|
@ -43,6 +43,11 @@ enum criu_cg_mode {
|
|||||||
CRIU_CG_MODE_DEFAULT,
|
CRIU_CG_MODE_DEFAULT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum criu_pre_dump_mode {
|
||||||
|
CRIU_PRE_DUMP_SPLICE = 1,
|
||||||
|
CRIU_PRE_DUMP_READ = 2
|
||||||
|
};
|
||||||
|
|
||||||
int criu_set_service_address(const char *path);
|
int criu_set_service_address(const char *path);
|
||||||
void criu_set_service_fd(int fd);
|
void criu_set_service_fd(int fd);
|
||||||
int criu_set_service_binary(const char *path);
|
int criu_set_service_binary(const char *path);
|
||||||
@ -95,6 +100,7 @@ int criu_add_irmap_path(const char *path);
|
|||||||
int criu_add_inherit_fd(int fd, const char *key);
|
int criu_add_inherit_fd(int fd, const char *key);
|
||||||
int criu_add_external(const char *key);
|
int criu_add_external(const char *key);
|
||||||
int criu_set_page_server_address_port(const char *address, int port);
|
int criu_set_page_server_address_port(const char *address, int port);
|
||||||
|
int criu_set_pre_dump_mode(enum criu_pre_dump_mode mode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The criu_notify_arg_t na argument is an opaque
|
* The criu_notify_arg_t na argument is an opaque
|
||||||
@ -211,6 +217,7 @@ int criu_local_add_cg_yard(criu_opts *opts, const char *path);
|
|||||||
int criu_local_add_inherit_fd(criu_opts *opts, int fd, const char *key);
|
int criu_local_add_inherit_fd(criu_opts *opts, int fd, const char *key);
|
||||||
int criu_local_add_external(criu_opts *opts, const char *key);
|
int criu_local_add_external(criu_opts *opts, const char *key);
|
||||||
int criu_local_set_page_server_address_port(criu_opts *opts, const char *address, int port);
|
int criu_local_set_page_server_address_port(criu_opts *opts, const char *address, int port);
|
||||||
|
int criu_local_set_pre_dump_mode(criu_opts *opts, enum criu_pre_dump_mode mode);
|
||||||
|
|
||||||
void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na));
|
void criu_local_set_notify_cb(criu_opts *opts, int (*cb)(char *action, criu_notify_arg_t na));
|
||||||
|
|
||||||
|
@ -1019,6 +1019,7 @@ class criu:
|
|||||||
self.__tls = self.__tls_options() if opts['tls'] else []
|
self.__tls = self.__tls_options() if opts['tls'] else []
|
||||||
self.__criu_bin = opts['criu_bin']
|
self.__criu_bin = opts['criu_bin']
|
||||||
self.__crit_bin = opts['crit_bin']
|
self.__crit_bin = opts['crit_bin']
|
||||||
|
self.__pre_dump_mode = opts['pre_dump_mode']
|
||||||
|
|
||||||
def fini(self):
|
def fini(self):
|
||||||
if self.__lazy_migrate:
|
if self.__lazy_migrate:
|
||||||
@ -1249,6 +1250,8 @@ class criu:
|
|||||||
a_opts += ['--leave-stopped']
|
a_opts += ['--leave-stopped']
|
||||||
if self.__empty_ns:
|
if self.__empty_ns:
|
||||||
a_opts += ['--empty-ns', 'net']
|
a_opts += ['--empty-ns', 'net']
|
||||||
|
if self.__pre_dump_mode:
|
||||||
|
a_opts += ["--pre-dump-mode", "%s" % self.__pre_dump_mode]
|
||||||
|
|
||||||
nowait = False
|
nowait = False
|
||||||
if self.__lazy_migrate and action == "dump":
|
if self.__lazy_migrate and action == "dump":
|
||||||
@ -1835,7 +1838,7 @@ class Launcher:
|
|||||||
'sat', 'script', 'rpc', 'lazy_pages', 'join_ns', 'dedup', 'sbs',
|
'sat', 'script', 'rpc', 'lazy_pages', 'join_ns', 'dedup', 'sbs',
|
||||||
'freezecg', 'user', 'dry_run', 'noauto_dedup',
|
'freezecg', 'user', 'dry_run', 'noauto_dedup',
|
||||||
'remote_lazy_pages', 'show_stats', 'lazy_migrate',
|
'remote_lazy_pages', 'show_stats', 'lazy_migrate',
|
||||||
'tls', 'criu_bin', 'crit_bin')
|
'tls', 'criu_bin', 'crit_bin', 'pre_dump_mode')
|
||||||
arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
|
arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
|
||||||
|
|
||||||
if self.__use_log:
|
if self.__use_log:
|
||||||
@ -2482,6 +2485,10 @@ rp.add_argument("--criu-bin",
|
|||||||
rp.add_argument("--crit-bin",
|
rp.add_argument("--crit-bin",
|
||||||
help="Path to crit binary",
|
help="Path to crit binary",
|
||||||
default='../crit/crit')
|
default='../crit/crit')
|
||||||
|
rp.add_argument("--pre-dump-mode",
|
||||||
|
help="Use splice or read mode of pre-dumping",
|
||||||
|
choices=['splice', 'read'],
|
||||||
|
default='splice')
|
||||||
|
|
||||||
lp = sp.add_parser("list", help="List tests")
|
lp = sp.add_parser("list", help="List tests")
|
||||||
lp.set_defaults(action=list_tests)
|
lp.set_defaults(action=list_tests)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user