From patchwork Fri Feb 21 08:17:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 322488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7E82F2C0334 for ; Fri, 21 Feb 2014 19:39:16 +1100 (EST) Received: from localhost ([::1]:43021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGlda-0007ag-Ak for incoming@patchwork.ozlabs.org; Fri, 21 Feb 2014 03:39:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGlKF-0006aM-Hf for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:19:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGlK3-0001tk-4C for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:19:15 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:51416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGlK2-0001tY-VM for qemu-devel@nongnu.org; Fri, 21 Feb 2014 03:19:03 -0500 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 21 Feb 2014 03:19:02 -0500 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 21 Feb 2014 03:19:01 -0500 Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 6C7A4C90026; Fri, 21 Feb 2014 03:18:57 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp23032.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1L8J0WK9044312; Fri, 21 Feb 2014 08:19:00 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1L8J0r3031646; Fri, 21 Feb 2014 03:19:00 -0500 Received: from localhost ([9.80.9.18]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s1L8Ixoi031603; Fri, 21 Feb 2014 03:18:59 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Fri, 21 Feb 2014 02:17:22 -0600 Message-Id: <1392970647-21528-47-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392970647-21528-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1392970647-21528-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14022108-0320-0000-0000-00000284A72E X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.138 Cc: lersek@redhat.com, qemu-stable@nongnu.org, Petar.Jovanovic@imgtec.com Subject: [Qemu-devel] [PATCH 46/51] KVM: Retry KVM_CREATE_VM on EINTR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: thomas knych Upstreaming this change from Android (https://android-review.googlesource.com/54211). On heavily loaded machines with many VM instances we see KVM_CREATE_VM failing with EINTR on this path: kvm_dev_ioctl_create_vm -> kvm_create_vm -> kvm_init_mmu_notifier -> mmu_notifier_register -> do_mmu_notifier_register -> mm_take_all_locks which checks if any signals have been raised while it was attaining locks and returns EINTR. Retrying the system call greatly improves reliability. Cc: qemu-stable@nongnu.org Signed-off-by: thomas knych Signed-off-by: Paolo Bonzini (cherry picked from commit 94ccff133820552a859c0fb95e33a539e0b90a75) Signed-off-by: Michael Roth --- kvm-all.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 4478969..951e6e3 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1431,16 +1431,22 @@ int kvm_init(void) nc++; } - s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0); - if (s->vmfd < 0) { + do { + ret = kvm_ioctl(s, KVM_CREATE_VM, 0); + } while (ret == -EINTR); + + if (ret < 0) { + fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -s->vmfd, + strerror(-ret)); + #ifdef TARGET_S390X fprintf(stderr, "Please add the 'switch_amode' kernel parameter to " "your host kernel command line\n"); #endif - ret = s->vmfd; goto err; } + s->vmfd = ret; missing_cap = kvm_check_extension_list(s, kvm_required_capabilites); if (!missing_cap) { missing_cap =