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

From: Frederic Weisbecker
Date: Tue Nov 27 2012 - 11:29:02 EST


2012/11/27 Li Zhong <zhong@xxxxxxxxxxxxxxxxxx>:
> @@ -247,10 +247,17 @@ 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();
> + if (is_idle_task(current) && rcu_is_cpu_idle())

If the task is idle we can't schedule so I guess we don't need to call
rcu_idle_exit()

> + rcu_idle_exit();
> + else
> + rcu_user_exit();

rcu_user_exit() must be called in any case yeah.

> +
> exit_idle();
> kvm_async_pf_task_wait((u32)read_cr2());
> - rcu_irq_exit();
> +
> + if (is_idle_task(current) && rcu_is_cpu_idle())
> + rcu_idle_enter();
> +

I think that only adding rcu_user_exit() in the beginning and let the
rest as is (rcu_irq_enter() / rcu_irq_exit()) is enough. If we are
idle we won't schedule out. If we are not idle then we exit rcu user
mode if necessary and we can call rcu_irq_enter() in any case. If we
schedule we can safely cal rcu_irq_exit() even if somebody called
rcu_idle_enter() / rcu_idle_exit() since our matching rcu_irq_enter()
called before we scheduled. This works because we are not in RCU idle
mode and Paul says this is legal to have irq exit without matching irq
entry (his famous "vice-versa" on his previous email ;-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/