mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Frederic Weisbecker" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Frederic Weisbecker <frederic@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: perf/urgent] task_work: Introduce task_work_cancel() again
Date: Mon, 01 Jul 2024 07:14:52 -0000	[thread overview]
Message-ID: <171981809270.2215.3000722988563647462.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240621091601.18227-3-frederic@kernel.org>

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     74e45974c966fdecafb7149edb08a2f210e7ab60
Gitweb:        https://git.kernel.org/tip/74e45974c966fdecafb7149edb08a2f210e7ab60
Author:        Frederic Weisbecker <frederic@kernel.org>
AuthorDate:    Fri, 21 Jun 2024 11:15:59 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 25 Jun 2024 10:43:37 +02:00

task_work: Introduce task_work_cancel() again

Re-introduce task_work_cancel(), this time to cancel an actual callback
and not *any* callback pointing to a given function. This is going to be
needed for perf events event freeing.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240621091601.18227-3-frederic@kernel.org
---
 include/linux/task_work.h |  1 +
 kernel/task_work.c        | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/linux/task_work.h b/include/linux/task_work.h
index 23ab01a..26b8a47 100644
--- a/include/linux/task_work.h
+++ b/include/linux/task_work.h
@@ -31,6 +31,7 @@ int task_work_add(struct task_struct *task, struct callback_head *twork,
 struct callback_head *task_work_cancel_match(struct task_struct *task,
 	bool (*match)(struct callback_head *, void *data), void *data);
 struct callback_head *task_work_cancel_func(struct task_struct *, task_work_func_t);
+bool task_work_cancel(struct task_struct *task, struct callback_head *cb);
 void task_work_run(void);
 
 static inline void exit_task_work(struct task_struct *task)
diff --git a/kernel/task_work.c b/kernel/task_work.c
index 54ac240..2134ac8 100644
--- a/kernel/task_work.c
+++ b/kernel/task_work.c
@@ -136,6 +136,30 @@ task_work_cancel_func(struct task_struct *task, task_work_func_t func)
 	return task_work_cancel_match(task, task_work_func_match, func);
 }
 
+static bool task_work_match(struct callback_head *cb, void *data)
+{
+	return cb == data;
+}
+
+/**
+ * task_work_cancel - cancel a pending work added by task_work_add()
+ * @task: the task which should execute the work
+ * @cb: the callback to remove if queued
+ *
+ * Remove a callback from a task's queue if queued.
+ *
+ * RETURNS:
+ * True if the callback was queued and got cancelled, false otherwise.
+ */
+bool task_work_cancel(struct task_struct *task, struct callback_head *cb)
+{
+	struct callback_head *ret;
+
+	ret = task_work_cancel_match(task, task_work_match, cb);
+
+	return ret == cb;
+}
+
 /**
  * task_work_run - execute the works added by task_work_add()
  *

  reply	other threads:[~2024-07-01  7:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21  9:15 [PATCH 0/4 v4] perf: Fix leaked sigtrap events Frederic Weisbecker
2024-06-21  9:15 ` [PATCH 1/4] task_work: s/task_work_cancel()/task_work_cancel_func()/ Frederic Weisbecker
2024-07-01  7:14   ` [tip: perf/urgent] " tip-bot2 for Frederic Weisbecker
2024-07-09 11:42   ` [tip: perf/core] " tip-bot2 for Frederic Weisbecker
2024-06-21  9:15 ` [PATCH 2/4] task_work: Introduce task_work_cancel() again Frederic Weisbecker
2024-07-01  7:14   ` tip-bot2 for Frederic Weisbecker [this message]
2024-07-09 11:42   ` [tip: perf/core] " tip-bot2 for Frederic Weisbecker
2024-06-21  9:16 ` [PATCH 3/4] perf: Fix event leak upon exit Frederic Weisbecker
2024-07-01  7:14   ` [tip: perf/urgent] " tip-bot2 for Frederic Weisbecker
2024-07-09 11:42   ` [tip: perf/core] " tip-bot2 for Frederic Weisbecker
2024-06-21  9:16 ` [PATCH 4/4] perf: Fix event leak upon exec and file release Frederic Weisbecker
2024-07-01  7:14   ` [tip: perf/urgent] " tip-bot2 for Frederic Weisbecker
2024-07-09 11:41   ` [tip: perf/core] " tip-bot2 for Frederic Weisbecker
2024-06-25  8:43 ` [PATCH 0/4 v4] perf: Fix leaked sigtrap events Peter Zijlstra

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=171981809270.2215.3000722988563647462.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®