Commit 04fde2e1 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mem: Don't track memory changes if --track-mem is not specified

We have a big mistake in how we track for ptes to be SOFT_DIRTY -- no
need in these checks if the --track-mem is not given.

While fixing this, remember proper checks for the kernel memory tracker.
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Reported-by: 's avatarTim Schürmann <info@tim-schuermann.de>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 21b5bcc0
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "compiler.h" #include "compiler.h"
#include "sysctl.h" #include "sysctl.h"
#include "asm/types.h" #include "asm/types.h"
#include "cr_options.h"
dev_t kerndat_shmem_dev; dev_t kerndat_shmem_dev;
...@@ -96,8 +97,13 @@ int kerndat_get_dirty_track(void) ...@@ -96,8 +97,13 @@ int kerndat_get_dirty_track(void)
if (pmap & PME_SOFT_DIRTY) { if (pmap & PME_SOFT_DIRTY) {
pr_info("Dirty track supported on kernel\n"); pr_info("Dirty track supported on kernel\n");
kerndat_has_dirty_track = true; kerndat_has_dirty_track = true;
} else } else {
pr_info("Dirty tracking support is OFF\n"); pr_info("Dirty tracking support is OFF\n");
if (opts.track_mem) {
pr_err("Tracking memory is not available\n");
return -1;
}
}
return 0; return 0;
} }
......
...@@ -43,11 +43,7 @@ static int task_reset_dirty_track(int pid) ...@@ -43,11 +43,7 @@ static int task_reset_dirty_track(int pid)
if (!opts.track_mem) if (!opts.track_mem)
return 0; return 0;
if (!kerndat_has_dirty_track) { BUG_ON(!kerndat_has_dirty_track);
pr_err("Kernel doesn't support dirty tracking. "
"No snapshot available.\n");
return -1;
}
return do_task_reset_dirty_track(pid); return do_task_reset_dirty_track(pid);
} }
...@@ -81,6 +77,17 @@ static struct mem_snap_ctx *mem_snap_init(struct parasite_ctl *ctl) ...@@ -81,6 +77,17 @@ static struct mem_snap_ctx *mem_snap_init(struct parasite_ctl *ctl)
int p_fd, pm_fd; int p_fd, pm_fd;
PagemapHead *h; PagemapHead *h;
/*
* If we're not tracking memory changes, then it doesn't
* matter whether we have parent images or not. Just
* proceed with full memory dump.
*/
if (!opts.track_mem)
return NULL;
BUG_ON(!kerndat_has_dirty_track);
p_fd = get_service_fd(PARENT_FD_OFF); p_fd = get_service_fd(PARENT_FD_OFF);
if (p_fd < 0) { if (p_fd < 0) {
pr_debug("Will do full memory dump\n"); pr_debug("Will do full memory dump\n");
......
...@@ -58,7 +58,7 @@ ${CRIU} pre-dump -D "$IMGDIR/dump-2/pre/" -o dump.log -t ${PID} -v4 || fail "Fai ...@@ -58,7 +58,7 @@ ${CRIU} pre-dump -D "$IMGDIR/dump-2/pre/" -o dump.log -t ${PID} -v4 || fail "Fai
echo "Plain dump" echo "Plain dump"
mkdir "$IMGDIR/dump-2/plain/" mkdir "$IMGDIR/dump-2/plain/"
${CRIU} dump -D "$IMGDIR/dump-2/plain/" -o dump.log -t ${PID} -v4 --prev-images-dir=../pre/ || fail "Fail to dump" ${CRIU} dump -D "$IMGDIR/dump-2/plain/" -o dump.log -t ${PID} -v4 --prev-images-dir=../pre/ --track-mem || fail "Fail to dump"
sleep 1 sleep 1
echo "Restore" echo "Restore"
......
...@@ -46,7 +46,7 @@ for SNAP in $(seq 1 $NRSNAP); do ...@@ -46,7 +46,7 @@ for SNAP in $(seq 1 $NRSNAP); do
elif [ $SNAP -eq $NRSNAP ]; then elif [ $SNAP -eq $NRSNAP ]; then
# Last dump # Last dump
cmd="dump" cmd="dump"
args="--prev-images-dir=../$((SNAP - 1))/" args="--prev-images-dir=../$((SNAP - 1))/ --track-mem"
else else
# Other pre-dumps # Other pre-dumps
cmd="pre-dump" cmd="pre-dump"
......
...@@ -45,7 +45,7 @@ for SNAP in $(seq 1 $NRSNAP); do ...@@ -45,7 +45,7 @@ for SNAP in $(seq 1 $NRSNAP); do
elif [ $SNAP -eq $NRSNAP ]; then elif [ $SNAP -eq $NRSNAP ]; then
# Last snapshot -- has parent, kill afterwards # Last snapshot -- has parent, kill afterwards
size_first=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1) size_first=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
args="--prev-images-dir=../$((SNAP - 1))/ --auto-dedup" args="--prev-images-dir=../$((SNAP - 1))/ --track-mem --auto-dedup"
else else
# Other snapshots -- have parent, keep running # Other snapshots -- have parent, keep running
args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R" args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
......
...@@ -44,7 +44,7 @@ for SNAP in $(seq 1 $NRSNAP); do ...@@ -44,7 +44,7 @@ for SNAP in $(seq 1 $NRSNAP); do
args="--track-mem -R" args="--track-mem -R"
elif [ $SNAP -eq $NRSNAP ]; then elif [ $SNAP -eq $NRSNAP ]; then
# Last snapshot -- has parent, kill afterwards # Last snapshot -- has parent, kill afterwards
args="--prev-images-dir=../$((SNAP - 1))/" args="--prev-images-dir=../$((SNAP - 1))/ --track-mem"
else else
# Other snapshots -- have parent, keep running # Other snapshots -- have parent, keep running
args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R" args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
......
...@@ -44,7 +44,7 @@ for SNAP in $(seq 1 $NRSNAP); do ...@@ -44,7 +44,7 @@ for SNAP in $(seq 1 $NRSNAP); do
args="--track-mem -R" args="--track-mem -R"
elif [ $SNAP -eq $NRSNAP ]; then elif [ $SNAP -eq $NRSNAP ]; then
# Last snapshot -- has parent, kill afterwards # Last snapshot -- has parent, kill afterwards
args="--prev-images-dir=../$((SNAP - 1))/" args="--prev-images-dir=../$((SNAP - 1))/ --track-mem"
else else
# Other snapshots -- have parent, keep running # Other snapshots -- have parent, keep running
args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R" args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment