Re: [PATCH v3 02/13] x86/xen: simplify flush_lazy_mmu()

From: Dave Hansen

Date: Wed Oct 15 2025 - 12:52:16 EST


On 10/15/25 01:27, Kevin Brodsky wrote:
> While at it, we can also avoid preempt_disable() if we are not
> in lazy MMU mode - xen_get_lazy_mode() should tolerate preemption.
...
> static void xen_flush_lazy_mmu(void)
> {
> - preempt_disable();
> -
> if (xen_get_lazy_mode() == XEN_LAZY_MMU) {
> - arch_leave_lazy_mmu_mode();
> - arch_enter_lazy_mmu_mode();
> + preempt_disable();
> + xen_mc_flush();
> + preempt_enable();
> }

But xen_get_lazy_mode() does:

this_cpu_read(xen_lazy_mode);

Couldn't preemption end up doing the 'xen_lazy_mode' read and the
xen_mc_flush() on different CPUs?

That seems like a problem. Is there a reason it's safe?