kernel code native_queued_spin_lock_slowpath function

1.3k Views Asked by At

In the kernel code, I cannot find the definition of the native_queued_spin_lock_slowpath function, __pv_queued_spin_lock_slowpath is the same, where are these functions defined? I searched all the kernel code, but in vain

1

There are 1 best solutions below

0
On

The definition of native_queued_spin_lock_slowpath is in "kernel/locking/qspinlock.c", using a macro to change the name of queued_spin_lock_slowpath to native_queued_spin_lock_slowpath when CONFIG_PARAVIRT_SPINLOCKS is defined:

#ifdef CONFIG_PARAVIRT_SPINLOCKS
#define queued_spin_lock_slowpath   native_queued_spin_lock_slowpath
#endif

void __lockfunc queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
{

The definition of __pv_queued_spin_lock_slowpath is also in "kernel/locking/qspinlock.c" using the same renaming macro trick with a twist — The "qspinlock.c" file includes itself once more, using a guard macro _GEN_PV_LOCK_SLOWPATH to avoid infinite recursive inclusion:

#if !defined(_GEN_PV_LOCK_SLOWPATH) && defined(CONFIG_PARAVIRT_SPINLOCKS)
#define _GEN_PV_LOCK_SLOWPATH

#undef  queued_spin_lock_slowpath
#define queued_spin_lock_slowpath   __pv_queued_spin_lock_slowpath

#include "qspinlock_paravirt.h"
#include "qspinlock.c"

#endif