Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/spinlock.h
Show All 31 Lines | |||||
#define _LINUXKPI_LINUX_SPINLOCK_H_ | #define _LINUXKPI_LINUX_SPINLOCK_H_ | ||||
#include <asm/atomic.h> | #include <asm/atomic.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/kdb.h> | #include <sys/kdb.h> | ||||
#include <sys/proc.h> | |||||
#include <linux/compiler.h> | #include <linux/compiler.h> | ||||
#include <linux/rwlock.h> | #include <linux/rwlock.h> | ||||
#include <linux/bottom_half.h> | #include <linux/bottom_half.h> | ||||
#include <linux/lockdep.h> | #include <linux/lockdep.h> | ||||
typedef struct { | typedef struct { | ||||
struct mtx m; | struct mtx m; | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
#define spin_lock_nested(_l, _n) do { \ | #define spin_lock_nested(_l, _n) do { \ | ||||
if (SPIN_SKIP()) \ | if (SPIN_SKIP()) \ | ||||
break; \ | break; \ | ||||
mtx_lock_flags(&(_l)->m, MTX_DUPOK); \ | mtx_lock_flags(&(_l)->m, MTX_DUPOK); \ | ||||
local_bh_disable(); \ | local_bh_disable(); \ | ||||
} while (0) | } while (0) | ||||
#define __spin_trylock_nested(_l, _n) ({ \ | |||||
int __ret; \ | |||||
if (SPIN_SKIP()) { \ | |||||
__ret = 1; \ | |||||
} else { \ | |||||
__ret = mtx_trylock_flags(&(_l)->m, MTX_DUPOK); \ | |||||
if (likely(__ret != 0)) \ | |||||
local_bh_disable(); \ | |||||
} \ | |||||
__ret; \ | |||||
}) | |||||
#define spin_lock_irqsave(_l, flags) do { \ | #define spin_lock_irqsave(_l, flags) do { \ | ||||
hselasky: Is this a property of spin_lock_irqsave() only or should other spin_lock() functions be updated… | |||||
Done Inline ActionsAFAIK no, they should not. Ordinary spin_lock() requires fully preemptible context at least on RT-kernels. See PREEMPT_RT caveats section of https://www.kernel.org/doc/html/latest/locking/locktypes.html May be some other spin_lock_XXX functions e.g. spin_lock_irqsave_nested() can be updated too, but I did not dig in to this direction. wulf: AFAIK no, they should not. Ordinary spin_lock() requires fully preemptible context at least on… | |||||
Not Done Inline ActionsPlease updsate spin_lock_irqsave_nested() aswell and let's get moving :-) hselasky: Please updsate spin_lock_irqsave_nested() aswell and let's get moving :-) | |||||
(flags) = 0; \ | (flags) = 0; \ | ||||
if (unlikely(curthread->td_critnest != 0)) \ | |||||
while (!spin_trylock(_l)) {} \ | |||||
else \ | |||||
spin_lock(_l); \ | spin_lock(_l); \ | ||||
} while (0) | } while (0) | ||||
#define spin_lock_irqsave_nested(_l, flags, _n) do { \ | #define spin_lock_irqsave_nested(_l, flags, _n) do { \ | ||||
(flags) = 0; \ | (flags) = 0; \ | ||||
if (unlikely(curthread->td_critnest != 0)) \ | |||||
while (!__spin_trylock_nested(_l, _n)) {} \ | |||||
else \ | |||||
spin_lock_nested(_l, _n); \ | spin_lock_nested(_l, _n); \ | ||||
} while (0) | } while (0) | ||||
#define spin_unlock_irqrestore(_l, flags) do { \ | #define spin_unlock_irqrestore(_l, flags) do { \ | ||||
spin_unlock(_l); \ | spin_unlock(_l); \ | ||||
} while (0) | } while (0) | ||||
#ifdef WITNESS_ALL | #ifdef WITNESS_ALL | ||||
/* NOTE: the maximum WITNESS name is 64 chars */ | /* NOTE: the maximum WITNESS name is 64 chars */ | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |
Is this a property of spin_lock_irqsave() only or should other spin_lock() functions be updated aswell?