diff options
author | Peter Zijlstra <peterz@infradead.org> | 2023-05-26 12:23:48 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2023-06-26 11:14:18 +0200 |
commit | 54da6a0924311c7cf5015533991e44fb8eb12773 (patch) | |
tree | af497256995d40431b9c214e7faa45639bf3d991 /include/linux/sched | |
parent | 9a1f37ebcfe061721564042254719dc8fd5c9fa0 (diff) |
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/sched')
-rw-r--r-- | include/linux/sched/task.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index e0f5ac90a228..dd35ce28bb90 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -125,6 +125,8 @@ static inline void put_task_struct(struct task_struct *t) __put_task_struct(t); } +DEFINE_FREE(put_task, struct task_struct *, if (_T) put_task_struct(_T)) + static inline void put_task_struct_many(struct task_struct *t, int nr) { if (refcount_sub_and_test(nr, &t->usage)) |