From: Marcelo Tosatti <marcelo.tosatti@cyclades•com>
To: Guillaume Autran <gautran@mrv•com>, '@logos.cnet
Cc: linux-ppc-embedded <linuxppc-embedded@ozlabs•org>
Subject: Re: [PATCH] 8xx: get_mmu_context() for (very) FEW_CONTEXTS and KERNEL_PREEMPT race/starvation issue
Date: Wed, 29 Jun 2005 12:54:45 -0300 [thread overview]
Message-ID: <20050629155445.GA3560@logos.cnet> (raw)
In-Reply-To: <42C2BF03.9000402@mrv.com>
Hi Guillaume,
On Wed, Jun 29, 2005 at 11:32:19AM -0400, Guillaume Autran wrote:
>
> Benjamin Herrenschmidt wrote:
>
> >On Tue, 2005-06-28 at 09:42 -0400, Guillaume Autran wrote:
> >
> >
> >>Hi,
> >>
> >>I happen to notice a race condition in the mmu_context code for the 8xx
> >>with very few context (16 MMU contexts) and kernel preemption enable. It
> >>is hard to reproduce has it shows only when many processes are
> >>created/destroy and the system is doing a lot of IRQ processing.
> >>
> >>In short, one process is trying to steal a context that is in the
> >>process of being freed (mm->context == NO_CONTEXT) but not completely
> >>freed (nr_free_contexts == 0).
> >>The steal_context() function does not do anything and the process stays
> >>in the loop forever.
> >>
> >>Anyway, I got a patch that fixes this part. Does not seem to affect
> >>scheduling latency at all.
> >>
> >>Comments are appreciated.
> >>
> >>
> >
> >Your patch seems to do a hell lot more than fixing this race ... What
> >about just calling preempt_disable() in destroy_context() instead ?
> >
> >
> I'm still a bit confused with "kernel preemption". One thing for sure is
> that disabling kernel preemption does indeed fix my problem.
> So, my question is, what if a task in the middle of being schedule gets
> preempted by an IRQ handler, where will this task restart execution ?
> Back at the beginning of schedule or where it left of ?
Execution is resumed exactly where it has been interrupted.
> The idea behind my patch was to get rid of that nr_free_contexts counter
> that is (I thing) redundant with the context_map.
Apparently its there to avoid the spinlock exactly on !FEW_CONTEXTS machines.
I suppose that what happens is that get_mmu_context() gets preempted after stealing
a context (so nr_free_contexts = 0), but before setting next_mmu_context to the
next entry
next_mmu_context = (ctx + 1) & LAST_CONTEXT;
So if the now running higher prio tasks calls switch_mm() (which is likely to happen)
it loops forever on atomic_dec_if_positive(&nr_free_contexts), while steal_context()
sees "mm->context == CONTEXT".
I think that you should try "preempt_disable()/preempt_enable" pair at entry and
exit of get_mmu_context() - I suppose around destroy_context() is not enough (you
can try that also).
spinlock ends up calling preempt_disable().
next prev parent reply other threads:[~2005-06-29 20:57 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-25 14:53 [PATCH] 8xx: map_page() skip pinned region and tlbie debugging aid Marcelo Tosatti
2005-06-25 22:24 ` Dan Malek
2005-06-26 14:30 ` Marcelo Tosatti
2005-06-27 13:39 ` Marcelo Tosatti
2005-06-27 20:46 ` Dan Malek
2005-06-28 6:30 ` Benjamin Herrenschmidt
2005-06-28 13:42 ` [PATCH] 8xx: get_mmu_context() for (very) FEW_CONTEXTS and KERNEL_PREEMPT race/starvation issue Guillaume Autran
2005-06-29 4:15 ` Benjamin Herrenschmidt
2005-06-29 15:32 ` Guillaume Autran
2005-06-29 15:54 ` Marcelo Tosatti [this message]
2005-06-29 21:25 ` Guillaume Autran
2005-06-29 17:00 ` Marcelo Tosatti
2005-06-29 23:26 ` Benjamin Herrenschmidt
2005-06-29 19:38 ` Marcelo Tosatti
2005-06-30 13:54 ` Guillaume Autran
2005-07-05 13:12 ` Guillaume Autran
2005-06-30 0:34 ` Eugene Surovegin
2005-06-29 23:24 ` Benjamin Herrenschmidt
2005-06-28 13:53 ` [PATCH] 8xx: map_page() skip pinned region and tlbie debugging aid Dan Malek
2005-06-28 23:47 ` Benjamin Herrenschmidt
2005-06-29 17:19 ` Marcelo Tosatti
2005-06-29 23:31 ` Benjamin Herrenschmidt
2005-06-30 18:05 ` Dan Malek
2005-06-30 23:29 ` Benjamin Herrenschmidt
2005-07-01 7:01 ` Pantelis Antoniou
2005-06-30 17:49 ` Dan Malek
2005-06-27 14:28 ` [PATCH] 8xx: tlbie debugging aid (try #2) Marcelo Tosatti
2005-06-27 20:18 ` Dan Malek
2005-06-27 14:56 ` Marcelo Tosatti
2005-06-27 20:53 ` Dan Malek
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=20050629155445.GA3560@logos.cnet \
--to=marcelo.tosatti@cyclades$(echo .)com \
--cc='@logos.cnet \
--cc=gautran@mrv$(echo .)com \
--cc=linuxppc-embedded@ozlabs$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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