diff options
author | Frederic Weisbecker <frederic@kernel.org> | 2024-06-21 11:15:59 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2024-07-09 13:26:32 +0200 |
commit | f409530e4db9dd11b88cb7703c97c8f326ff6566 (patch) | |
tree | 212a4af10e9204f1d4c0abf7cc5a01584347a993 /kernel | |
parent | 68cbd415dd4b9c5b9df69f0f091879e56bf5907a (diff) |
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>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240621091601.18227-3-frederic@kernel.org
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/task_work.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/task_work.c b/kernel/task_work.c index 54ac24059daa..2134ac8057a9 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() * |