mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
memory: Add pasing of VmFlags
The kernel now supports providing VMA flags via smaps interface so add pasting of them. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
a343afad34
commit
cc6af3898e
58
proc_parse.c
58
proc_parse.c
@@ -49,6 +49,59 @@ static bool is_vma_range_fmt(char *line)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_vmflags(char *buf, struct vma_area *vma_area)
|
||||||
|
{
|
||||||
|
char *tok;
|
||||||
|
|
||||||
|
if (!buf[0])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
tok = strtok(buf, " \n");
|
||||||
|
if (!tok)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#define _vmflag_match(_t, _s) (_t[0] == _s[0] && _t[1] == _s[1])
|
||||||
|
|
||||||
|
do {
|
||||||
|
/* mmap() block */
|
||||||
|
if (_vmflag_match(tok, "gd"))
|
||||||
|
vma_area->vma.flags |= MAP_GROWSDOWN;
|
||||||
|
else if (_vmflag_match(tok, "lo"))
|
||||||
|
vma_area->vma.flags |= MAP_LOCKED;
|
||||||
|
else if (_vmflag_match(tok, "nr"))
|
||||||
|
vma_area->vma.flags |= MAP_NORESERVE;
|
||||||
|
else if (_vmflag_match(tok, "ht"))
|
||||||
|
vma_area->vma.flags |= MAP_HUGETLB;
|
||||||
|
|
||||||
|
/* madvise() block */
|
||||||
|
if (_vmflag_match(tok, "sr"))
|
||||||
|
vma_area->vma.madv |= (1ul << MADV_SEQUENTIAL);
|
||||||
|
else if (_vmflag_match(tok, "rr"))
|
||||||
|
vma_area->vma.madv |= (1ul << MADV_RANDOM);
|
||||||
|
else if (_vmflag_match(tok, "dc"))
|
||||||
|
vma_area->vma.madv |= (1ul << MADV_DONTFORK);
|
||||||
|
else if (_vmflag_match(tok, "dd"))
|
||||||
|
vma_area->vma.madv |= (1ul << MADV_DONTDUMP);
|
||||||
|
else if (_vmflag_match(tok, "mg"))
|
||||||
|
vma_area->vma.madv |= (1ul << MADV_MERGEABLE);
|
||||||
|
else if (_vmflag_match(tok, "hg"))
|
||||||
|
vma_area->vma.madv |= (1ul << MADV_HUGEPAGE);
|
||||||
|
else if (_vmflag_match(tok, "nh"))
|
||||||
|
vma_area->vma.madv |= (1ul << MADV_NOHUGEPAGE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Anything else is just ignored.
|
||||||
|
*/
|
||||||
|
} while ((tok = strtok(NULL, " \n")));
|
||||||
|
|
||||||
|
#undef _vmflag_match
|
||||||
|
|
||||||
|
if (vma_area->vma.madv)
|
||||||
|
vma_area->vma.has_madv = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_files)
|
int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_files)
|
||||||
{
|
{
|
||||||
struct vma_area *vma_area = NULL;
|
struct vma_area *vma_area = NULL;
|
||||||
@@ -86,6 +139,11 @@ int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_files)
|
|||||||
*/
|
*/
|
||||||
vma_area = NULL;
|
vma_area = NULL;
|
||||||
goto err;
|
goto err;
|
||||||
|
} else if (!strncmp(buf, "VmFlags: ", 9)) {
|
||||||
|
BUG_ON(!vma_area);
|
||||||
|
if (parse_vmflags(&buf[9], vma_area))
|
||||||
|
goto err;
|
||||||
|
continue;
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -10,4 +10,7 @@ message vma_entry {
|
|||||||
// while switching from execve restore model. It is
|
// while switching from execve restore model. It is
|
||||||
// -1 by default.
|
// -1 by default.
|
||||||
required sint64 fd = 8;
|
required sint64 fd = 8;
|
||||||
|
|
||||||
|
/* madvise flags bitmap */
|
||||||
|
optional uint64 madv = 9;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user