locking: Introduce __cleanup() based infrastructure
authorPeter Zijlstra <peterz@infradead.org>
Fri, 26 May 2023 10:23:48 +0000 (12:23 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 26 Jun 2023 09:14:18 +0000 (11:14 +0200)
commit54da6a0924311c7cf5015533991e44fb8eb12773
treeaf497256995d40431b9c214e7faa45639bf3d991
parent9a1f37ebcfe061721564042254719dc8fd5c9fa0
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
16 files changed:
include/linux/cleanup.h [new file with mode: 0644]
include/linux/compiler-clang.h
include/linux/compiler_attributes.h
include/linux/device.h
include/linux/file.h
include/linux/irqflags.h
include/linux/mutex.h
include/linux/percpu.h
include/linux/preempt.h
include/linux/rcupdate.h
include/linux/rwsem.h
include/linux/sched/task.h
include/linux/slab.h
include/linux/spinlock.h
include/linux/srcu.h
scripts/checkpatch.pl