All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	Len Brown <lenb@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [patch] x86, tlb: switch cr3 in leave_mm() only when needed
Date: Thu, 22 Mar 2012 16:44:54 -0700	[thread overview]
Message-ID: <CA+55aFyf9RqAROx7t=CYUSGCDBXvv9z2c+LP1vRJjLU45_pD+Q@mail.gmail.com> (raw)
In-Reply-To: <1332459220.16101.144.camel@sbsiddha-desk.sc.intel.com>

On Thu, Mar 22, 2012 at 4:33 PM, Suresh Siddha
<suresh.b.siddha@intel.com> wrote:
>
> Currently leave_mm() unconditionally switches the cr3 to swapper_pg_dir.
> But there is no need to change the cr3, if we already left that mm.
>
> intel_idle() for example calls leave_mm() on every deep c-state entry where
> the CPU flushes the TLB for us. Similarly flush_tlb_all() was also calling
> leave_mm() whenever the TLB is in LAZY state. Both these paths will be
> improved with this change.

Hmm. If this is reasonably common (and intel_idle() certainly is),
maybe we shouldn't even do the "test_and_clear" RMW cycle.

We could do it with a read-only bit test (no races I can see - if it's
clear, it will stay clear), so we could do this with

    if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
        cpumask_clear_cpu(cpu,mm_cpumask(active_mm));
        load_cr3(swapper_pg_dir);
    }

instead? And avoid touching that "mm_cpumask" (and the atomic
serializing instruction) when not necessary?

                       Linus

  reply	other threads:[~2012-03-22 23:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 23:33 [patch] x86, tlb: switch cr3 in leave_mm() only when needed Suresh Siddha
2012-03-22 23:44 ` Linus Torvalds [this message]
2012-03-23  0:01   ` Suresh Siddha
2012-03-23  0:20     ` H. Peter Anvin
2012-03-23  0:37       ` Linus Torvalds
2012-03-23  0:51         ` Suresh Siddha
2012-03-23  8:37           ` Ingo Molnar
2012-03-26 22:47             ` Suresh Siddha
2012-03-26 22:47               ` H. Peter Anvin
2012-03-23  0:31     ` [tip:x86/mm] x86, tlb: Switch " tip-bot for Suresh Siddha

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='CA+55aFyf9RqAROx7t=CYUSGCDBXvv9z2c+LP1vRJjLU45_pD+Q@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=suresh.b.siddha@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.