diff options
| author | Thomas Zimmermann <[email protected]> | 2024-03-13 08:43:21 +0000 |
|---|---|---|
| committer | Thomas Zimmermann <[email protected]> | 2024-03-13 08:43:21 +0000 |
| commit | a2e7496b453eaa577425858d6f8b854800ed7343 (patch) | |
| tree | 35d05023d51161a28768a29115c8e03e65599fe5 /tools/testing/selftests/bpf/progs/timer.c | |
| parent | nouveau/dmem: handle kcalloc() allocation failure (diff) | |
| parent | nouveau: lock the client object tree. (diff) | |
| download | kernel-a2e7496b453eaa577425858d6f8b854800ed7343.tar.gz kernel-a2e7496b453eaa577425858d6f8b854800ed7343.zip | |
Merge drm/drm-fixes into drm-misc-fixes
Backmerging to sync before merging the patchset at [1].
[1] https://lore.kernel.org/all/[email protected]/
Signed-off-by: Thomas Zimmermann <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/timer.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/timer.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/progs/timer.c b/tools/testing/selftests/bpf/progs/timer.c index 8b946c8188c6..f615da97df26 100644 --- a/tools/testing/selftests/bpf/progs/timer.c +++ b/tools/testing/selftests/bpf/progs/timer.c @@ -51,7 +51,8 @@ struct { __uint(max_entries, 1); __type(key, int); __type(value, struct elem); -} abs_timer SEC(".maps"), soft_timer_pinned SEC(".maps"), abs_timer_pinned SEC(".maps"); +} abs_timer SEC(".maps"), soft_timer_pinned SEC(".maps"), abs_timer_pinned SEC(".maps"), + race_array SEC(".maps"); __u64 bss_data; __u64 abs_data; @@ -390,3 +391,34 @@ int BPF_PROG2(test5, int, a) return 0; } + +static int race_timer_callback(void *race_array, int *race_key, struct bpf_timer *timer) +{ + bpf_timer_start(timer, 1000000, 0); + return 0; +} + +SEC("syscall") +int race(void *ctx) +{ + struct bpf_timer *timer; + int err, race_key = 0; + struct elem init; + + __builtin_memset(&init, 0, sizeof(struct elem)); + bpf_map_update_elem(&race_array, &race_key, &init, BPF_ANY); + + timer = bpf_map_lookup_elem(&race_array, &race_key); + if (!timer) + return 1; + + err = bpf_timer_init(timer, &race_array, CLOCK_MONOTONIC); + if (err && err != -EBUSY) + return 1; + + bpf_timer_set_callback(timer, race_timer_callback); + bpf_timer_start(timer, 0, 0); + bpf_timer_cancel(timer); + + return 0; +} |
