Thread (50 messages) 50 messages, 5 authors, 2012-12-18

Re: [RFC PATCH] Fix abnormal rcu dynticks_nesting values related to async page fault

From: Gleb Natapov <hidden>
Date: 2012-11-27 17:01:03
Also in: lkml
Subsystem: kvm paravirt (kvm/paravirt), the rest, x86 architecture (32-bit and 64-bit) · Maintainers: Paolo Bonzini, Linus Torvalds, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen

On Tue, Nov 27, 2012 at 05:51:12PM +0100, Frederic Weisbecker wrote:
2012/11/27 Gleb Natapov [off-list ref]:
quoted
On Tue, Nov 27, 2012 at 04:56:30PM +0100, Frederic Weisbecker wrote:
quoted
2012/11/27 Gleb Natapov [off-list ref]:
quoted
For KVM_PV_REASON_PAGE_NOT_PRESENT it behaves like an exception.
Ok.
There seem to be a bug in kvm_async_pf_task_wait(). Using
idle_cpu(cpu) to find out if the current task is the idle task may not
work if there is pending wake up. Me may schedule another task but
when that other task sleeps later we can't schedule back to idle until
the fault is completed.

The right way is to use is_idle_task(current)
But if there is pending wake up then scheduling to the waked up task is
exactly what we want.
Ok, but what if that task goes to sleep soon after beeing scheduled
and there is no other task on the runqueue and the page fault has not
been handled yet? The only thing you can do is to schedule the idle
task. But the idle task is waiting for the fault completion so you
can't do that.
Yes, I see now. So even though we have runnable task we can't schedule
away from idle task. Wouldn't the patch below solve Sasha's and Li's
RCU problems then (not even compiled):

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 4180a87..636800d 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -113,7 +113,7 @@ void kvm_async_pf_task_wait(u32 token)
 	int cpu, idle;
 
 	cpu = get_cpu();
-	idle = idle_cpu(cpu);
+	idle = is_idle_task(current);
 	put_cpu();
 
 	spin_lock(&b->lock);
@@ -247,10 +247,7 @@ do_async_page_fault(struct pt_regs *regs, unsigned long error_code)
 		break;
 	case KVM_PV_REASON_PAGE_NOT_PRESENT:
 		/* page is swapped out by the host. */
-		rcu_irq_enter();
-		exit_idle();
 		kvm_async_pf_task_wait((u32)read_cr2());
-		rcu_irq_exit();
 		break;
 	case KVM_PV_REASON_PAGE_READY:
 		rcu_irq_enter();

--
			Gleb.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help