Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--criu/hugetlb.c13
-rw-r--r--criu/include/hugetlb.h6
-rw-r--r--criu/proc_parse.c7
3 files changed, 22 insertions, 4 deletions
diff --git a/criu/hugetlb.c b/criu/hugetlb.c
index aa98662d8..866c4050f 100644
--- a/criu/hugetlb.c
+++ b/criu/hugetlb.c
@@ -35,6 +35,19 @@ int is_hugetlb_dev(dev_t dev, int *hugetlb_size_flag)
return 0;
}
+int can_dump_with_memfd_hugetlb(dev_t dev, int *hugetlb_size_flag, const char *file_path, struct vma_area *vma)
+{
+ /*
+ * Dump the hugetlb backed mapping using memfd_hugetlb when it is not
+ * anonymous private mapping.
+ */
+ if (kdat.has_memfd_hugetlb && is_hugetlb_dev(dev, hugetlb_size_flag) &&
+ !((vma->e->flags & MAP_PRIVATE) && !strncmp(file_path, ANON_HUGEPAGE_PREFIX, ANON_HUGEPAGE_PREFIX_LEN)))
+ return 1;
+
+ return 0;
+}
+
unsigned long get_size_from_hugetlb_flag(int flag)
{
int i;
diff --git a/criu/include/hugetlb.h b/criu/include/hugetlb.h
index c0e83652b..9aee5bed3 100644
--- a/criu/include/hugetlb.h
+++ b/criu/include/hugetlb.h
@@ -4,6 +4,11 @@
#include <sys/types.h>
#include <stddef.h>
+#include "vma.h"
+
+#define ANON_HUGEPAGE_PREFIX "/anon_hugepage"
+#define ANON_HUGEPAGE_PREFIX_LEN (sizeof(ANON_HUGEPAGE_PREFIX) - 1)
+
enum hugepage_size {
HUGETLB_16KB,
HUGETLB_64KB,
@@ -46,6 +51,7 @@ struct htlb_info {
extern struct htlb_info hugetlb_info[HUGETLB_MAX];
int is_hugetlb_dev(dev_t dev, int *hugetlb_size_flag);
+int can_dump_with_memfd_hugetlb(dev_t dev, int *hugetlb_size_flag, const char *file_path, struct vma_area *vma);
unsigned long get_size_from_hugetlb_flag(int flag);
#ifndef MFD_HUGETLB
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index b3badb6e4..6b41a81db 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -620,17 +620,16 @@ static int handle_vma(pid_t pid, struct vma_area *vma_area, const char *file_pat
pr_info("path: %s\n", file_path);
vma_area->e->status |= VMA_AREA_SYSVIPC;
} else {
- /* Dump shmem dev, hugetlb dev (private and share) mappings the same way as memfd
- * when possible.
+ /* We dump memfd backed mapping, both normal and hugepage anonymous share
+ * mapping using memfd approach when possible.
*/
if (is_memfd(st_buf->st_dev) || is_anon_shmem_map(st_buf->st_dev) ||
- (kdat.has_memfd_hugetlb && is_hugetlb_dev(st_buf->st_dev, &hugetlb_flag))) {
+ can_dump_with_memfd_hugetlb(st_buf->st_dev, &hugetlb_flag, file_path, vma_area)) {
vma_area->e->status |= VMA_AREA_MEMFD;
vma_area->e->flags |= hugetlb_flag;
if (fault_injected(FI_HUGE_ANON_SHMEM_ID))
vma_area->e->shmid += FI_HUGE_ANON_SHMEM_ID_BASE;
} else if (is_hugetlb_dev(st_buf->st_dev, &hugetlb_flag)) {
- /* hugetlb mapping but memfd does not support HUGETLB */
vma_area->e->flags |= hugetlb_flag;
vma_area->e->flags |= MAP_ANONYMOUS;