public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: use is_idle_task() instead of idle_cpu() to decide when to halt in async_pf
@ 2012-11-28 13:19 Gleb Natapov
  2012-11-28 23:30 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2012-11-28 13:19 UTC (permalink / raw)
  To: kvm; +Cc: mtosatti, Frederic Weisbecker, Li Zhong

As Frederic pointed idle_cpu() may return false even if async fault
happened in the idle task if wake up is pending. In this case the code
will try to put idle task to sleep. Fix this by using is_idle_task() to
check for idle task.

Reported-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index a91c6b4..08b973f 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -120,11 +120,6 @@ void kvm_async_pf_task_wait(u32 token)
 	struct kvm_task_sleep_head *b = &async_pf_sleepers[key];
 	struct kvm_task_sleep_node n, *e;
 	DEFINE_WAIT(wait);
-	int cpu, idle;
-
-	cpu = get_cpu();
-	idle = idle_cpu(cpu);
-	put_cpu();
 
 	spin_lock(&b->lock);
 	e = _find_apf_task(b, token);
@@ -138,7 +133,7 @@ void kvm_async_pf_task_wait(u32 token)
 
 	n.token = token;
 	n.cpu = smp_processor_id();
-	n.halted = idle || preempt_count() > 1;
+	n.halted = is_idle_task(current) || preempt_count() > 1;
 	init_waitqueue_head(&n.wq);
 	hlist_add_head(&n.link, &b->list);
 	spin_unlock(&b->lock);
--
			Gleb.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: use is_idle_task() instead of idle_cpu() to decide when to halt in async_pf
  2012-11-28 13:19 [PATCH] KVM: use is_idle_task() instead of idle_cpu() to decide when to halt in async_pf Gleb Natapov
@ 2012-11-28 23:30 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2012-11-28 23:30 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, Frederic Weisbecker, Li Zhong

On Wed, Nov 28, 2012 at 03:19:08PM +0200, Gleb Natapov wrote:
> As Frederic pointed idle_cpu() may return false even if async fault
> happened in the idle task if wake up is pending. In this case the code
> will try to put idle task to sleep. Fix this by using is_idle_task() to
> check for idle task.
> 
> Reported-by: Frederic Weisbecker <fweisbec@gmail.com>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-29  0:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28 13:19 [PATCH] KVM: use is_idle_task() instead of idle_cpu() to decide when to halt in async_pf Gleb Natapov
2012-11-28 23:30 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox