File Index
Files and directories
Sign in
FILE

local_lock.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/local_lock.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _LINUX_LOCAL_LOCK_H
  3#define _LINUX_LOCAL_LOCK_H
  4
  5#include <linux/local_lock_internal.h>
  6
  7/**
  8 * local_lock_init - Runtime initialize a lock instance
  9 * @lock:	The lock variable
 10 */
 11#define local_lock_init(lock)		__local_lock_init(lock)
 12
 13/**
 14 * local_lock - Acquire a per CPU local lock
 15 * @lock:	The lock variable
 16 */
 17#define local_lock(lock)		__local_lock(this_cpu_ptr(lock))
 18
 19/**
 20 * local_lock_irq - Acquire a per CPU local lock and disable interrupts
 21 * @lock:	The lock variable
 22 */
 23#define local_lock_irq(lock)		__local_lock_irq(this_cpu_ptr(lock))
 24
 25/**
 26 * local_lock_irqsave - Acquire a per CPU local lock, save and disable
 27 *			 interrupts
 28 * @lock:	The lock variable
 29 * @flags:	Storage for interrupt flags
 30 */
 31#define local_lock_irqsave(lock, flags)				\
 32	__local_lock_irqsave(this_cpu_ptr(lock), flags)
 33
 34/**
 35 * local_unlock - Release a per CPU local lock
 36 * @lock:	The lock variable
 37 */
 38#define local_unlock(lock)		__local_unlock(this_cpu_ptr(lock))
 39
 40/**
 41 * local_unlock_irq - Release a per CPU local lock and enable interrupts
 42 * @lock:	The lock variable
 43 */
 44#define local_unlock_irq(lock)		__local_unlock_irq(this_cpu_ptr(lock))
 45
 46/**
 47 * local_unlock_irqrestore - Release a per CPU local lock and restore
 48 *			      interrupt flags
 49 * @lock:	The lock variable
 50 * @flags:      Interrupt flags to restore
 51 */
 52#define local_unlock_irqrestore(lock, flags)			\
 53	__local_unlock_irqrestore(this_cpu_ptr(lock), flags)
 54
 55/**
 56 * local_trylock_init - Runtime initialize a lock instance
 57 * @lock:	The lock variable
 58 */
 59#define local_trylock_init(lock)	__local_trylock_init(lock)
 60
 61/**
 62 * local_trylock - Try to acquire a per CPU local lock
 63 * @lock:	The lock variable
 64 *
 65 * The function can be used in any context such as NMI or HARDIRQ. Due to
 66 * locking constrains it will _always_ fail to acquire the lock in NMI or
 67 * HARDIRQ context on PREEMPT_RT.
 68 */
 69#define local_trylock(lock)		__local_trylock(this_cpu_ptr(lock))
 70
 71#define local_lock_is_locked(lock)	__local_lock_is_locked(lock)
 72
 73/**
 74 * local_trylock_irqsave - Try to acquire a per CPU local lock, save and disable
 75 *			   interrupts if acquired
 76 * @lock:	The lock variable
 77 * @flags:	Storage for interrupt flags
 78 *
 79 * The function can be used in any context such as NMI or HARDIRQ. Due to
 80 * locking constrains it will _always_ fail to acquire the lock in NMI or
 81 * HARDIRQ context on PREEMPT_RT.
 82 */
 83#define local_trylock_irqsave(lock, flags)			\
 84	__local_trylock_irqsave(this_cpu_ptr(lock), flags)
 85
 86DEFINE_GUARD(local_lock, local_lock_t __percpu*,
 87	     local_lock(_T),
 88	     local_unlock(_T))
 89DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
 90	     local_lock_irq(_T),
 91	     local_unlock_irq(_T))
 92DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
 93		    local_lock_irqsave(_T->lock, _T->flags),
 94		    local_unlock_irqrestore(_T->lock, _T->flags),
 95		    unsigned long flags)
 96
 97#define local_lock_nested_bh(_lock)				\
 98	__local_lock_nested_bh(this_cpu_ptr(_lock))
 99
100#define local_unlock_nested_bh(_lock)				\
101	__local_unlock_nested_bh(this_cpu_ptr(_lock))
102
103DEFINE_GUARD(local_lock_nested_bh, local_lock_t __percpu*,
104	     local_lock_nested_bh(_T),
105	     local_unlock_nested_bh(_T))
106
107#endif
~/ Read-only file preview.