Received: from eggs.gnu.org ([2001:4830:134:3::10]:49869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1b7H-0005K5-Cv for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:32:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1b7D-0001Tf-Cb for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:32:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1b7D-0001Ta-7r for qemu-devel@nongnu.org; Wed, 25 Nov 2015 09:32:11 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id F1C8FE7061 for ; Wed, 25 Nov 2015 14:32:10 +0000 (UTC) From: Juan Quintela Date: Wed, 25 Nov 2015 15:32:05 +0100 Message-Id: <1448461926-31401-2-git-send-email-quintela@redhat.com> In-Reply-To: <1448461926-31401-1-git-send-email-quintela@redhat.com> References: <1448461926-31401-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PULL 1/2] Assume madvise for (no)hugepage works List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, dgilbert@redhat.com From: "Dr. David Alan Gilbert" madvise() returns EINVAL in the case of many failures, but also returns it in cases where the host kernel doesn't have THP enabled. Postcopy only really cares that THP is off before it detects faults, and turns it back on afterwards; so we're going to have to assume that if the madvise fails then the host just doesn't do THP and we can carry on with the postcopy. Signed-off-by: Dr. David Alan Gilbert Tested-by: Jason J. Herne Reviewed-by: Juan Quintela Reviewed-by: Amit Shah Signed-off-by: Juan Quintela --- migration/postcopy-ram.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 22d6b18..3946aa9 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -241,10 +241,7 @@ static int cleanup_range(const char *block_name, void *host_addr, * We turned off hugepage for the precopy stage with postcopy enabled * we can turn it back on now. */ - if (qemu_madvise(host_addr, length, QEMU_MADV_HUGEPAGE)) { - error_report("%s HUGEPAGE: %s", __func__, strerror(errno)); - return -1; - } + qemu_madvise(host_addr, length, QEMU_MADV_HUGEPAGE); /* * We can also turn off userfault now since we should have all the @@ -345,10 +342,7 @@ static int nhp_range(const char *block_name, void *host_addr, * do delete areas of the page, even if THP thinks a hugepage would * be a good idea, so force hugepages off. */ - if (qemu_madvise(host_addr, length, QEMU_MADV_NOHUGEPAGE)) { - error_report("%s: NOHUGEPAGE: %s", __func__, strerror(errno)); - return -1; - } + qemu_madvise(host_addr, length, QEMU_MADV_NOHUGEPAGE); return 0; } -- 2.5.0