On Wed, Nov 19, 2025, at 10:31 AM, 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.
I read the code earlier today and I *think* it’s maybe okay. It’s quite
confusing that this thing is split among multiple patches, and the memory
ordering issues need comments.
The fact that the big flush is basically unconditional at this point helps. The
fact that it’s tangled up with CR3 even though the current implementation has
nothing to do with CR3 does not help.
I’m kind of with dhansen though — the fact that the implementation is so nasty
coupled with the fact that modern CPUs can do this in hardware makes the whole
thing kind of unpalatable.
>
> I still _really_ wish folks would be willing to get newer CPUs to get
> this behavior rather than going through all this complexity. RAR in
> particular was *specifically* designed to keep TLB flushing IPIs from
> blipping userspace for too long.
- Re: [RFC PATCH v7 29/31] x86/mm/pti: Implement... Valentin Schneider
- Re: [RFC PATCH v7 29/31] x86/mm/pti: Imple... Andy Lutomirski
- Re: [RFC PATCH v7 29/31] x86/mm/pti: I... Valentin Schneider
- [RFC PATCH v7 28/31] x86/mm/pti: Introduce a kernel/use... Valentin Schneider
- [PATCH v7 22/31] objtool: Add noinstr validation for st... Valentin Schneider
- [PATCH v7 17/31] x86/bugs: Mark cpu_buf_vm_clear key as... Valentin Schneider
- [PATCH v7 23/31] module: Add MOD_NOINSTR_TEXT mem_type Valentin Schneider
- [PATCH v7 11/31] loongarch/paravirt: Mark pv_steal_cloc... Valentin Schneider
- [RFC PATCH v7 30/31] x86/mm, mm/vmalloc: Defer kernel T... Valentin Schneider
- Re: [RFC PATCH v7 30/31] x86/mm, mm/vmalloc: Defer... Dave Hansen
- Re: [RFC PATCH v7 30/31] x86/mm, mm/vmalloc: D... Andy Lutomirski
- Re: [RFC PATCH v7 30/31] x86/mm, mm/vmalloc: D... Valentin Schneider
- Re: [RFC PATCH v7 30/31] x86/mm, mm/vmallo... Dave Hansen
- Re: [RFC PATCH v7 30/31] x86/mm, mm/vm... Valentin Schneider
- [RFC PATCH v7 31/31] x86/entry: Add an option to coales... Valentin Schneider
- [PATCH v7 24/31] context-tracking: Introduce work defer... Valentin Schneider
- [PATCH v7 25/31] context_tracking,x86: Defer kernel tex... Valentin Schneider
- [PATCH v7 18/31] x86/speculation/mds: Mark cpu_buf_idle... Valentin Schneider
- Re: [PATCH v7 00/31] context_tracking,x86: Defer some I... Andy Lutomirski
- Re: [PATCH v7 00/31] context_tracking,x86: Defer s... Andy Lutomirski
- Re: [PATCH v7 00/31] context_tracking,x86: Def... Paul E. McKenney
