From: Pavel Begunkov asml.silence@gmail.com
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 asml.silence@gmail.com Signed-off-by: Jens Axboe axboe@kernel.dk
Conflicts: include/linux/sched/task.h [ec1d281923cf ("sched/core: Convert task_struct.usage to refcount_t)" not merge]
Signed-off-by: yangerkun yangerkun@huawei.com Reviewed-by: zhangyi (F) yi.zhang@huawei.com Signed-off-by: Cheng Jian cj.chengjian@huawei.com --- 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