tech-userlevel archive

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

Re: PATCH libatomic

On Thu, May 07, 2020 at 08:14:57PM -0400, Thor Lancelot Simon wrote:
> On Fri, May 08, 2020 at 01:51:16AM +0200, Kamil Rytarowski wrote:
> > A runtime detection could be a part of ifunc (is it ready for NetBSD?).
> > 
> > The standard C/C++ feature is to detect whether atomic operations are
> > real (lock-free) through atomic_is_lock_free(). This is a feature, not a
> > bug (as claimed by some people). atomic_is_lock_free() can be overloaded
> > in libatomic and detect CPU type in runtime and redirect either to real
> > CPU intrinsic of lock-free fallback.
> Not without performance penalty for every atomic operation, unless you propose
> to do this by binary patch as is done in the kernel.

ifuncs are pretty cool in enabling to do this everywhere, not just in a
kernel with binary patching.

It lets you write a "resolver function" which is run by in the
first run of the function, and it returns which variant of the function
should be used.

Home | Main Index | Thread Index | Old Index