On 01/07/2018 04:05 AM, Thomas Gleixner wrote:
static DEFINE_SPINLOCK(shadow_table_allocation_lock);
Now I have my suspicions why that's not needed anymore upstream but I'd let tglx explain better.
We got rid of all that runtime mapping stuff and the functions are only called from pti_init(). So the locking and therefor the tests above are not needed anymore. While at it we should mark all those function __init.
Yes, the double-test was part of an optimization where we attempted to avoid using a global spinlock in the fork() path. We would check for unallocated mid-level page tables without the lock. The lock was only taken it when we needed to *make* an entry to avoid collisions.
Now that it is all single-threaded, there is no chance of a collision, no need for a lock, and no need for the re-check.
^^ Just in case someone wants to include a bit more first-hand information about wtf that code was doing there.