summaryrefslogtreecommitdiff
path: root/include/linux/srcu.h
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2023-05-26 13:23:48 +0300
committerPeter Zijlstra <peterz@infradead.org>2023-06-26 12:14:18 +0300
commit54da6a0924311c7cf5015533991e44fb8eb12773 (patch)
treeaf497256995d40431b9c214e7faa45639bf3d991 /include/linux/srcu.h
parent9a1f37ebcfe061721564042254719dc8fd5c9fa0 (diff)
downloadlinux-54da6a0924311c7cf5015533991e44fb8eb12773.tar.xz
locking: Introduce __cleanup() based infrastructure
Use __attribute__((__cleanup__(func))) to build: - simple auto-release pointers using __free() - 'classes' with constructor and destructor semantics for scope-based resource management. - lock guards based on the above classes. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20230612093537.614161713%40infradead.org
Diffstat (limited to 'include/linux/srcu.h')
-rw-r--r--include/linux/srcu.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 41c4b26fb1c1..b3b1def982dd 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -343,4 +343,9 @@ static inline void smp_mb__after_srcu_read_unlock(void)
/* __srcu_read_unlock has smp_mb() internally so nothing to do here. */
}
+DEFINE_LOCK_GUARD_1(srcu, struct srcu_struct,
+ _T->idx = srcu_read_lock(_T->lock),
+ srcu_read_unlock(_T->lock, _T->idx),
+ int idx)
+
#endif