tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: 2*(void *) atomic swap?



   Date: Thu, 30 Jul 2015 10:53:01 +0200
   From: Maxime Villard <max%m00nbsd.net@localhost>

   Do we have a magic function that can perform two atomic_swap_ptr()
   atomically?

Nope.

   I don't want to use a global lock; it may slow down the system..

Atomics are expensive enough -- each one requires talking to all the
CPUs -- that it's not likely to be all that much of a difference.  You
already have two atomic operations there, which is more than an
uncontended mutex_enter/mutex_exit involves on several architectures.

If this is a bottleneck, you could perhaps make the queue per-CPU.  It
looks like this is just a mechanism for delaying page frees so that
use-after-free will trap for longer before the page is reallocated, so
a per-CPU queue should be fine for that.


Home | Main Index | Thread Index | Old Index