On 11/10/21 7:50 PM, Jarkko Sakkinen wrote: >> CPU_A CPU_B >> ----- ----- >> spin_lock(&nodeA->lock); spin_lock(&nodeB->lock); >> ... ... >> sgx_nr_free_pages--; /* NOT SAFE */ sgx_nr_free_pages--; >> >> spin_unlock(&nodeA->lock); spin_unlock(&nodeB->lock); >> >> Maybe you missed the "NOT SAFE" hidden in the middle of >> the picture? >> >> -Tony > For me from that the ordering is not clear. E.g. compare to > https://www.kernel.org/doc/Documentation/memory-barriers.txt Jarkko, Reinette's explanation looks great to me. Something "protected" by two different locks is not protected at all. I don't think we need to fret over this too much. We don't need memory barriers or anything fancy at all to explain this.