linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	jmario@redhat.com, Peter Anvin <hpa@zytor.com>,
	dzickus@redhat.com, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] sched,x86: optimize switch_mm for multi-threaded workloads
Date: Wed, 31 Jul 2013 19:12:30 -0400	[thread overview]
Message-ID: <51F999DE.7080200@redhat.com> (raw)
In-Reply-To: <CA+55aFxKSEHSkdsCkTvjwwo4MnEpN0TwJrek2jd1QJCyUTb-=Q@mail.gmail.com>

On 07/31/2013 06:46 PM, Linus Torvalds wrote:
>
> On Jul 31, 2013 3:39 PM, "Rik van Riel" <riel@redhat.com
> <mailto:riel@redhat.com>> wrote:
>  >
>  > On 07/31/2013 06:21 PM, Linus Torvalds wrote:
>  >>
>  >> Ummm.. The race is to the testing of the bit, not setting. The testing
>  >> of the bit is not valid before we have set the tlb state, AFAIK.
>  >
>  >
>  > I believe the bit is cleared and set by the current CPU.
>
> Yes, but we need to be careful with interrupts.
>
>  > Interrupts are blocked inside switch_mm, so I think we
>  > are safe.
>
> Are they? I thought we removed all that.

context_switch() shows that the runqueue lock (which is an irq
lock) is released, and irqs re-enabled, by the next task, after
switch_to(), in finish_lock_switch(), called from finish_task_switch()

> Note that switch_mm gets called for activate_mm too, or something.

Good catch, though it looks like activate_mm is only called from
exec_mmap, with the new mm as its argument.  While the new mm can
have pages in memory yet, it has never been run so there should
be nothing in the TLB yet for the new mm.

This is subtler than I thought, but it does appear to be safe.

-- 
All rights reversed

  parent reply	other threads:[~2013-07-31 23:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-31 21:43 [PATCH] sched,x86: optimize switch_mm for multi-threaded workloads Rik van Riel
2013-07-31 21:46 ` Paul Turner
2013-07-31 22:07 ` Linus Torvalds
2013-07-31 22:16   ` Rik van Riel
     [not found]     ` <CA+55aFwj+6P4y8MgGTGbiK_EtfY7LJ_bL_7k9zFYLx4S8F0rJQ@mail.gmail.com>
2013-07-31 22:39       ` Rik van Riel
     [not found]         ` <CA+55aFxKSEHSkdsCkTvjwwo4MnEpN0TwJrek2jd1QJCyUTb-=Q@mail.gmail.com>
2013-07-31 23:12           ` Rik van Riel [this message]
2013-07-31 23:14             ` Paul Turner
2013-08-01  0:41               ` Linus Torvalds
2013-08-01  1:58                 ` Rik van Riel
2013-08-01  2:14                   ` Linus Torvalds
2013-08-01  2:14                 ` [PATCH -v2] " Rik van Riel
2013-08-01  2:25                   ` Linus Torvalds
2013-08-01  7:04                     ` Ingo Molnar
2013-08-02  9:07                   ` [tip:sched/core] sched/x86: Optimize switch_mm() " tip-bot for Rik van Riel
2013-08-02  9:12                     ` Ingo Molnar
2013-08-02 12:44                       ` Joe Mario
2013-08-03  1:18                       ` Greg KH
2013-08-01 15:37             ` [PATCH] sched,x86: optimize switch_mm " Jörn Engel
2013-08-01 17:45               ` Linus Torvalds
2013-08-01 17:54                 ` Jörn Engel

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=51F999DE.7080200@redhat.com \
    --to=riel@redhat.com \
    --cc=dzickus@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jmario@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).