linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: ppc-dev <linuxppc-dev@ozlabs.org>
Cc: Kumar Gala <galak@gate.crashing.org>, Paul Mackerras <paulus@samba.org>
Subject: fsl booke MM vs. SMP questions
Date: Mon, 21 May 2007 17:06:55 +1000	[thread overview]
Message-ID: <1179731215.32247.659.camel@localhost.localdomain> (raw)

Hi Folks !

I see that the fsl booke code has some #ifdef CONFIG_SMP bits here or
there, thus I suppose there are some SMP implementations of these
right ?

I'm having some serious issues trying to figure out how the TLB
management is made SMP safe however.

There are at least two main issues I've spotted at this point (there's
at least one more if there are HW threading, that is the TLB is shared
between logical processors, but I'll ignore that for now since I don't
think there is such a thing ... yet).

 - How do you guys shield PTE flushing vs. TLB misses on another CPU ?
That is, how do you prevent (if you do) the following scenario:

	cpu 0				cpu 1
	tlb miss			pte_clear (or similar)
	load PTE value
					write 0 to PTE (or replace)
					tlbviax (tlbie)
	tlbwe

That scenario, as you can see, will leave you with stale entries in the
TLB which will ultimately lead to all sort of unpleasant/random
behaviours.

If the answer is "oops ... we don't", then let's try to find out ways
out of that since I may have a similar issue in a not too distant
future :-) And I'm trying to find out a -fast- way to deal with that
without bloating the fast path. My main problem is that I want to avoid
taking a spin lock or equivalent atomic operation in the fast TLB reload
path (which would solve the problem) since lwarx/stwcx. are generally
real slow (hundreds of cycles on some processors).

 - I see that your TLB miss handle is using a non-atomic store to write
the _PAGE_ACCESSED bit back to the PTE. Don't you have a similar race
where something would do:

	cpu 0				cpu 1
	tlb miss			pte_clear (or similar)
	load PTE value
					write 0 to PTE (or replace)
	write back PTE with _PAGE_ACCESSED
	tlbwe

This is an extension of the previous race but it's a different problem
so I listed it separately. In that case, the problem is worse, since not
only you have a stale TLB entry, but you -also- have corrupted the linux
PTE by writing back the old value in it.

At this point, I'm afraid you may have no choice but going atomic, which
means paying the cost of lwarx/stwcx. on TLB misses, though if you have
a solution for the first problem, then you can avoid the atomic
operation in the second problem if _PAGE_ACCESSED is already set.

If not, you might have to use a _PAGE_BUSY bit similar to what 64 bits
uses as a per-PTE lock, or use mmu_hash_lock... Unless you come up with
a great idea or some HW black magic that makes the problem go away...

In any case, I'm curious about how you have or intend to solve that
since as I said above, I might be in a similar situation soon and am
trying to keep the TLB miss handler as fast as humanly possible.

Cheers,
Ben.

             reply	other threads:[~2007-05-21  7:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-21  7:06 Benjamin Herrenschmidt [this message]
     [not found] ` <1179741447.3660.7.camel@localhost.localdomain>
     [not found]   ` <1179742083.32247.689.camel@localhost.localdomain>
2007-05-21 11:37     ` fsl booke MM vs. SMP questions Dave Liu
2007-05-21 22:07       ` Benjamin Herrenschmidt
2007-05-22  3:09         ` Benjamin Herrenschmidt
2007-05-22 10:56           ` Dave Liu
2007-05-22 22:42             ` Benjamin Herrenschmidt
2007-05-23  2:38               ` Dave Liu
2007-05-23  3:08                 ` Benjamin Herrenschmidt
2007-05-28  9:05                   ` Liu Dave-r63238
2007-05-28  9:24                     ` Benjamin Herrenschmidt
2007-05-28  9:37                       ` Liu Dave-r63238
2007-05-28 10:00                         ` Benjamin Herrenschmidt
2007-05-28 10:23                           ` Gabriel Paubert
2007-05-28 10:28                             ` Benjamin Herrenschmidt
2007-05-22  8:46         ` Gabriel Paubert
2007-05-22  9:14           ` Benjamin Herrenschmidt
2007-05-22 10:02             ` Gabriel Paubert
2007-05-22 10:05               ` Benjamin Herrenschmidt
2007-05-23  9:12                 ` Gabriel Paubert
2007-05-22  3:03 ` Kumar Gala

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=1179731215.32247.659.camel@localhost.localdomain \
    --to=benh@kernel.crashing.org \
    --cc=galak@gate.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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).