public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
	[email protected], [email protected]
Subject: [PATCH 4/5] tasks: add put_task_struct_many()
Date: Tue, 14 Jul 2020 02:41:55 +0300	[thread overview]
Message-ID: <97d4ccff189d1df7e0a7656af40ced2642caef99.1594683622.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

put_task_struct_many() is as put_task_struct() but puts several
references at once. Useful to batching it.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 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 38359071236a..1301077f9c24 100644
--- a/include/linux/sched/task.h
+++ b/include/linux/sched/task.h
@@ -126,6 +126,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 (refcount_sub_and_test(nr, &t->usage))
+		__put_task_struct(t);
+}
+
 void put_task_struct_rcu_user(struct task_struct *task);
 
 #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
-- 
2.24.0


  parent reply	other threads:[~2020-07-13 23:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 23:41 [PATCH 0/5] batch completion + freeing improvements Pavel Begunkov
2020-07-13 23:41 ` [PATCH 1/5] io_uring: move io_req_complete() definition Pavel Begunkov
2020-07-13 23:41 ` [PATCH 2/5] io_uring: replace list with array for compl batch Pavel Begunkov
2020-07-13 23:41 ` [PATCH 3/5] io_uring: batch free in batched completion Pavel Begunkov
2020-07-13 23:41 ` Pavel Begunkov [this message]
2020-07-13 23:41 ` [PATCH 5/5] io_uring: batch put_task_struct() Pavel Begunkov
2020-07-14  1:08 ` [PATCH 0/5] batch completion + freeing improvements Jens Axboe
2020-07-14  7:15   ` Pavel Begunkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=97d4ccff189d1df7e0a7656af40ced2642caef99.1594683622.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox