Re: PTE access rules & abstraction

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Benjamin Herrenschmidt
Date: Monday, September 22, 2008 - 2:05 pm

> I didn't change the function of that code when I made the change, so the

The bug may have been there, as I said, lots of unwritten rules...
sometimes broken. I'm not necessarily blaming you, but there have been
lots of changes to the PTE accessors over the last 2 years and not
always under any control :-)

In our case, the consequence is that the entry can be re-hashed because
the fact that it was already hashed and where it was hashed, which is
encoded in the PTE, gets lost by the clear. That means a potential
duplicate entry in the hash. A hard to hit race, but possible. Such a
condition is architecturally illegal and can cause things ranging from
incorrect translation to machine checks or checkstops (generally, on
LPAR machines, what will happen is your partition will get killed).

I know s390 has different issues & constraints. Martin told me during
Plumbers that mprotect was probably also broken for him.


Again, I'm not necessarily talking about the very latest round of
changes that you did here... More like a general approach as trying to
find a better overall interface to PTE access which currently is a total
mess as far as I'm concerned.


Well, unfortunately it's a lot more complex than that. For example, on
powerpc, we have to keep the hash table in sync and hash misses don't
take the PTE lock. They are aking to a non-atomic HW walk of the page
tables if you prefer.

So we must be careful about things like never replacing a PTE without
first flushing the hash table entry for the previous one (if it was
hashed). We also need to ensure we flush before we unlock, but we do
that by re-using the new lazy MMU hooks, as to not insert a new PTE
(which can potentially be hashed).

s390 has more complex sets of rules.


Well, for example, the generic copy-on-write case used to do just that,
ie set_pte_at() over the previous one, then flush. That is not good for
us and thus our set_pte_at() has special code to check whether there's
already a present PTE there and does a synchronous flush if there is.

However, that also changed, and nowadays, afaik, set_pte_at() is never
called anymore to override a already present PTE. 

We are doing some work on 32 bits code that will need similar
constraints and It would be nice if we could rely on the above and make
it part of the rules.


Not off hand, Nick ? How far did you go down that path ?


Well, part of the problem is that with the current interface, some
architectures are really mostly hacking around, and in some case,
possibly losing potential performance benefits by not having a slightly
more abstracted interface.

I don't think we should ditch the page tables in favor of some kind of
abstract memory objects, don't get me wrong :-) But having a more
generic higher level set of transactional interfaces to modifying and
flushing PTEs would probably help. Instead we are doing as-hoc hacks
left and right mostly based on how things work on x86.

Ben.


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
PTE access rules & abstraction, Benjamin Herrenschmidt, (Fri Sep 19, 10:42 am)
Re: PTE access rules & abstraction, Jeremy Fitzhardinge, (Sun Sep 21, 11:22 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Mon Sep 22, 2:05 pm)
Re: PTE access rules & abstraction, Nick Piggin, (Mon Sep 22, 8:10 pm)
Re: PTE access rules & abstraction, David Miller, (Mon Sep 22, 8:16 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Mon Sep 22, 10:31 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Mon Sep 22, 10:35 pm)
Re: PTE access rules & abstraction, Jeremy Fitzhardinge, (Mon Sep 22, 11:13 pm)
Re: PTE access rules & abstraction, Nick Piggin, (Mon Sep 22, 11:18 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Mon Sep 22, 11:49 pm)
Re: PTE access rules & abstraction, Nick Piggin, (Tue Sep 23, 2:50 am)
Re: PTE access rules & abstraction, peter, (Tue Sep 23, 4:54 am)
Re: PTE access rules & abstraction, Hugh Dickins, (Wed Sep 24, 11:45 am)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Wed Sep 24, 2:20 pm)
Re: PTE access rules & abstraction, Jeremy Fitzhardinge, (Wed Sep 24, 2:57 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Wed Sep 24, 3:07 pm)
Re: PTE access rules & abstraction, Martin Schwidefsky, (Wed Sep 24, 3:17 pm)
Re: PTE access rules & abstraction, Jeremy Fitzhardinge, (Wed Sep 24, 3:43 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Wed Sep 24, 3:53 pm)
Re: PTE access rules & abstraction, Hugh Dickins, (Wed Sep 24, 4:55 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Wed Sep 24, 6:04 pm)
Re: PTE access rules & abstraction, Jeremy Fitzhardinge, (Thu Sep 25, 11:15 am)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Thu Sep 25, 2:44 pm)
Re: PTE access rules & abstraction, Jeremy Fitzhardinge, (Thu Sep 25, 3:27 pm)
Re: PTE access rules & abstraction, Benjamin Herrenschmidt, (Thu Sep 25, 4:02 pm)