[CRIU] [PATCH] pagemap: add an ability to disable pagemap cache
Andrei Vagin
avagin at openvz.org
Wed Aug 24 12:17:06 PDT 2016
From: Andrei Vagin <avagin at virtuozzo.com>
We found that the 3.19 Ubuntu kernel has a bug and
the pagemap cache doesn't work properly on this kernel.
Unfortunately Travis-CI allows to create intancies only with this kernel,
so we need to add this workaround.
https://github.com/xemul/criu/issues/207
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Cc: Dmitry Safonov <dsafonov at virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
criu/pagemap-cache.c | 18 +++++++++++++++++-
scripts/travis/travis-tests | 4 ++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/criu/pagemap-cache.c b/criu/pagemap-cache.c
index 28bd8ca..5a8def9 100644
--- a/criu/pagemap-cache.c
+++ b/criu/pagemap-cache.c
@@ -21,6 +21,13 @@
#define PAGEMAP_LEN(addr) (PAGE_PFN(addr) * sizeof(u64))
+/*
+ * It's a workaround for a kernel bug. In the 3.19 kernel when pagemap are read
+ * for a few vma-s for one read call, it returns incorrect data.
+ * https://github.com/xemul/criu/issues/207
+*/
+static bool pagemap_cache_disabled;
+
static inline void pmc_reset(pmc_t *pmc)
{
memzero(pmc, sizeof(*pmc));
@@ -47,6 +54,9 @@ int pmc_init(pmc_t *pmc, pid_t pid, const struct list_head *vma_head, size_t siz
if (!pmc->map)
goto err;
+ if (pagemap_cache_disabled)
+ pr_debug("The pagemap cache is disabled\n");
+
if (kdat.pmap == PM_DISABLED) {
/*
* FIXME We might need to implement greedy
@@ -107,7 +117,8 @@ static int pmc_fill_cache(pmc_t *pmc, const struct vma_area *vma)
* The benefit (apart redusing the number of read() calls)
* is to walk page tables less.
*/
- if (len < PMC_SIZE && (vma->e->start - low) < PMC_SIZE_GAP) {
+ if (!pagemap_cache_disabled &&
+ len < PMC_SIZE && (vma->e->start - low) < PMC_SIZE_GAP) {
size_t size_cov = len;
size_t nr_vmas = 1;
@@ -174,3 +185,8 @@ void pmc_fini(pmc_t *pmc)
xfree(pmc->map);
pmc_reset(pmc);
}
+
+static void __attribute__((constructor)) pagemap_cache_init(void)
+{
+ pagemap_cache_disabled = (getenv("CRIU_PMC_OFF") != NULL);
+}
diff --git a/scripts/travis/travis-tests b/scripts/travis/travis-tests
index fb569ac..76f4db9 100755
--- a/scripts/travis/travis-tests
+++ b/scripts/travis/travis-tests
@@ -19,6 +19,10 @@ make -C test/zdtm
umask 0000
export SKIP_PREP=1
+# The 3.19 Ubuntu kernel has a bug. When pagemap are read for a few vma-s
+# for one read call, it returns incorrect data.
+# https://github.com/xemul/criu/issues/207
+export CRIU_PMC_OFF=1
./test/zdtm.py run -a -x 'cgroup*' -p 2
--
2.7.4
More information about the CRIU
mailing list