Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Mykyta Yatsenko and committed by
Alexei Starovoitov
c1f2c449 dd341eac

+18 -11
+18 -11
kernel/bpf/helpers.c
··· 1558 1558 return cb; 1559 1559 } 1560 1560 1561 - /* This function is called by map_delete/update_elem for individual element and 1562 - * by ops->map_release_uref when the user space reference to a map reaches zero. 1563 - */ 1564 - void bpf_timer_cancel_and_free(void *val) 1561 + static void bpf_timer_delete(struct bpf_hrtimer *t) 1565 1562 { 1566 - struct bpf_hrtimer *t; 1567 - 1568 - t = (struct bpf_hrtimer *)__bpf_async_cancel_and_free(val); 1569 - 1570 - if (!t) 1571 - return; 1572 - /* We check that bpf_map_delete/update_elem() was called from timer 1563 + /* 1564 + * We check that bpf_map_delete/update_elem() was called from timer 1573 1565 * callback_fn. In such case we don't call hrtimer_cancel() (since it 1574 1566 * will deadlock) and don't call hrtimer_try_to_cancel() (since it will 1575 1567 * just return -1). Though callback_fn is still running on this cpu it's ··· 1608 1616 } else { 1609 1617 bpf_timer_delete_work(&t->cb.delete_work); 1610 1618 } 1619 + } 1620 + 1621 + /* 1622 + * This function is called by map_delete/update_elem for individual element and 1623 + * by ops->map_release_uref when the user space reference to a map reaches zero. 1624 + */ 1625 + void bpf_timer_cancel_and_free(void *val) 1626 + { 1627 + struct bpf_hrtimer *t; 1628 + 1629 + t = (struct bpf_hrtimer *)__bpf_async_cancel_and_free(val); 1630 + if (!t) 1631 + return; 1632 + 1633 + bpf_timer_delete(t); 1611 1634 } 1612 1635 1613 1636 /* This function is called by map_delete/update_elem for individual element and