From 4636c3a8b690c3568d8335b59f5db16ede36e4b8 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Thu, 15 Apr 2021 17:42:48 +0800 Subject: [PATCH] tasks: add put_task_struct_many() mainline inclusion from mainline-5.9-rc1 commit dd6f843a9fca8f225c86fee5f50da429c369c045 category: feature bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=27 CVE: NA --------------------------- put_task_struct_many() is as put_task_struct() but puts several references at once. Useful to batching it. Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Conflicts: include/linux/sched/task.h [ec1d281923cf ("sched/core: Convert task_struct.usage to refcount_t)" not merge] Signed-off-by: yangerkun Reviewed-by: zhangyi (F) Signed-off-by: Cheng Jian --- include/linux/sched/task.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index 44c6f15800ff..d744b385108e 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -98,6 +98,12 @@ static inline void put_task_struct(struct task_struct *t) __put_task_struct(t); } +static inline void put_task_struct_many(struct task_struct *t, int nr) +{ + if (atomic_sub_and_test(nr, &t->usage)) + __put_task_struct(t); +} + struct task_struct *task_rcu_dereference(struct task_struct **ptask); #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT -- GitLab