linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] completion: introduce complete_put() helper function
@ 2021-12-06  4:03 Yajun Deng
  2021-12-06  7:17 ` kernel test robot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yajun Deng @ 2021-12-06  4:03 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, bristot,
	linux-kernel, Yajun Deng

There are many cases where it is necessary to decrease refcount and test,
then called complete(). So introduce complete_put() helper function.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 kernel/sched/completion.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index a778554f9dad..dcb737f1edc2 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -38,6 +38,13 @@ void complete(struct completion *x)
 }
 EXPORT_SYMBOL(complete);
 
+void complete_put(refcount_t *r, struct completion *x)
+{
+	if (refcount_dec_and_test(r))
+		complete(x);
+}
+EXPORT_SYMBOL(complete_put);
+
 /**
  * complete_all: - signals all threads waiting on this completion
  * @x:  holds the state of this particular completion
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-06  9:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06  4:03 [PATCH] completion: introduce complete_put() helper function Yajun Deng
2021-12-06  7:17 ` kernel test robot
2021-12-06  7:37 ` kernel test robot
2021-12-06  8:34 ` Peter Zijlstra
2021-12-06  9:13 ` yajun.deng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).