Skip to contentSkip to conversation

pagefault scalability alternative

PATCH [email protected] 2 participants 2 messages Aug 24, 2005 Memory management

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines

Atomicity can be guaranteed to some degree by using the present bit. For an update the present bit is first switched off. When a new value is written, it is first written in the piece of the entry that does not contain the pte bit which keeps the entry "not present". Last the word with the present bit is written.

Er... no. That would work if reads were atomic but writes weren't, but consider the following:

Reader Writer
Read first half
Write not-present bit
Write other half
Write present bit
Read second half

Voila, mismatched halves.
Unless you can give a guarantee on relative rates of progress, this can't be made to work.

The first obvious fix is to read the first half a second time and make sure it matches, retrying if not. The idea being that if the PTE changed from AB to AC, you might not notice the change, but it wouldn't matter, either. But that can fail, too, in sufficiently contrived circumstances:

Reader Writer
Read first half
Write not-present bit
Write other half
Write present bit
Read second half
Write not-present bit
Write other half
Write present bit
Read first half

If it changed from AB -> CD -> AE, you could read AD and not notice the problem.

And remember that relative rates in SMP systems are *usually* matched, but if you depend for correctness on a requirement that there be no interrupts, no NMI, no SMM, no I-cache miss, no I-cache parity error that triggered a re-fetch, no single-bit ECC error that triggered scrubbing, etc., then you're really tightly constraining the rest of the system.

Modern processors do all kinds of strange low-probability exception handling in order to speed up the common case.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 9 lines · On Wed, 24 Aug 2005 [email protected] wrote:
Quoted 5 lines

Atomicity can be guaranteed to some degree by using the present bit. For an update the present bit is first switched off. When a new value is written, it is first written in the piece of the entry that does not contain the pte bit which keeps the entry "not present". Last the word with the present bit is written.

Er... no. That would work if reads were atomic but writes weren't, but consider the following:

Quoted 8 lines

Reader Writer
Read first half
Write not-present bit
Write other half
Write present bit
Read second half

Voila, mismatched halves.

True. But not an issue for the patch under discussion.

In the case of the pt entries, all the writes are done within ptlock, and any reads done outside of ptlock (to choose which fault handler) are rechecked within ptlock before making any critical decision (in the PAE case which might have mismatched halves).

In the case of the pmd entries, a transition from present to not present is only made in free_pgtables (either while mmap_sem is held exclusively, or when the mm no longer has users), after unlinking from the prio_tree and anon_vma list by which kswapd might have got to them without mmap_sem (the unlinking taking the necessary locks). And pfn is never changed while present.

Hugh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>