Re: [RESEND PATCH v5 12/12] x86/mm: Enable preemption during flush_tlb_kernel_range

From: Sebastian Andrzej Siewior

Date: Fri May 22 2026 - 06:48:34 EST


On 2026-05-13 20:45:24 [+0800], Chuyi Zhou wrote:
> flush_tlb_kernel_range() is invoked when kernel memory mapping changes.
> On x86 platforms without the INVLPGB feature enabled, we need to send IPIs
> to every online CPU and synchronously wait for them to complete
> do_kernel_range_flush(). This process can be time-consuming due to factors
> such as a large number of CPUs or other issues (like interrupts being
> disabled). flush_tlb_kernel_range() always disables preemption, this may
> affect the scheduling latency of other tasks on the current CPU.
>
> Previous patch converted flush_tlb_info from per-cpu variable to on-stack
> variable. Additionally, it's no longer necessary to explicitly disable
> preemption before calling smp_call*() since they internally handles the
> preemption logic. Now it's safe to enable preemption during
> flush_tlb_kernel_range(). Additionally, in get_flush_tlb_info() use
> raw_smp_processor_id() to avoid warnings from check_preemption_disabled().

This is a bit odd. That smp_processor_id() is there to catch users with
enabled CPU migration. The only reason is the accounting done in
flush_tlb_func(). This raw_smp_processor_id() is only needed in
flush_tlb_kernel_range() which does not call flush_tlb_func(). This is
only statistics.

kernel_tlb_flush_all() does not need info at all.
kernel_tlb_flush_range() needs only start and end.

Oh well.

> Signed-off-by: Chuyi Zhou <zhouchuyi@xxxxxxxxxxxxx>

Sebastian