Re: [kvm-unit-tests PATCH v2 7/8] arm64: microbench: Add time limit for each individual test
Hi Eric, On 7/2/2020 9:23 PM, Auger Eric wrote: Hi Jingyi, On 7/2/20 5:01 AM, Jingyi Wang wrote: Besides using separate running times parameter, we add time limit for loop_test to make sure each test should be done in a certain time(5 sec here). Signed-off-by: Jingyi Wang --- arm/micro-bench.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arm/micro-bench.c b/arm/micro-bench.c index 506d2f9..4c962b7 100644 --- a/arm/micro-bench.c +++ b/arm/micro-bench.c @@ -23,6 +23,7 @@ #include #define NTIMES (1U << 16) +#define MAX_NS (5 * 1000 * 1000 * 1000UL) static u32 cntfrq; @@ -258,22 +259,26 @@ static void loop_test(struct exit_test *test) uint64_t start, end, total_ticks, ntimes = 0; struct ns_time total_ns, avg_ns; + total_ticks = 0; if (test->prep) { if(!test->prep()) { printf("%s test skipped\n", test->name); return; } } - isb(); - start = read_sysreg(cntpct_el0); - while (ntimes < test->times) { + + while (ntimes < test->times && total_ns.ns < MAX_NS) { + isb(); + start = read_sysreg(cntpct_el0); test->exec(); + isb(); + end = read_sysreg(cntpct_el0); + ntimes++; + total_ticks += (end - start); + ticks_to_ns_time(total_ticks, &total_ns); } you don't need the ticks_to_ns_time(total_ticks, &total_ns); after the loop Okay, I forgot to delete it here. Thanks for reviewing. - isb(); - end = read_sysreg(cntpct_el0); - total_ticks = end - start; ticks_to_ns_time(total_ticks, &total_ns); avg_ns.ns = total_ns.ns / ntimes; avg_ns.ns_frac = total_ns.ns_frac / ntimes; Besides Reviewed-by: Eric Auger Thanks Eric . Thanks, Jingyi ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [kvm-unit-tests PATCH v2 7/8] arm64: microbench: Add time limit for each individual test
Hi Jingyi, On 7/2/20 5:01 AM, Jingyi Wang wrote: > Besides using separate running times parameter, we add time limit > for loop_test to make sure each test should be done in a certain > time(5 sec here). > > Signed-off-by: Jingyi Wang > --- > arm/micro-bench.c | 17 +++-- > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/arm/micro-bench.c b/arm/micro-bench.c > index 506d2f9..4c962b7 100644 > --- a/arm/micro-bench.c > +++ b/arm/micro-bench.c > @@ -23,6 +23,7 @@ > #include > > #define NTIMES (1U << 16) > +#define MAX_NS (5 * 1000 * 1000 * 1000UL) > > static u32 cntfrq; > > @@ -258,22 +259,26 @@ static void loop_test(struct exit_test *test) > uint64_t start, end, total_ticks, ntimes = 0; > struct ns_time total_ns, avg_ns; > > + total_ticks = 0; > if (test->prep) { > if(!test->prep()) { > printf("%s test skipped\n", test->name); > return; > } > } > - isb(); > - start = read_sysreg(cntpct_el0); > - while (ntimes < test->times) { > + > + while (ntimes < test->times && total_ns.ns < MAX_NS) { > + isb(); > + start = read_sysreg(cntpct_el0); > test->exec(); > + isb(); > + end = read_sysreg(cntpct_el0); > + > ntimes++; > + total_ticks += (end - start); > + ticks_to_ns_time(total_ticks, &total_ns); > } you don't need the ticks_to_ns_time(total_ticks, &total_ns); after the loop > - isb(); > - end = read_sysreg(cntpct_el0); > > - total_ticks = end - start; > ticks_to_ns_time(total_ticks, &total_ns); > avg_ns.ns = total_ns.ns / ntimes; > avg_ns.ns_frac = total_ns.ns_frac / ntimes; > Besides Reviewed-by: Eric Auger Thanks Eric ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [kvm-unit-tests PATCH v2 7/8] arm64: microbench: Add time limit for each individual test
On 7/2/2020 1:48 PM, Andrew Jones wrote: On Thu, Jul 02, 2020 at 11:01:31AM +0800, Jingyi Wang wrote: Besides using separate running times parameter, we add time limit for loop_test to make sure each test should be done in a certain time(5 sec here). Signed-off-by: Jingyi Wang --- arm/micro-bench.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arm/micro-bench.c b/arm/micro-bench.c index 506d2f9..4c962b7 100644 --- a/arm/micro-bench.c +++ b/arm/micro-bench.c @@ -23,6 +23,7 @@ #include #define NTIMES (1U << 16) +#define MAX_NS (5 * 1000 * 1000 * 1000UL) How about naming this something like "NS_5_SECONDS"? Done, thanks for reviewing. static u32 cntfrq; @@ -258,22 +259,26 @@ static void loop_test(struct exit_test *test) uint64_t start, end, total_ticks, ntimes = 0; struct ns_time total_ns, avg_ns; + total_ticks = 0; if (test->prep) { if(!test->prep()) { printf("%s test skipped\n", test->name); return; } } - isb(); - start = read_sysreg(cntpct_el0); - while (ntimes < test->times) { + + while (ntimes < test->times && total_ns.ns < MAX_NS) { + isb(); + start = read_sysreg(cntpct_el0); test->exec(); + isb(); + end = read_sysreg(cntpct_el0); + ntimes++; + total_ticks += (end - start); + ticks_to_ns_time(total_ticks, &total_ns); } - isb(); - end = read_sysreg(cntpct_el0); - total_ticks = end - start; ticks_to_ns_time(total_ticks, &total_ns); avg_ns.ns = total_ns.ns / ntimes; avg_ns.ns_frac = total_ns.ns_frac / ntimes; -- 2.19.1 Thanks, drew . ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [kvm-unit-tests PATCH v2 7/8] arm64: microbench: Add time limit for each individual test
On Thu, Jul 02, 2020 at 11:01:31AM +0800, Jingyi Wang wrote: > Besides using separate running times parameter, we add time limit > for loop_test to make sure each test should be done in a certain > time(5 sec here). > > Signed-off-by: Jingyi Wang > --- > arm/micro-bench.c | 17 +++-- > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/arm/micro-bench.c b/arm/micro-bench.c > index 506d2f9..4c962b7 100644 > --- a/arm/micro-bench.c > +++ b/arm/micro-bench.c > @@ -23,6 +23,7 @@ > #include > > #define NTIMES (1U << 16) > +#define MAX_NS (5 * 1000 * 1000 * 1000UL) How about naming this something like "NS_5_SECONDS"? > > static u32 cntfrq; > > @@ -258,22 +259,26 @@ static void loop_test(struct exit_test *test) > uint64_t start, end, total_ticks, ntimes = 0; > struct ns_time total_ns, avg_ns; > > + total_ticks = 0; > if (test->prep) { > if(!test->prep()) { > printf("%s test skipped\n", test->name); > return; > } > } > - isb(); > - start = read_sysreg(cntpct_el0); > - while (ntimes < test->times) { > + > + while (ntimes < test->times && total_ns.ns < MAX_NS) { > + isb(); > + start = read_sysreg(cntpct_el0); > test->exec(); > + isb(); > + end = read_sysreg(cntpct_el0); > + > ntimes++; > + total_ticks += (end - start); > + ticks_to_ns_time(total_ticks, &total_ns); > } > - isb(); > - end = read_sysreg(cntpct_el0); > > - total_ticks = end - start; > ticks_to_ns_time(total_ticks, &total_ns); > avg_ns.ns = total_ns.ns / ntimes; > avg_ns.ns_frac = total_ns.ns_frac / ntimes; > -- > 2.19.1 > > Thanks, drew ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm