1 // SPDX-License-Identifier: GPL-2.0
6 #include <bpf/bpf_helpers.h>
7 #include <bpf/bpf_tracing.h>
10 char _license[] SEC("license") = "GPL";
17 __uint(type, BPF_MAP_TYPE_ARRAY);
18 __uint(max_entries, 1);
20 __type(value, struct elem);
21 } timer1_map SEC(".maps");
24 __uint(type, BPF_MAP_TYPE_ARRAY);
25 __uint(max_entries, 1);
27 __type(value, struct elem);
28 } timer2_map SEC(".maps");
33 static int timer_cb1(void *map, int *k, struct elem *v)
35 struct bpf_timer *timer;
38 timer = bpf_map_lookup_elem(&timer2_map, &key);
40 timer2_err = bpf_timer_cancel(timer);
45 static int timer_cb2(void *map, int *k, struct elem *v)
47 struct bpf_timer *timer;
50 timer = bpf_map_lookup_elem(&timer1_map, &key);
52 timer1_err = bpf_timer_cancel(timer);
58 int timer1_prog(void *ctx)
60 struct bpf_timer *timer;
63 timer = bpf_map_lookup_elem(&timer1_map, &key);
65 bpf_timer_init(timer, &timer1_map, CLOCK_BOOTTIME);
66 bpf_timer_set_callback(timer, timer_cb1);
67 bpf_timer_start(timer, 1, BPF_F_TIMER_CPU_PIN);
74 int timer2_prog(void *ctx)
76 struct bpf_timer *timer;
79 timer = bpf_map_lookup_elem(&timer2_map, &key);
81 bpf_timer_init(timer, &timer2_map, CLOCK_BOOTTIME);
82 bpf_timer_set_callback(timer, timer_cb2);
83 bpf_timer_start(timer, 1, BPF_F_TIMER_CPU_PIN);