On Thu, Nov 16, 2023 at 12:53:55PM +0800, heqiong wrote: > Reducing the impact of the cntvct_el0 register and isb() operation > on microbenchmark test results to improve testing accuracy and reduce > latency in test results. > > Signed-off-by: heqiong <heqiong1557@xxxxxxxxxxxxxx> > --- > arm/micro-bench.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/arm/micro-bench.c b/arm/micro-bench.c > index fbe59d03..22408955 100644 > --- a/arm/micro-bench.c > +++ b/arm/micro-bench.c > @@ -24,7 +24,6 @@ > #include <asm/gic-v3-its.h> > #include <asm/timer.h> > > -#define NS_5_SECONDS (5 * 1000 * 1000 * 1000UL) > #define QEMU_MMIO_ADDR 0x0a000008 > > static u32 cntfrq; > @@ -346,17 +345,21 @@ static void loop_test(struct exit_test *test) > } > } > > - while (ntimes < test->times && total_ns.ns < NS_5_SECONDS) { > - isb(); > - start = read_sysreg(cntvct_el0); > + dsb(ish); > + isb(); > + start = read_sysreg(cntvct_el0); > + isb(); > + while (ntimes < test->times) { > test->exec(); > - isb(); > - end = read_sysreg(cntvct_el0); > > ntimes++; > - total_ticks += (end - start); > - ticks_to_ns_time(total_ticks, &total_ns); > } > + dsb(ish); > + isb(); > + end = read_sysreg(cntvct_el0); > + > + total_ticks = end - start; > + ticks_to_ns_time(total_ticks, &total_ns); > > if (test->post) { > test->post(ntimes, &total_ticks); > -- > 2.39.3 > Merged into https://gitlab.com/kvm-unit-tests/kvm-unit-tests master Thanks, drew