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

TOMOYO Linux Cross Reference
Linux/kernel/locking/lglock.c

Version: ~ [ linux-5.14-rc1 ] ~ [ linux-5.13.1 ] ~ [ linux-5.12.16 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.49 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.131 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.197 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.239 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.275 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.275 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ 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 /* See include/linux/lglock.h for description */
  2 #include <linux/module.h>
  3 #include <linux/lglock.h>
  4 #include <linux/cpu.h>
  5 #include <linux/string.h>
  6 
  7 /*
  8  * Note there is no uninit, so lglocks cannot be defined in
  9  * modules (but it's fine to use them from there)
 10  * Could be added though, just undo lg_lock_init
 11  */
 12 
 13 void lg_lock_init(struct lglock *lg, char *name)
 14 {
 15         LOCKDEP_INIT_MAP(&lg->lock_dep_map, name, &lg->lock_key, 0);
 16 }
 17 EXPORT_SYMBOL(lg_lock_init);
 18 
 19 void lg_local_lock(struct lglock *lg)
 20 {
 21         arch_spinlock_t *lock;
 22 
 23         preempt_disable();
 24         lock_acquire_shared(&lg->lock_dep_map, 0, 0, NULL, _RET_IP_);
 25         lock = this_cpu_ptr(lg->lock);
 26         arch_spin_lock(lock);
 27 }
 28 EXPORT_SYMBOL(lg_local_lock);
 29 
 30 void lg_local_unlock(struct lglock *lg)
 31 {
 32         arch_spinlock_t *lock;
 33 
 34         lock_release(&lg->lock_dep_map, 1, _RET_IP_);
 35         lock = this_cpu_ptr(lg->lock);
 36         arch_spin_unlock(lock);
 37         preempt_enable();
 38 }
 39 EXPORT_SYMBOL(lg_local_unlock);
 40 
 41 void lg_local_lock_cpu(struct lglock *lg, int cpu)
 42 {
 43         arch_spinlock_t *lock;
 44 
 45         preempt_disable();
 46         lock_acquire_shared(&lg->lock_dep_map, 0, 0, NULL, _RET_IP_);
 47         lock = per_cpu_ptr(lg->lock, cpu);
 48         arch_spin_lock(lock);
 49 }
 50 EXPORT_SYMBOL(lg_local_lock_cpu);
 51 
 52 void lg_local_unlock_cpu(struct lglock *lg, int cpu)
 53 {
 54         arch_spinlock_t *lock;
 55 
 56         lock_release(&lg->lock_dep_map, 1, _RET_IP_);
 57         lock = per_cpu_ptr(lg->lock, cpu);
 58         arch_spin_unlock(lock);
 59         preempt_enable();
 60 }
 61 EXPORT_SYMBOL(lg_local_unlock_cpu);
 62 
 63 void lg_global_lock(struct lglock *lg)
 64 {
 65         int i;
 66 
 67         preempt_disable();
 68         lock_acquire_exclusive(&lg->lock_dep_map, 0, 0, NULL, _RET_IP_);
 69         for_each_possible_cpu(i) {
 70                 arch_spinlock_t *lock;
 71                 lock = per_cpu_ptr(lg->lock, i);
 72                 arch_spin_lock(lock);
 73         }
 74 }
 75 EXPORT_SYMBOL(lg_global_lock);
 76 
 77 void lg_global_unlock(struct lglock *lg)
 78 {
 79         int i;
 80 
 81         lock_release(&lg->lock_dep_map, 1, _RET_IP_);
 82         for_each_possible_cpu(i) {
 83                 arch_spinlock_t *lock;
 84                 lock = per_cpu_ptr(lg->lock, i);
 85                 arch_spin_unlock(lock);
 86         }
 87         preempt_enable();
 88 }
 89 EXPORT_SYMBOL(lg_global_unlock);
 90 

~ [ 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