17.1.3 Memory-Mapping Operations
It is perfectly legal to execute memory-mapping operations (including
mmap(), shmat(), and munmap() [Gro01])
within a lock-based critical section,
and, at least in principle, from within an RCU read-side critical section.
What happens when you attempt to execute such an operation from within
a transaction?
More to the point, what happens if the memory region being remapped
contains some variables participating in the current thread's transaction?
And what if this memory region contains variables participating in some
other thread's transaction?
It should not be necessary to consider cases where the TM system's
metadata is remapped, given that most locking primitives do not define
the outcome of remapping their lock variables.
Here are some memory-mapping options available to TM:
- Memory remapping is illegal within a transaction, and will result
in all enclosing transactions being aborted.
This does simplify things somewhat, but also requires that TM
interoperate with synchronization primitives that do tolerate
remapping from within their critical sections.
- Memory remapping is illegal within a transaction, and the
compiler is enlisted to enforce this prohibition.
- Memory mapping is legal within a transaction, but aborts all
other transactions having variables in the region mapped over.
- Memory mapping is legal within a transaction, but the mapping
operation will fail if the region being mapped overlaps with
the current transaction's footprint.
- All memory-mapping operations, whether within or outside a
transaction, check the region being mapped against the memory
footprint of all transactions in the system.
If there is overlap, then the memory-mapping operation fails.
- The effect of memory-mapping operations that overlap the memory
footprint of any transaction in the system is determined by the
TM conflict manager, which might dynamically determine whether
to fail the memory-mapping operation or abort any conflicting
transactions.
In is interesting to note that munmap() leaves the relevant region
of memory unmapped, which could have additional interesting
implications.17.2
Paul E. McKenney
2011-12-16