Hi, IIUC, multiple JVM GC implementations use page protections for various thread synchronizations. Obviously this will rely on the behavior of mprotect in multiple thread WRT when the other thread can observe it when one thread removed certain access on a page, especially relative to other memory operations on either threads.
However, I was not able to find any good/explicit document on what the expected behavior is. What I do find (googling and on this list) is that the OS will issue a TLB shootdown if the page is cached on another thread and I suppose this is done in order to provide some ordering guarantee (otherwise it can probably just not do this and give a "relaxed" ording where different thread will observe this change in a random order after an arbitrary length of time) though I cannot find a good description of what the guarantee is. Maybe it'll be clearer with examples so let's suppose thread 1 changes a page p from PROT_READ to PROT_NONE and thread 2 has a load from this page. 1. If thread 2 fault, is it guaranteed that this happens after mprotect on thread 1? (Or in another word that sounds less weird, can it observer all load/stores on thread 1 happens before any operations on thread 2 after the fault?) 2. The other way around, if thread 2 didn't fault, is it guaranteed that the load happens before mprotect on thread 1? In another word, is it guaranteed that thread 1 will be able to oberve all memory operation thread 2 has done before the load, right after mprotect returns? 3. Does transitivity work? i.e. if therer's a thread 3 that's also loading from p, and if thread 2 faults on the load while thread 3 doesn't, can we say that thread 2 faults after the mprotect on thread 1 which is after the load on thread 3 and therefore the load (and fault) on thread 2 happens after the load on thread 3? Also link to my question on stackoverflow[1] Thanks, Yichao Yu [1] http://stackoverflow.com/questions/43722456/behavior-of-mprotect-with-multiple-threads -- You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
