blob: 6ef23b6d6639fffdbc36dd2e7ac73e46702842e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
#ifndef __BENCH_BPF_TIMING_H__
#define __BENCH_BPF_TIMING_H__
#include <stdbool.h>
#include <linux/types.h>
#include "bench.h"
#ifndef BENCH_NR_SAMPLES
#define BENCH_NR_SAMPLES 4096
#endif
#ifndef BENCH_NR_CPUS
#define BENCH_NR_CPUS 256
#endif
typedef void (*bpf_bench_run_fn)(void *ctx);
struct bpf_bench_timing {
__u64 (*samples)[BENCH_NR_SAMPLES]; /* skel->bss->timing_samples */
__u32 *idx; /* skel->bss->timing_idx */
volatile __u32 *timing_enabled; /* &skel->bss->timing_enabled */
volatile __u32 *batch_iters_bss; /* &skel->bss->batch_iters */
__u32 batch_iters;
__u32 target_samples;
__u32 nr_cpus;
int warmup_ticks;
bool done;
bool machine_readable;
};
#define BENCH_TIMING_INIT(t, skel, iters) do { \
(t)->samples = (skel)->bss->timing_samples; \
(t)->idx = (skel)->bss->timing_idx; \
(t)->timing_enabled = &(skel)->bss->timing_enabled; \
(t)->batch_iters_bss = &(skel)->bss->batch_iters; \
(t)->batch_iters = (iters); \
(t)->target_samples = 200; \
(t)->nr_cpus = env.nr_cpus; \
(t)->warmup_ticks = 0; \
(t)->done = false; \
(t)->machine_readable = false; \
} while (0)
void bpf_bench_timing_measure(struct bpf_bench_timing *t, struct bench_res *res);
void bpf_bench_timing_report(struct bpf_bench_timing *t, const char *name, const char *desc);
void bpf_bench_calibrate(struct bpf_bench_timing *t, bpf_bench_run_fn run_fn, void *ctx);
#endif /* __BENCH_BPF_TIMING_H__ */
|