Discussion:
[tz_vmm demo]- execution time
John David
2016-08-15 22:25:29 UTC
Permalink
Hello,

I want to measure execution time of a function in the secure world of
tz_vmm demo. I was wondering if I could use elapsed_ms( ) method in
timer_session to measure t1 and t2 so that I can take the difference (t2
-t1). Is there any other way?


Best regards,
John
Martin Stein
2016-08-18 07:35:00 UTC
Permalink
The function elapsed_ms gives you the time that has passed since the
creation of the corresponding timer session. So, yes, you can measure
time intervals with this if you use the same session for t1 and t2.

If you merely aim for performance comparison and are not interested in
concrete time values, you could also use the performance counter. The
performance counter is enabled by adding the specifier 'perf_counter' to
your <build_dir>/etc/specs.conf file. Once enabled, the performance
counter is fully accessible by the (secure world) userland.

Cheers,
Martin
Post by John David
Hello,
I want to measure execution time of a function in the secure world of
tz_vmm demo. I was wondering if I could use elapsed_ms( ) method in
timer_session to measure t1 and t2 so that I can take the difference (t2
-t1). Is there any other way?
Best regards,
John
------------------------------------------------------------------------------
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
------------------------------------------------------------------------------
John David
2016-09-19 23:46:17 UTC
Permalink
Dear Martin,

Thanks a lot for your answers.

I wanted to use the performance counter for more performance measurements
such as cache-misses, but I don't know how to access and use it in the
secure world userland. Could you please give me some hints? is there any
reading material on this?

Thanks,
Post by Martin Stein
The function elapsed_ms gives you the time that has passed since the
creation of the corresponding timer session. So, yes, you can measure
time intervals with this if you use the same session for t1 and t2.
If you merely aim for performance comparison and are not interested in
concrete time values, you could also use the performance counter. The
performance counter is enabled by adding the specifier 'perf_counter' to
your <build_dir>/etc/specs.conf file. Once enabled, the performance
counter is fully accessible by the (secure world) userland.
Cheers,
Martin
Post by John David
Hello,
I want to measure execution time of a function in the secure world of
tz_vmm demo. I was wondering if I could use elapsed_ms( ) method in
timer_session to measure t1 and t2 so that I can take the difference (t2
-t1). Is there any other way?
Best regards,
John
------------------------------------------------------------
------------------
Post by John David
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
------------------------------------------------------------
------------------
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
Martin Stein
2016-09-20 09:32:36 UTC
Permalink
Hi John,
Post by John David
Dear Martin,
Thanks a lot for your answers.
I wanted to use the performance counter for more performance
measurements such as cache-misses, but I don't know how to access and
I forgot to mention that you could also transform the performance
counter values into time values. On ARMv7 the counter counts every
single CPU cycle. Thus, you can use SECONDS = PERF_COUNTER / CPU_FREQUENCY.
Post by John David
use it in the secure world userland. Could you please give me some
If you have the performance counter enabled in the SPECS, you can
include 'trace/timestamp.h' and read a timestamp via
'Genode::Trace::Timestamp Genode::Trace::timestamp();'.
Post by John David
hints? is there any reading material on this?
I think [1] illustrates the use of the timestamp/performance counter
pretty good. The only document I could find to read about perfomance
counter access in general is the ARMv7 Manual [2] paragraph "C12.7
Counter access". If you have further questions, don't hesitate to ask.

Cheers,
Martin

[1] base-nova/src/test/platform/main.cc
[2]
http://liris.cnrs.fr/~mmrissa/lib/exe/fetch.php?media=armv7-a-r-manual.pdf

------------------------------------------------------------------------------
John David
2016-10-25 01:53:04 UTC
Permalink
Hi Martin,

Thanks a lot.
I have tried to measure and print the performance counter value on as
follows ( i.MX53QSB)


*Trace::Timestamp start = Trace::timestamp();*

* my_funciton();*


* Trace::Timestamp end = Trace::timestamp();
printf("CPU_cyces= %lu\n",(end-start));*

I have tried with *printf(%zu),* *printf(%llu)* and *printf("%"PRIu32) *format
but the maximum number of digits what I can get is 10. I wonder what format
can be used if the performance counter value is larger than 10 digits.
To calculate the elapsed time, I multiply the *CPU_cycles by 1 nanosecod
(ns) / cycle. *Is that right?

Thanks,
Post by Martin Stein
Hi John,
Post by John David
Dear Martin,
Thanks a lot for your answers.
I wanted to use the performance counter for more performance
measurements such as cache-misses, but I don't know how to access and
I forgot to mention that you could also transform the performance
counter values into time values. On ARMv7 the counter counts every
single CPU cycle. Thus, you can use SECONDS = PERF_COUNTER / CPU_FREQUENCY.
Post by John David
use it in the secure world userland. Could you please give me some
If you have the performance counter enabled in the SPECS, you can
include 'trace/timestamp.h' and read a timestamp via
'Genode::Trace::Timestamp Genode::Trace::timestamp();'.
Post by John David
hints? is there any reading material on this?
I think [1] illustrates the use of the timestamp/performance counter
pretty good. The only document I could find to read about perfomance
counter access in general is the ARMv7 Manual [2] paragraph "C12.7
Counter access". If you have further questions, don't hesitate to ask.
Cheers,
Martin
[1] base-nova/src/test/platform/main.cc
[2]
http://liris.cnrs.fr/~mmrissa/lib/exe/fetch.php?media=armv7-a-r-manual.pdf
------------------------------------------------------------
------------------
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
Martin Stein
2016-11-03 16:54:41 UTC
Permalink
Hi John,
Post by John David
Hi Martin,
Thanks a lot.
I have tried to measure and print the performance counter value on as
follows ( i.MX53QSB)
/Trace::Timestamp start = Trace::timestamp();
/
/ my_funciton();
/
/ Trace::Timestamp end = Trace::timestamp();
printf("CPU_cyces= %lu\n",(end-start));/
I have tried with /printf(%zu),/ /printf(%llu)/ and /printf("%"PRIu32)
/format but the maximum number of digits what I can get is 10. I wonder
what format can be used if the performance counter value is larger than
10 digits.
To calculate the elapsed time, I multiply the /CPU_cycles by 1
nanosecod (ns) / cycle. /Is that right?
Thanks,
As you are on an ARMv7, Timestamp is a uint32_t. So, %u is sufficient
but the value never exceeds ten digits as the maximum uint32_t
(0xffffffff) is 4294967295 decimal. So it seems that your performance
counter is to fast. You can, however, slow it down by counting only
every 64th CPU cycle. This is the kernel patch for that:

--- a/repos/base-hw/src/core/spec/arm_v7/perf_counter.cc
+++ b/repos/base-hw/src/core/spec/arm_v7/perf_counter.cc
@@ -37,6 +37,7 @@ struct Pmcr : Register<32>
E::set(v, 1);
P::set(v, 1);
C::set(v, 1);
+ D::set(v, 1);
return v;
}

Your CPU should work with 1GHz so one cycle should be one nanosecond,
right. But consider that with the above patch, one counter step extends
to 64 nanoseconds.

Cheers,
Martin

Loading...