On Mon, Mar 17, 2025 at 3:50 PM Vadim Fedorenko <vadfed@xxxxxxxx> wrote: > > bpf_get_cpu_time_counter() is replaced with rdtsc instruction on x86_64. > Add tests to check that JIT works as expected. > > Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx> > Signed-off-by: Vadim Fedorenko <vadfed@xxxxxxxx> > --- > .../selftests/bpf/prog_tests/verifier.c | 2 + > .../selftests/bpf/progs/verifier_cpu_cycles.c | 104 ++++++++++++++++++ > 2 files changed, 106 insertions(+) > create mode 100644 tools/testing/selftests/bpf/progs/verifier_cpu_cycles.c > > diff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c > index e66a57970d28..d5e7e302a344 100644 > --- a/tools/testing/selftests/bpf/prog_tests/verifier.c > +++ b/tools/testing/selftests/bpf/prog_tests/verifier.c > @@ -102,6 +102,7 @@ > #include "verifier_xdp_direct_packet_access.skel.h" > #include "verifier_bits_iter.skel.h" > #include "verifier_lsm.skel.h" > +#include "verifier_cpu_cycles.skel.h" > #include "irq.skel.h" > > #define MAX_ENTRIES 11 > @@ -236,6 +237,7 @@ void test_verifier_bits_iter(void) { RUN(verifier_bits_iter); } > void test_verifier_lsm(void) { RUN(verifier_lsm); } > void test_irq(void) { RUN(irq); } > void test_verifier_mtu(void) { RUN(verifier_mtu); } > +void test_verifier_cpu_cycles(void) { RUN(verifier_cpu_cycles); } > > static int init_test_val_map(struct bpf_object *obj, char *map_name) > { > diff --git a/tools/testing/selftests/bpf/progs/verifier_cpu_cycles.c b/tools/testing/selftests/bpf/progs/verifier_cpu_cycles.c > new file mode 100644 > index 000000000000..5b62e3690362 > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/verifier_cpu_cycles.c > @@ -0,0 +1,104 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* Copyright (c) 2022 Meta Inc. */ botched copy paste.