mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
crtools/rpc/libcriu: Expose page compression
The compression paths have no supported user or RPC controls, and clients cannot discover whether CRIU was built with LZ4. Expose per-page and region compression, LZ4 acceleration, and worker concurrency for LZ4 decoding and eligible large zero fills through the CLI, configuration files, RPC, and libcriu. Add compression to the feature-check API and document each interface. Define --decompress-threads=0 as automatic worker concurrency and one as the serial default with zero-fill workers disabled. Values above one bound aggregate worker concurrency. Automatic mode derives a useful width from CPU affinity and the work in each batch. Reduce explicit requests above the available CPU count with a warning. Document the independent two-slot encoded-input budget. A local restore overlaps its next read only when it can reserve the second slot without waiting; otherwise it keeps synchronous I/O. Use the compression mode as the source of truth and validate every related value. An explicit RPC OFF clears ambient compression settings and rejects conflicting fields. Reject combinations unsupported by page server, stream, TLS, and image-format paths, and cover option and RPC precedence in the tests. Assisted-by: Codex:GPT-5 Assisted-by: Claude:claude-fable-5 Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
parent
85ac63b772
commit
3441f66b24
15 changed files with 612 additions and 4 deletions
86
lib/c/criu.c
86
lib/c/criu.c
|
|
@ -376,6 +376,85 @@ void criu_set_track_mem(bool track_mem)
|
|||
criu_local_set_track_mem(global_opts, track_mem);
|
||||
}
|
||||
|
||||
int criu_local_set_compress(criu_opts *opts, enum criu_compress_mode mode)
|
||||
{
|
||||
if (mode < CRIU_COMPRESS_OFF || mode > CRIU_COMPRESS_REGION)
|
||||
return -EINVAL;
|
||||
|
||||
opts->rpc->has_compress = true;
|
||||
opts->rpc->compress = mode;
|
||||
if (mode != CRIU_COMPRESS_REGION) {
|
||||
opts->rpc->has_compress_region_size = false;
|
||||
opts->rpc->compress_region_size = 0;
|
||||
}
|
||||
if (mode == CRIU_COMPRESS_OFF) {
|
||||
opts->rpc->has_compress_acceleration = false;
|
||||
opts->rpc->compress_acceleration = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int criu_set_compress(enum criu_compress_mode mode)
|
||||
{
|
||||
return criu_local_set_compress(global_opts, mode);
|
||||
}
|
||||
|
||||
int criu_local_set_compress_acceleration(criu_opts *opts,
|
||||
unsigned int acceleration)
|
||||
{
|
||||
if (acceleration < 1 || acceleration > CRIU_COMPRESS_MAX_ACCELERATION)
|
||||
return -EINVAL;
|
||||
|
||||
opts->rpc->has_compress_acceleration = true;
|
||||
opts->rpc->compress_acceleration = acceleration;
|
||||
if (!opts->rpc->has_compress ||
|
||||
opts->rpc->compress == CRIU_COMPRESS_OFF) {
|
||||
opts->rpc->has_compress = true;
|
||||
opts->rpc->compress = CRIU_COMPRESS_PER_PAGE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int criu_set_compress_acceleration(unsigned int acceleration)
|
||||
{
|
||||
return criu_local_set_compress_acceleration(global_opts, acceleration);
|
||||
}
|
||||
|
||||
int criu_local_set_compress_region_size(criu_opts *opts, unsigned int bytes)
|
||||
{
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
|
||||
if (page_size <= 0 || !bytes || bytes > CRIU_COMPRESS_MAX_REGION_SIZE ||
|
||||
bytes % (unsigned long)page_size)
|
||||
return -EINVAL;
|
||||
|
||||
opts->rpc->has_compress_region_size = true;
|
||||
opts->rpc->compress_region_size = bytes;
|
||||
opts->rpc->has_compress = true;
|
||||
opts->rpc->compress = CRIU_COMPRESS_REGION;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int criu_set_compress_region_size(unsigned int bytes)
|
||||
{
|
||||
return criu_local_set_compress_region_size(global_opts, bytes);
|
||||
}
|
||||
|
||||
int criu_local_set_decompress_threads(criu_opts *opts, unsigned int threads)
|
||||
{
|
||||
if (threads > CRIU_DECOMPRESS_MAX_THREADS)
|
||||
return -EINVAL;
|
||||
|
||||
opts->rpc->has_decompress_threads = true;
|
||||
opts->rpc->decompress_threads = threads;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int criu_set_decompress_threads(unsigned int threads)
|
||||
{
|
||||
return criu_local_set_decompress_threads(global_opts, threads);
|
||||
}
|
||||
|
||||
void criu_local_set_auto_dedup(criu_opts *opts, bool auto_dedup)
|
||||
{
|
||||
opts->rpc->has_auto_dedup = true;
|
||||
|
|
@ -2007,6 +2086,10 @@ int criu_local_feature_check(criu_opts *opts, struct criu_feature_check *feature
|
|||
criu_features.has_pidfd_store = true;
|
||||
criu_features.pidfd_store = true;
|
||||
}
|
||||
if (features_copy.mem_compression) {
|
||||
criu_features.has_mem_compression = true;
|
||||
criu_features.mem_compression = true;
|
||||
}
|
||||
req.features = &criu_features;
|
||||
|
||||
ret = send_req_and_recv_resp(opts, &req, &resp);
|
||||
|
|
@ -2025,6 +2108,9 @@ int criu_local_feature_check(criu_opts *opts, struct criu_feature_check *feature
|
|||
if (resp->features->has_pidfd_store) {
|
||||
features_copy.pidfd_store = resp->features->pidfd_store;
|
||||
}
|
||||
if (resp->features->has_mem_compression) {
|
||||
features_copy.mem_compression = resp->features->mem_compression;
|
||||
}
|
||||
memcpy(features, &features_copy, size);
|
||||
} else {
|
||||
ret = -EBADE;
|
||||
|
|
|
|||
28
lib/c/criu.h
28
lib/c/criu.h
|
|
@ -60,6 +60,17 @@ enum criu_image_io_mode {
|
|||
CRIU_IMAGE_IO_DIRECT = 1,
|
||||
};
|
||||
|
||||
enum criu_compress_mode {
|
||||
CRIU_COMPRESS_OFF = 0,
|
||||
CRIU_COMPRESS_PER_PAGE = 1,
|
||||
CRIU_COMPRESS_REGION = 2,
|
||||
};
|
||||
|
||||
#define CRIU_COMPRESS_MAX_ACCELERATION 65537U
|
||||
#define CRIU_COMPRESS_MAX_REGION_SIZE (4U * 1024U * 1024U)
|
||||
/* Maximum explicit setting; automatic concurrency is not capped by it. */
|
||||
#define CRIU_DECOMPRESS_MAX_THREADS 1024U
|
||||
|
||||
int criu_set_service_address(const char *path);
|
||||
void criu_set_service_fd(int fd);
|
||||
int criu_set_service_binary(const char *path);
|
||||
|
|
@ -90,6 +101,17 @@ void criu_set_unprivileged(bool unprivileged);
|
|||
void criu_set_orphan_pts_master(bool orphan_pts_master);
|
||||
void criu_set_file_locks(bool file_locks);
|
||||
void criu_set_track_mem(bool track_mem);
|
||||
int criu_set_compress(enum criu_compress_mode mode);
|
||||
int criu_set_compress_acceleration(unsigned int acceleration);
|
||||
int criu_set_compress_region_size(unsigned int bytes);
|
||||
/*
|
||||
* Worker concurrency for LZ4 decoding and eligible large zero fills:
|
||||
* 0 = auto, 1 = serial/no zero-fill workers (default), N > 1 = aggregate
|
||||
* worker limit.
|
||||
* CPU affinity, useful batch work, and the shared budget may reduce active
|
||||
* concurrency.
|
||||
*/
|
||||
int criu_set_decompress_threads(unsigned int threads);
|
||||
void criu_set_auto_dedup(bool auto_dedup);
|
||||
void criu_set_force_irmap(bool force_irmap);
|
||||
void criu_set_link_remap(bool link_remap);
|
||||
|
|
@ -253,6 +275,11 @@ void criu_local_set_skip_file_rwx_check(criu_opts *opts, bool skip_file_rwx_chec
|
|||
void criu_local_set_orphan_pts_master(criu_opts *opts, bool orphan_pts_master);
|
||||
void criu_local_set_file_locks(criu_opts *opts, bool file_locks);
|
||||
void criu_local_set_track_mem(criu_opts *opts, bool track_mem);
|
||||
int criu_local_set_compress(criu_opts *opts, enum criu_compress_mode mode);
|
||||
int criu_local_set_compress_acceleration(criu_opts *opts, unsigned int acceleration);
|
||||
int criu_local_set_compress_region_size(criu_opts *opts, unsigned int bytes);
|
||||
/* Uses the same worker-concurrency values as criu_set_decompress_threads(). */
|
||||
int criu_local_set_decompress_threads(criu_opts *opts, unsigned int threads);
|
||||
void criu_local_set_auto_dedup(criu_opts *opts, bool auto_dedup);
|
||||
void criu_local_set_force_irmap(criu_opts *opts, bool force_irmap);
|
||||
void criu_local_set_link_remap(criu_opts *opts, bool link_remap);
|
||||
|
|
@ -327,6 +354,7 @@ struct criu_feature_check {
|
|||
bool mem_track;
|
||||
bool lazy_pages;
|
||||
bool pidfd_store;
|
||||
bool mem_compression;
|
||||
};
|
||||
|
||||
int criu_feature_check(struct criu_feature_check *features, size_t size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue