[CRIU] Re: [PATCH] zdtm: maps02 -- Make sure HugeTLB is present

Cyrill Gorcunov gorcunov at openvz.org
Fri Oct 26 05:39:44 EDT 2012


On Fri, Oct 26, 2012 at 01:09:37PM +0400, Pavel Emelyanov wrote:
> This is horrible. When you create some kind of mapping and fail
> to madvise one, you should remind that fact and don't check one
> later.

Something like below?

-------------- next part --------------
>From e362724b5f9035df43bb35a17b97d021309497bf Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Fri, 26 Oct 2012 12:51:40 +0400
Subject: [PATCH] zdtm: maps02 -- Make sure HugeTLB is present

Reported-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm/live/static/maps02.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/zdtm/live/static/maps02.c b/test/zdtm/live/static/maps02.c
index 5394a71..f0949df 100644
--- a/test/zdtm/live/static/maps02.c
+++ b/test/zdtm/live/static/maps02.c
@@ -116,6 +116,9 @@ static int get_smaps_bits(unsigned long where, unsigned long *flags, unsigned lo
 	FILE *smaps = NULL;
 	char buf[1024];
 
+	if (!where)
+		return 0;
+
 	smaps = fopen("/proc/self/smaps", "r");
 	if (!smaps) {
 		err("Can't open smaps: %m");
@@ -153,8 +156,14 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv)
 	}
 
 	if (madvise(m->start, MEM_SIZE, adv)) {
-		err("madvise failed: %m");
-		return -1;
+		if (errno == EINVAL) {
+			test_msg("madvise failed, no kernel support\n");
+			munmap(m->start, MEM_SIZE);
+			*m = (struct mmap_data){ };
+		} else {
+			err("madvise failed: %m");
+			return -1;
+		}
 	}
 
 	return 0;
-- 
1.7.7.6



More information about the CRIU mailing list