[CRIU] [PATCH] crit: Add madvise flags decoding
Víctor González Prieto
victor.gonzalez.prieto at est.fib.upc.edu
Tue Apr 9 00:37:17 MSK 2019
Closes: checkpoint-restore/criu#342
Only added support for the subset of advises that CRIU encodes in its
mm images, as defined in criu/proc_parse.c, macro _vmflag_match().
As for the hardcoded advise constants, I crosschecked a number of
mman.h headers available on the Internet, including criu's.
Signed-off-by: Víctor González Prieto <victor.gonzalez.prieto at est.fib.upc.edu>
---
How did I test this:
I ran the Simple Loop demo (https://criu.org/Simple_loop), before
and after the patch. In the mm checkpoint file for the first process,
there's a line for one of the VMAs that, with crit show, reads
"madv": "0x10000"
After applying the patch, the line reads
"madv": "MADV_DONTDUMP"
I guess this happens because of criu/mem.c#L1094, which is the only
use of advises I have seen in the codebase aside from logging and tests.
I also ensured that I'm not breaking any ZDTM tests. Would that mean
that the CRIT tools could use some testing?
images/vma.proto | 2 +-
lib/py/images/pb2dict.py | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/images/vma.proto b/images/vma.proto
index 7085f423..16747882 100644
--- a/images/vma.proto
+++ b/images/vma.proto
@@ -18,7 +18,7 @@ message vma_entry {
required sint64 fd = 8;
/* madvise flags bitmap */
- optional uint64 madv = 9 [(criu).hex = true];
+ optional uint64 madv = 9 [(criu).flags = "madvise.advice" ];
/* file status flags */
optional uint32 fdflags = 10 [(criu).hex = true];
diff --git a/lib/py/images/pb2dict.py b/lib/py/images/pb2dict.py
index 18d4c68e..4a2516c4 100644
--- a/lib/py/images/pb2dict.py
+++ b/lib/py/images/pb2dict.py
@@ -98,6 +98,16 @@ mmap_status_map = [
('VMA_UNSUPP', 1 << 31),
]
+madvise_advice_map = [
+ ('MADV_RANDOM', 1 << 1),
+ ('MADV_SEQUENTIAL', 1 << 2),
+ ('MADV_DONTFORK', 1 << 10),
+ ('MADV_MERGEABLE', 1 << 12),
+ ('MADV_HUGEPAGE', 1 << 14),
+ ('MADV_NOHUGEPAGE', 1 << 15),
+ ('MADV_DONTDUMP', 1 << 16),
+]
+
rfile_flags_map = [
('O_WRONLY', 0o1),
('O_RDWR', 0o2),
@@ -116,6 +126,7 @@ flags_maps = {
'mmap.prot' : mmap_prot_map,
'mmap.flags' : mmap_flags_map,
'mmap.status' : mmap_status_map,
+ 'madvise.advice' : madvise_advice_map,
'rfile.flags' : rfile_flags_map,
'pmap.flags' : pmap_flags_map,
}
--
2.21.0
More information about the CRIU
mailing list