Re: [PATCH tip/core/rcu 4/5] sys_membarrier: Add expedited option

From: Peter Zijlstra
Date: Thu Jul 27 2017 - 06:10:25 EST


On Thu, Jul 27, 2017 at 10:53:12AM +0200, Peter Zijlstra wrote:

> Another crazy idea is using madvise() for this. The new MADV_MEMBAR
> could revoke PROT_WRITE and PROT_READ for all extant PTEs. Then the
> tasks attempting access will fault and the fault handler can figure out
> if it still needs to issue a MB or not before reinstating the PTE.

Slight oversight is that page-tables are per process and we need a MB
per thread, so the fault handler can simply issue a private
sys_membarrier() to spread the joy around the local process.

> That is fully contained to the tasks actually having that map, and
> doesn't perturb anybody else.