19 Star 0 Fork 38

openEuler-RISC-V/criu

forked from src-openEuler/criu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0047-mm-add-clear-pin-mem-and-init-page-map-option.patch 3.14 KB
一键复制 编辑 原始数据 按行查看 历史
river 提交于 2022-04-13 15:05 . criu: backport kinds of features/bugfix
From 1cb92fe0a930cf862f8a3ecd9a812d5b2e3aea60 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 8 Sep 2021 08:23:11 +0000
Subject: [PATCH 47/72] mm: add clear pin mem and init page map option
Add 'clear-pin-mem' option for clearing pin memory data,
and 'init-page-map' option for initializationing buffer for
reading page map info.
Signed-off-by: Jingxian He <hejingxian@huawei.com>
Signed-off-by: fu.lin <fulin10@huawei.com>
---
criu/crtools.c | 13 ++++++++++++-
criu/include/pin-mem.h | 4 ++++
criu/pin-mem.c | 20 ++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/criu/crtools.c b/criu/crtools.c
index ae858e8..cc0a18f 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -43,6 +43,7 @@
#include "fault-injection.h"
#include "proc_parse.h"
#include "kerndat.h"
+#include "pin-mem.h"
#include "setproctitle.h"
#include "sysctl.h"
@@ -169,6 +170,14 @@ int main(int argc, char *argv[], char *envp[])
goto usage;
}
+ if (!strcmp(argv[optind], "clear-pin-memory")) {
+ return clear_pin_mem(0);
+ }
+
+ if (!strcmp(argv[optind], "init-pagemap-read")) {
+ return init_pagemap_read(0);
+ }
+
/* We must not open imgs dir, if service is called */
if (strcmp(argv[optind], "service")) {
ret = open_image_dir(opts.imgs_dir, image_dir_mode(argv, optind));
@@ -320,7 +329,9 @@ usage:
" service launch service\n"
" dedup remove duplicates in memory dump\n"
" cpuinfo dump writes cpu information into image file\n"
- " cpuinfo check validates cpu information read from image file\n");
+ " cpuinfo check validates cpu information read from image file\n"
+ " clear-pin-memory clear pin memory manage data\n"
+ " init-pagemap-read init data buffer for reading page map info\n");
if (usage_error) {
pr_msg("\nTry -h|--help for more info\n");
diff --git a/criu/include/pin-mem.h b/criu/include/pin-mem.h
index 2b54996..b28ef3d 100644
--- a/criu/include/pin-mem.h
+++ b/criu/include/pin-mem.h
@@ -39,6 +39,9 @@ struct pin_mem_area_set {
#define _SET_FORK_PID 8
#define SET_FORK_PID _IOW(PIN_MEM_MAGIC, _SET_FORK_PID, int)
+#define _INIT_PAGEMAP_READ 5
+#define INIT_PAGEMAP_READ _IOW(PIN_MEM_MAGIC, _INIT_PAGEMAP_READ, int)
+
#endif /* __has_include("linux/pin_memory.h") */
#define PIN_MEM_FILE "/dev/pinmem"
@@ -49,5 +52,6 @@ int pin_vmae(VmaEntry *vmae, struct pstree_item *item);
int dump_task_special_pages(int pid);
int restore_task_special_pages(int pid);
int clear_pin_mem(int pid);
+int init_pagemap_read(int para);
#endif /* __CRIU_PIN_MEM_H__ */
diff --git a/criu/pin-mem.c b/criu/pin-mem.c
index b18db97..96ca2c5 100644
--- a/criu/pin-mem.c
+++ b/criu/pin-mem.c
@@ -144,3 +144,23 @@ int clear_pin_mem(int pid)
close(fd);
return ret;
}
+
+int init_pagemap_read(int para)
+{
+ int fd, ret;
+
+ fd = open(PIN_MEM_FILE, O_RDWR, 0);
+ if (fd < 0) {
+ pr_warn("error open file: %s\n", PIN_MEM_FILE);
+ return -1;
+ }
+
+ ret = ioctl(fd, INIT_PAGEMAP_READ, (unsigned long) &para);
+ if (ret < 0) {
+ pr_warn("Init pagemap read fail, errno: %s\n", strerror(errno));
+ }
+
+ close(fd);
+ return ret;
+}
+
--
2.34.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler-risc-v/criu.git
git@gitee.com:openeuler-risc-v/criu.git
openeuler-risc-v
criu
criu
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385