1 /* SPDX-License-Identifier: GPL-2.0 */
9 #include <bpf/libbpf.h>
12 #include <sys/syscall.h>
29 struct cpu_set prod_cpus
;
30 struct cpu_set cons_cpus
;
42 void *(*producer_thread
)(void *ctx
);
43 void *(*consumer_thread
)(void *ctx
);
44 void (*measure
)(struct bench_res
* res
);
45 void (*report_progress
)(int iter
, struct bench_res
* res
, long delta_ns
);
46 void (*report_final
)(struct bench_res res
[], int res_cnt
);
51 } __attribute__((aligned(128)));
53 extern struct env env
;
54 extern const struct bench
*bench
;
57 void hits_drops_report_progress(int iter
, struct bench_res
*res
, long delta_ns
);
58 void hits_drops_report_final(struct bench_res res
[], int res_cnt
);
60 static inline __u64
get_time_ns() {
63 clock_gettime(CLOCK_MONOTONIC
, &t
);
65 return (u64
)t
.tv_sec
* 1000000000 + t
.tv_nsec
;
68 static inline void atomic_inc(long *value
)
70 (void)__atomic_add_fetch(value
, 1, __ATOMIC_RELAXED
);
73 static inline void atomic_add(long *value
, long n
)
75 (void)__atomic_add_fetch(value
, n
, __ATOMIC_RELAXED
);
78 static inline long atomic_swap(long *value
, long n
)
80 return __atomic_exchange_n(value
, n
, __ATOMIC_RELAXED
);