[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <xhsmh5xb3thh6.mognet@vschneid-thinkpadt14sgen2i.remote.csb>
Date: Fri, 21 Nov 2025 18:37:09 +0100
From: Valentin Schneider <vschneid@...hat.com>
To: Dave Hansen <dave.hansen@...el.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, rcu@...r.kernel.org, x86@...nel.org,
linux-arm-kernel@...ts.infradead.org, loongarch@...ts.linux.dev,
linux-riscv@...ts.infradead.org, linux-arch@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>, Andy Lutomirski <luto@...nel.org>, Peter
Zijlstra <peterz@...radead.org>, Arnaldo Carvalho de Melo
<acme@...nel.org>, Josh Poimboeuf <jpoimboe@...nel.org>, Paolo Bonzini
<pbonzini@...hat.com>, Arnd Bergmann <arnd@...db.de>, Frederic Weisbecker
<frederic@...nel.org>, "Paul E. McKenney" <paulmck@...nel.org>, Jason
Baron <jbaron@...mai.com>, Steven Rostedt <rostedt@...dmis.org>, Ard
Biesheuvel <ardb@...nel.org>, Sami Tolvanen <samitolvanen@...gle.com>,
"David S. Miller" <davem@...emloft.net>, Neeraj Upadhyay
<neeraj.upadhyay@...nel.org>, Joel Fernandes <joelagnelf@...dia.com>, Josh
Triplett <josh@...htriplett.org>, Boqun Feng <boqun.feng@...il.com>,
Uladzislau Rezki <urezki@...il.com>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, Mel Gorman <mgorman@...e.de>, Andrew
Morton <akpm@...ux-foundation.org>, Masahiro Yamada
<masahiroy@...nel.org>, Han Shen <shenhan@...gle.com>, Rik van Riel
<riel@...riel.com>, Jann Horn <jannh@...gle.com>, Dan Carpenter
<dan.carpenter@...aro.org>, Oleg Nesterov <oleg@...hat.com>, Juri Lelli
<juri.lelli@...hat.com>, Clark Williams <williams@...hat.com>, Yair
Podemsky <ypodemsk@...hat.com>, Marcelo Tosatti <mtosatti@...hat.com>,
Daniel Wagner <dwagner@...e.de>, Petr Tesarik <ptesarik@...e.com>,
Shrikanth Hegde <sshegde@...ux.ibm.com>
Subject: Re: [RFC PATCH v7 30/31] x86/mm, mm/vmalloc: Defer kernel TLB flush
IPIs under CONFIG_COALESCE_TLBI=y
On 19/11/25 10:31, Dave Hansen wrote:
> On 11/14/25 07:14, Valentin Schneider wrote:
>> +static bool flush_tlb_kernel_cond(int cpu, void *info)
>> +{
>> + return housekeeping_cpu(cpu, HK_TYPE_KERNEL_NOISE) ||
>> + per_cpu(kernel_cr3_loaded, cpu);
>> +}
>
> Is it OK that 'kernel_cr3_loaded' can be be stale? Since it's not part
> of the instruction that actually sets CR3, there's a window between when
> 'kernel_cr3_loaded' is set (or cleared) and CR3 is actually written.
>
> Is that OK?
>
> It seems like it could lead to both unnecessary IPIs being sent and for
> IPIs to be missed.
>
So the pattern is
SWITCH_TO_KERNEL_CR3
FLUSH
KERNEL_CR3_LOADED := 1
KERNEL_CR3_LOADED := 0
SWITCH_TO_USER_CR3
The 0 -> 1 transition has a window between the unconditional flush and the
write to 1 where a remote flush IPI may be omitted. Given that the write is
immediately following the unconditional flush, that would really be just
two flushes racing with each other, but I could punt the kernel_cr3_loaded
write above the unconditional flush.
The 1 -> 0 transition is less problematic, worst case a remote flush races
with the CPU returning to userspace and it'll get interrupted back to
kernelspace.
Powered by blists - more mailing lists