mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: davidm@hpl.hp.com
Cc: Ingo Molnar <mingo@elte.hu>,
	"David S. Miller" <davem@davemloft.net>,
	tony.luck@intel.com, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [patch] sched: unlocked context-switches
Date: Tue, 12 Apr 2005 12:12:45 +1000	[thread overview]
Message-ID: <1113271965.5090.24.camel@npiggin-nld.site> (raw)
In-Reply-To: <16987.7956.806699.617633@napali.hpl.hp.com>

On Mon, 2005-04-11 at 18:06 -0700, David Mosberger wrote:

> I had to refresh my memory with a quick Google search that netted [1]
> (look for "Disable interrupts during context switch").  Actually, it
> wasn't really a deadlock, but rather a livelock, since a CPU got stuck
> on an infinite page-not-present loop.
> 
> Fundamentally, the issue was that doing the switch_mm() and
> switch_to() with interrupts enabled opened a window during which you
> could get a call to flush_tlb_mm() (as a result of an IPI).  This, in
> turn, could end up activating the wrong MMU-context, since the action
> of flush_tlb_mm() depends on the value of current->active_mm.  The
> problematic sequence was:
> 
> 1) schedule() calls switch_mm() which calls activate_context() to
>    switch to the new address-space
> 2) IPI comes in and flush_tlb_mm(mm) gets called
> 3) "current" still points to old task and if "current->active_mm == mm",
>    activate_mm() is called for the old address-space, resetting the
>    address-space back to that of the old task
> 
> Now, Ingo says that the order is reversed with his patch, i.e.,
> switch_mm() happens after switch_to().  That means flush_tlb_mm() may
> now see a current->active_mm which hasn't really been activated yet.

If that did bother you, could you keep track of the actually
activated mm in your arch code? Or would that involve more arch
hooks and general ugliness in the scheduler?

Could you alternatively just disable interrupts across the switch?
I guess that would require a bit of #ifdefery in sched.c, which we
are trying to move away from, but it would be pretty minimal. Much
better than what is there now.

> That should be OK since it would just mean that we'd do an early (and
> duplicate) activate_context().  While it does not give me a warm and
> fuzzy feeling to have this inconsistent state be observable by
> interrupt-handlers (and, in particular, IPI-handlers), I don't see any
> problem with it off hand.
> 

IMO it *is* the direction we should move towards. That is,
liberating context switching from scheduler locking, and providing
a single set of semantics for the context switch hooks for all
architectures.

No rush, of course. But it would be good to get it in sooner
or later.

Nick



  reply	other threads:[~2005-04-12  2:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3R6Ir-89Y-23@gated-at.bofh.it>
2005-04-09  6:32 ` David Mosberger-Tang
2005-04-09  7:07   ` Ingo Molnar
2005-04-09  7:15     ` David Mosberger
2005-04-09 22:58       ` David S. Miller
2005-04-10  6:43         ` Ingo Molnar
2005-04-12  1:06           ` David Mosberger
2005-04-12  2:12             ` Nick Piggin [this message]
2005-04-12 17:14               ` David Mosberger
2005-04-13  3:26                 ` Nick Piggin
2005-04-12  6:42             ` Ingo Molnar
2005-04-12 17:15               ` David Mosberger
2005-04-08 18:38 Luck, Tony
2005-04-09  4:38 ` Ingo Molnar
2005-04-09  6:28   ` Nick Piggin
2005-04-09  6:55     ` Ingo Molnar
2005-04-09  7:11       ` Nick Piggin
2005-04-09  9:22   ` Benjamin Herrenschmidt
2005-04-09 22:46     ` David S. Miller
2005-04-10  7:23       ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2005-04-08 12:16 Ingo Molnar
2005-04-29  9:09 ` Andrew Morton

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=1113271965.5090.24.camel@npiggin-nld.site \
    --to=nickpiggin@yahoo.com.au \
    --cc=davem@davemloft.net \
    --cc=davidm@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tony.luck@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 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®