Lines Matching defs:timer
17 struct bpf_timer timer;
81 static int timer_cb1(void *map, int *key, struct bpf_timer *timer)
84 * Once via array timer callback and once via lru timer callback
88 /* *key == 0 - the callback was called for array timer.
89 * *key == 4 - the callback was called from lru timer.
95 /* rearm array timer to be called again in ~35 seconds */
96 if (bpf_timer_start(timer, 1ull << 35, 0) != 0)
121 * element and force deletion of this timer
128 * which means that key/timer memory was reused
134 /* check that the timer was removed */
135 if (bpf_timer_cancel(timer) != -EINVAL)
165 * doesn't leak timer memory.
175 static int timer_error(void *map, int *key, struct bpf_timer *timer)
206 /* re-arm the timer again to execute after 1 usec */
207 bpf_timer_start(&val->timer, 1000, 0);
225 if (bpf_timer_cancel(&val->timer) != -EDEADLK)
228 /* delete this key and this timer anyway.
238 if (bpf_timer_start(&val->timer, 1000, 0) != -EINVAL)
246 if (bpf_timer_cancel(&val->timer) != -EDEADLK)
249 /* delete this key and this timer anyway.
266 if (bpf_timer_init(&val->timer, &hmap, CLOCK_BOOTTIME) != 0)
268 bpf_timer_set_callback(&val->timer, timer_cb2);
269 bpf_timer_start(&val->timer, 1000, 0);
273 if (bpf_timer_init(&val->timer, &hmap_malloc, CLOCK_BOOTTIME) != 0)
275 bpf_timer_set_callback(&val->timer, timer_cb2);
276 bpf_timer_start(&val->timer, 1000, 0);
291 bpf_timer_init(&val->timer, &hmap, CLOCK_BOOTTIME);
292 /* update the same key to free the timer */
298 bpf_timer_init(&val->timer, &hmap_malloc, CLOCK_BOOTTIME);
299 /* update the same key to free the timer */
303 * don't leak timer memory.
309 bpf_timer_init(&val->timer, &hmap, CLOCK_BOOTTIME);
314 bpf_timer_init(&val->timer, &hmap, CLOCK_BOOTTIME);
321 bpf_timer_init(&val->timer, &hmap_malloc, CLOCK_BOOTTIME);
326 bpf_timer_init(&val->timer, &hmap_malloc, CLOCK_BOOTTIME);
331 /* callback for absolute timer */
332 static int timer_cb3(void *map, int *key, struct bpf_timer *timer)
337 bpf_timer_start(timer, bpf_ktime_get_boot_ns() + 1000,
340 /* Re-arm timer ~35 seconds in future */
341 bpf_timer_start(timer, bpf_ktime_get_boot_ns() + (1ull << 35),
352 struct bpf_timer *timer;
356 timer = bpf_map_lookup_elem(&abs_timer, &key);
357 if (timer) {
358 if (bpf_timer_init(timer, &abs_timer, CLOCK_BOOTTIME) != 0)
360 bpf_timer_set_callback(timer, timer_cb3);
361 bpf_timer_start(timer, bpf_ktime_get_boot_ns() + 1000,
368 /* callback for pinned timer */
369 static int timer_cb_pinned(void *map, int *key, struct bpf_timer *timer)
384 struct bpf_timer *timer;
397 timer = bpf_map_lookup_elem(map, &key);
398 if (timer) {
399 if (bpf_timer_init(timer, map, CLOCK_BOOTTIME) != 0)
401 bpf_timer_set_callback(timer, timer_cb_pinned);
403 bpf_timer_start(timer, start_time + 1000, flags);
427 static int race_timer_callback(void *race_array, int *race_key, struct bpf_timer *timer)
429 bpf_timer_start(timer, 1000000, 0);
434 static int update_self_callback(void *map, int *key, struct bpf_timer *timer)
444 static int cancel_self_callback(void *map, int *key, struct bpf_timer *timer)
446 bpf_timer_cancel_async(timer);
460 struct bpf_timer *timer;
467 timer = bpf_map_lookup_elem(&race_array, &key);
468 if (!timer)
471 ret = bpf_timer_init(timer, &race_array, CLOCK_MONOTONIC);
476 bpf_timer_set_callback(timer, race_timer_callback);
478 bpf_timer_set_callback(timer, update_self_callback);
480 bpf_timer_set_callback(timer, cancel_self_callback);
482 bpf_timer_start(timer, 0, 0);
485 bpf_timer_cancel_async(timer);
487 bpf_timer_cancel(timer);