aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/preempt.h
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2023-05-26 12:23:48 +0200
committerPeter Zijlstra <peterz@infradead.org>2023-06-26 11:14:18 +0200
commit54da6a0924311c7cf5015533991e44fb8eb12773 (patch)
treeaf497256995d40431b9c214e7faa45639bf3d991 /include/linux/preempt.h
parentapparmor: Free up __cleanup() name (diff)
downloadwireguard-linux-54da6a0924311c7cf5015533991e44fb8eb12773.tar.xz
wireguard-linux-54da6a0924311c7cf5015533991e44fb8eb12773.zip
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/preempt.h')
-rw-r--r--include/linux/preempt.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index 0df425bf9bd7..1424670df161 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -8,6 +8,7 @@
*/
#include <linux/linkage.h>
+#include <linux/cleanup.h>
#include <linux/list.h>
/*
@@ -463,4 +464,8 @@ static __always_inline void preempt_enable_nested(void)
preempt_enable();
}
+DEFINE_LOCK_GUARD_0(preempt, preempt_disable(), preempt_enable())
+DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_notrace())
+DEFINE_LOCK_GUARD_0(migrate, migrate_disable(), migrate_enable())
+
#endif /* __LINUX_PREEMPT_H */