From patchwork Sun Nov 1 11:56:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 56848 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA1Bvolg029112 for ; Sun, 1 Nov 2009 11:57:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752393AbZKAL4p (ORCPT ); Sun, 1 Nov 2009 06:56:45 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752333AbZKAL4n (ORCPT ); Sun, 1 Nov 2009 06:56:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58306 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752166AbZKAL4b (ORCPT ); Sun, 1 Nov 2009 06:56:31 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA1BuZ7Q032000; Sun, 1 Nov 2009 06:56:35 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA1BuYWq022626; Sun, 1 Nov 2009 06:56:34 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 1B40018D41D; Sun, 1 Nov 2009 13:56:31 +0200 (IST) From: Gleb Natapov To: kvm@vger.kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/11] Handle async PF in non preemptable context. Date: Sun, 1 Nov 2009 13:56:29 +0200 Message-Id: <1257076590-29559-11-git-send-email-gleb@redhat.com> In-Reply-To: <1257076590-29559-1-git-send-email-gleb@redhat.com> References: <1257076590-29559-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 79d291f..1bd8b8d 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -162,10 +162,24 @@ int kvm_handle_pf(struct pt_regs *regs, unsigned long error_code) switch (reason) { default: return 0; - case KVM_PV_REASON_PAGE_NP: + case KVM_PV_REASON_PAGE_NP: { + int cpu, idle; + cpu = get_cpu(); + idle = idle_cpu(cpu); + put_cpu(); + + /* + * We cannot reschedule. Wait for page to be ready. + */ + if (idle || preempt_count()) { + kvm_hypercall0(KVM_HC_WAIT_FOR_ASYNC_PF); + break; + } + /* real page is missing. */ apf_task_wait(current, token); break; + } case KVM_PV_REASON_PAGE_READY: apf_task_wake(token); break;