Re: [patch V4 part 5 07/31] x86/entry: Provide idtentry_entry/exit_cond_rcu()

From: Peter Zijlstra
Date: Mon May 11 2020 - 10:14:36 EST


On Mon, May 11, 2020 at 03:53:17PM +0200, Alexandre Chartre wrote:
>
> On 5/5/20 3:53 PM, Thomas Gleixner wrote:
> > The pagefault handler cannot use the regular idtentry_enter() because on
> > that invokes rcu_irq_enter() the pagefault was caused in the kernel.
>
> I am struggling to understand this part of the sentence: "because on
> that invokes rcu_irq_enter() the pagefault was caused in the kernel."
>
> Do you mean: "because that invokes rcu_irq_enter() if the pagefault was
> caused in the kernel." ?

The problem is that rcu_irq_enter() uses per-cpu state and expect
rcu_irq_exit() to be called on the very same cpu we did enter on.

However, #PF likes to schedule and breaks that expectation.

While there are more exceptions that schedule when from userspace, #PF
is the only one that does so when from kernel space, which makes is
'special'.