Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
systemwide_memory_barrier: use madvise(MADV_DONTNEED) instead of mpro…
…tect() Like mprotect() with a permission reduction, madvise(MADV_DONTNEED) sends and IPI to all CPUs, inducing them to inject a memory barrier. Unlike mprotect(), madvise(MADV_DONTNEED) does not take the mmap semaphore, as it works on pages, not VMAs. That means that madvise(MADV_DONTNEED) calls can be executed concurrently without serialization by the kernel. Replace the calls to mprotect() by a call to madvise(MADV_DONTNEED) and drop the spinlock that guarded the whole thing, as we are now happy with concurrent execution of systemwide_memory_barrier. This reduces our CPU consumption when going to sleep on kernels that don't have sys_membarrier(). While it appears we're reducing the system call count as well, that's not true, as we have to fault in the page before the call to madvise(). In fact the fault is slower than the system call (but we still gain overall on large machines from reduced spinning). Credit to Aliaksei Kandratsenka/gperftools for the idea. Message-Id: <20180314121738.16336-1-avi@scylladb.com>
- Loading branch information