mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-13 20:15:20 -05:00
bpf: Factor out timer deletion helper
Move the timer deletion logic into a dedicated bpf_timer_delete() helper so it can be reused by later patches. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Link: https://lore.kernel.org/r/20260120-timer_nolock-v6-1-670ffdd787b4@meta.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
dd341eacdb
commit
c1f2c449de
@@ -1558,18 +1558,10 @@ static struct bpf_async_cb *__bpf_async_cancel_and_free(struct bpf_async_kern *a
|
||||
return cb;
|
||||
}
|
||||
|
||||
/* This function is called by map_delete/update_elem for individual element and
|
||||
* by ops->map_release_uref when the user space reference to a map reaches zero.
|
||||
*/
|
||||
void bpf_timer_cancel_and_free(void *val)
|
||||
static void bpf_timer_delete(struct bpf_hrtimer *t)
|
||||
{
|
||||
struct bpf_hrtimer *t;
|
||||
|
||||
t = (struct bpf_hrtimer *)__bpf_async_cancel_and_free(val);
|
||||
|
||||
if (!t)
|
||||
return;
|
||||
/* We check that bpf_map_delete/update_elem() was called from timer
|
||||
/*
|
||||
* We check that bpf_map_delete/update_elem() was called from timer
|
||||
* callback_fn. In such case we don't call hrtimer_cancel() (since it
|
||||
* will deadlock) and don't call hrtimer_try_to_cancel() (since it will
|
||||
* just return -1). Though callback_fn is still running on this cpu it's
|
||||
@@ -1618,6 +1610,21 @@ void bpf_timer_cancel_and_free(void *val)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called by map_delete/update_elem for individual element and
|
||||
* by ops->map_release_uref when the user space reference to a map reaches zero.
|
||||
*/
|
||||
void bpf_timer_cancel_and_free(void *val)
|
||||
{
|
||||
struct bpf_hrtimer *t;
|
||||
|
||||
t = (struct bpf_hrtimer *)__bpf_async_cancel_and_free(val);
|
||||
if (!t)
|
||||
return;
|
||||
|
||||
bpf_timer_delete(t);
|
||||
}
|
||||
|
||||
/* This function is called by map_delete/update_elem for individual element and
|
||||
* by ops->map_release_uref when the user space reference to a map reaches zero.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user