mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>,
	Andy Lutomirski <luto@kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>
Subject: Re: x86/pti: smp_processor_id() called while preemptible in resume-from-sleep
Date: Sat, 30 Dec 2017 21:28:03 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1712302121310.1899@nanos> (raw)
In-Reply-To: <CA+55aFybDbanqpA2eSy1oSCUj9a8RPuAgQYEZN8c+Rfege1a3Q@mail.gmail.com>

On Sat, 30 Dec 2017, Linus Torvalds wrote:
> On Sat, Dec 30, 2017 at 10:20 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> The __native_flush_tlb() function looks _very_ broken.
> 
> It does:
> 
>         invalidate_user_asid(this_cpu_read(cpu_tlbstate.loaded_mm_asid));
>         /*
>          * If current->mm == NULL then we borrow a mm which may change
>          * during a task switch and therefore we must not be preempted
>          * while we write CR3 back:
>          */
>         preempt_disable();
>         native_write_cr3(__native_read_cr3());
>         preempt_enable();
> 
> but why is that preempt-disabled region only around the cr3 write? The
> invalidate_user_asid() logic seems to be very CPU-sensitive too.
> 
> And even if there is some reason why invalidate_user_asid() really can
> do multiple different percpu accesses and it doesn't matter whether
> the thread is bouncing around on different cpu's while it does it,
> there doesn't seem any _reason_ not to just extend the preempt-disable
> over the whole series.
> 
> It really looks strange how it does multiple reads (and then a final
> write!) to percpu state, when the cpu can change in between.
> 
> So I'd suggest moving the preempt_disable() up to the top of that
> function,

That preempt_disable()/enable() was added with:

commit 5cf0791da5c162ebc14b01eb01631cfa7ed4fa6e
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Fri Aug 5 15:37:39 2016 +0200

    x86/mm: Disable preemption during CR3 read+write

So we need to look at that scenario before removing it.

Thanks,

	tglx

  parent reply	other threads:[~2017-12-30 20:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-30 13:29 Dominik Brodowski
2017-12-30 15:03 ` Thomas Gleixner
2017-12-30 15:30   ` Dominik Brodowski
2017-12-30 17:51     ` Dave Hansen
2017-12-30 18:21       ` Thomas Gleixner
2017-12-30 18:20     ` Thomas Gleixner
2017-12-30 18:40       ` Linus Torvalds
2017-12-30 19:03         ` Dave Hansen
2017-12-30 19:15           ` Linus Torvalds
2017-12-30 19:32             ` Andy Lutomirski
2017-12-30 19:41         ` Thomas Gleixner
2017-12-30 20:00           ` Linus Torvalds
2017-12-30 20:28         ` Thomas Gleixner [this message]
2017-12-30 20:45           ` Linus Torvalds
2017-12-30 20:47           ` Thomas Gleixner
2017-12-30 20:49             ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1712302121310.1899@nanos \
    --to=tglx@linutronix.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=luto@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®