[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201012104508.GS2628@hirez.programming.kicks-ass.net>
Date: Mon, 12 Oct 2020 12:45:08 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jürgen Groß <jgross@...e.com>
Cc: xen-devel@...ts.xenproject.org, x86@...nel.org,
linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>, Andy Lutomirski <luto@...nel.org>
Subject: Re: [PATCH] x86/alternative: don't call text_poke() in lazy TLB mode
On Mon, Oct 12, 2020 at 12:26:06PM +0200, Jürgen Groß wrote:
> > > @@ -807,6 +807,15 @@ static inline temp_mm_state_t use_temporary_mm(struct mm_struct *mm)
> > > temp_mm_state_t temp_state;
> > > lockdep_assert_irqs_disabled();
> > > +
> > > + /*
> > > + * Make sure not to be in TLB lazy mode, as otherwise we'll end up
> > > + * with a stale address space WITHOUT being in lazy mode after
> > > + * restoring the previous mm.
> > > + */
> > > + if (this_cpu_read(cpu_tlbstate.is_lazy))
> > > + leave_mm(smp_processor_id());
> > > +
> > > temp_state.mm = this_cpu_read(cpu_tlbstate.loaded_mm);
> > > switch_mm_irqs_off(NULL, mm, current);
> >
> > Would it make sense to write it like:
> >
> > this_state.mm = this_cpu_read(cpu_tlbstate.is_lazy) ?
> > &init_mm : this_cpu_read(cpu_tlbstate.loaded_mm);
> >
> > Possibly with that wrapped in a conveniently named helper function.
>
> Fine with me, but I don't think it matters that much.
>
> For each batch of text_poke() it will be hit only once, and I'm not sure
> it is really a good idea to use the knowledge that leave_mm() is just a
> switch to init_mm here.
Yeah, I'm not sure either. But it's something I came up with when
looking at all this.
Andy, what's your preference?
Powered by blists - more mailing lists