[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cbxzo4e3zkr5pxxr4e2hualiucqudsizr2bmxgh3rr7yagcazd@fer5qemogcls>
Date: Fri, 8 Mar 2024 20:18:28 +0200
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Dave Hansen <dave.hansen@...el.com>
Cc: Andy Lutomirski <luto@...nel.org>, Yosry Ahmed <yosryahmed@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, the arch/x86 maintainers <x86@...nel.org>, linux-mm@...ck.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH 2/3] x86/mm: make sure LAM is up-to-date during
context switching
On Fri, Mar 08, 2024 at 07:23:58AM -0800, Dave Hansen wrote:
> On 3/7/24 17:34, Andy Lutomirski wrote:
> >> Fix this by making sure we write a new CR3 if LAM is not
> >> up-to-date. No problems were observed in practice, this was found
> >> by code inspection.
> > I think it should be fixed with a much bigger hammer: explicit IPIs.
> > Just don't ever let it get out of date, like install_ldt().
> I guess it matters whether the thing that matters is having a persistent
> inconsistency or a temporary one. IPIs will definitely turn a permanent
> one into a temporary one.
>
> But this is all easier to reason about if we can get rid of even the
> temporary inconsistency.
>
> Wouldn't this be even simpler than IPIs?
>
> static inline unsigned long set_tlbstate_lam_mode(struct mm_struct *mm)
> {
> unsigned long lam = READ_ONCE(mm->context.lam_cr3_mask);
>
> + /* LAM is for userspace only. Ignore it for kernel threads: */
> + if (tsk->flags & PF_KTHREAD)
> + return 0;
I like this approach. kthread_use_mm() WARNs if it called for
non-PF_KTHREAD task, so it should be okay.
I was worried that it would also exclude io_uring, but worker threads
don't have the flag set.
--
Kiryl Shutsemau / Kirill A. Shutemov
Powered by blists - more mailing lists