~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/lglock.h

Version: ~ [ linux-5.6-rc7 ] ~ [ linux-5.5.11 ] ~ [ linux-5.4.27 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.112 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.174 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.217 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.217 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.82 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Specialised local-global spinlock. Can only be declared as global variables
  3  * to avoid overhead and keep things simple (and we don't want to start using
  4  * these inside dynamically allocated structures).
  5  *
  6  * "local/global locks" (lglocks) can be used to:
  7  *
  8  * - Provide fast exclusive access to per-CPU data, with exclusive access to
  9  *   another CPU's data allowed but possibly subject to contention, and to
 10  *   provide very slow exclusive access to all per-CPU data.
 11  * - Or to provide very fast and scalable read serialisation, and to provide
 12  *   very slow exclusive serialisation of data (not necessarily per-CPU data).
 13  *
 14  * Brlocks are also implemented as a short-hand notation for the latter use
 15  * case.
 16  *
 17  * Copyright 2009, 2010, Nick Piggin, Novell Inc.
 18  */
 19 #ifndef __LINUX_LGLOCK_H
 20 #define __LINUX_LGLOCK_H
 21 
 22 #include <linux/spinlock.h>
 23 #include <linux/lockdep.h>
 24 #include <linux/percpu.h>
 25 #include <linux/cpu.h>
 26 #include <linux/notifier.h>
 27 
 28 #ifdef CONFIG_SMP
 29 
 30 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 31 #define LOCKDEP_INIT_MAP lockdep_init_map
 32 #else
 33 #define LOCKDEP_INIT_MAP(a, b, c, d)
 34 #endif
 35 
 36 struct lglock {
 37         arch_spinlock_t __percpu *lock;
 38 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 39         struct lock_class_key lock_key;
 40         struct lockdep_map    lock_dep_map;
 41 #endif
 42 };
 43 
 44 #define DEFINE_LGLOCK(name)                                             \
 45         static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock)           \
 46         = __ARCH_SPIN_LOCK_UNLOCKED;                                    \
 47         struct lglock name = { .lock = &name ## _lock }
 48 
 49 #define DEFINE_STATIC_LGLOCK(name)                                      \
 50         static DEFINE_PER_CPU(arch_spinlock_t, name ## _lock)           \
 51         = __ARCH_SPIN_LOCK_UNLOCKED;                                    \
 52         static struct lglock name = { .lock = &name ## _lock }
 53 
 54 void lg_lock_init(struct lglock *lg, char *name);
 55 void lg_local_lock(struct lglock *lg);
 56 void lg_local_unlock(struct lglock *lg);
 57 void lg_local_lock_cpu(struct lglock *lg, int cpu);
 58 void lg_local_unlock_cpu(struct lglock *lg, int cpu);
 59 void lg_global_lock(struct lglock *lg);
 60 void lg_global_unlock(struct lglock *lg);
 61 
 62 #else
 63 /* When !CONFIG_SMP, map lglock to spinlock */
 64 #define lglock spinlock
 65 #define DEFINE_LGLOCK(name) DEFINE_SPINLOCK(name)
 66 #define DEFINE_STATIC_LGLOCK(name) static DEFINE_SPINLOCK(name)
 67 #define lg_lock_init(lg, name) spin_lock_init(lg)
 68 #define lg_local_lock spin_lock
 69 #define lg_local_unlock spin_unlock
 70 #define lg_local_lock_cpu(lg, cpu) spin_lock(lg)
 71 #define lg_local_unlock_cpu(lg, cpu) spin_unlock(lg)
 72 #define lg_global_lock spin_lock
 73 #define lg_global_unlock spin_unlock
 74 #endif
 75 
 76 #endif
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp