Re: x86/pti: smp_processor_id() called while preemptible in resume-from-sleep
From: Linus Torvalds
Date: Sat Dec 30 2017 - 15:45:45 EST
On Sat, Dec 30, 2017 at 12:28 PM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> That preempt_disable()/enable() was added with:
>
> commit 5cf0791da5c162ebc14b01eb01631cfa7ed4fa6e
> Author: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> Date: Fri Aug 5 15:37:39 2016 +0200
>
> x86/mm: Disable preemption during CR3 read+write
>
> So we need to look at that scenario before removing it.
Good point, but I think that was actually a mis-feature of the old
"__flush_tlb_up()" implementation that Andy got rid of in commit
ce4a4e565f52 ("x86/mm: Remove the UP asm/tlbflush.h code, always use
the (formerly) SMP code").
So the code sequence that that commit talks about no longer exists.
Instead, we now have the call to __flush_tlb() inside a
get_cpu/put_cpu, which is preempt-safe even on UP (despite the CPU
number obviously being fixed).
So I think Dave is right: we should just remove the
preempt_disable/endable. But adding a
WARN_ON_ONCE(preemptible());
might still be a good idea.
Linus