aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/lglock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/lglock.h')
-rw-r--r--include/linux/lglock.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/lglock.h b/include/linux/lglock.h
index c92ebd100d9b..6f035f635d0e 100644
--- a/include/linux/lglock.h
+++ b/include/linux/lglock.h
@@ -34,13 +34,30 @@
#endif
struct lglock {
+#ifdef CONFIG_PREEMPT_RT_FULL
+ struct rt_mutex __percpu *lock;
+#else
arch_spinlock_t __percpu *lock;
+#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lock_class_key lock_key;
struct lockdep_map lock_dep_map;
#endif
};
+#ifdef CONFIG_PREEMPT_RT_FULL
+# define DEFINE_LGLOCK(name) \
+ static DEFINE_PER_CPU(struct rt_mutex, name ## _lock) \
+ = __RT_MUTEX_INITIALIZER( name ## _lock); \
+ struct lglock name = { .lock = &name ## _lock }
+
+# define DEFINE_STATIC_LGLOCK(name) \
+ static DEFINE_PER_CPU(struct rt_mutex, name ## _lock) \
+ = __RT_MUTEX_INITIALIZER( name ## _lock); \
+ static struct lglock name = { .lock = &name ## _lock }
+
+#else
+
#define DEFINE_LGLOCK(name) \
static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock) \
= __ARCH_SPIN_LOCK_UNLOCKED; \
@@ -50,6 +67,7 @@ struct lglock {
static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock) \
= __ARCH_SPIN_LOCK_UNLOCKED; \
static struct lglock name = { .lock = &name ## _lock }
+#endif
void lg_lock_init(struct lglock *lg, char *name);
@@ -64,6 +82,12 @@ void lg_double_unlock(struct lglock *lg, int cpu1, int cpu2);
void lg_global_lock(struct lglock *lg);
void lg_global_unlock(struct lglock *lg);
+#ifndef CONFIG_PREEMPT_RT_FULL
+#define lg_global_trylock_relax(name) lg_global_lock(name)
+#else
+void lg_global_trylock_relax(struct lglock *lg);
+#endif
+
#else
/* When !CONFIG_SMP, map lglock to spinlock */
#define lglock spinlock