tests: latency_measure: Use syscall to get timestamp Many architectures and platforms can not directly read a timestamp from userspace as the relevant MMIO registers are inaccessible. This necessitates that the timestamp be obtained by a system call. The additional overhead from these system calls can be taken into account and the recorded times adjusted depending upon whether the test occurred entirely within kernel space, entirely within user space, or a mix between the two. It is worth noting that when the test requires a mix of both user and kernel space threads, the overhead is estimated as the mean average of purely kernel threads and purely user threads overhead times. This might not be technically correct, but it ought to provide a reasonable enough approximation. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
diff --git a/tests/benchmarks/latency_measure/src/utils.h b/tests/benchmarks/latency_measure/src/utils.h index a946e38..62d2fb7 100644 --- a/tests/benchmarks/latency_measure/src/utils.h +++ b/tests/benchmarks/latency_measure/src/utils.h
@@ -19,6 +19,12 @@ #define START_STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACK_SIZE) #define ALT_STACK_SIZE (512 + CONFIG_TEST_EXTRA_STACK_SIZE) +#ifdef CONFIG_USERSPACE +#define BENCH_BMEM K_APP_BMEM(bench_mem_partition) +#else +#define BENCH_BMEM +#endif + struct timestamp_data { uint64_t cycles; timing_t sample; @@ -33,6 +39,10 @@ extern struct k_sem pause_sem; extern struct timestamp_data timestamp; +#ifdef CONFIG_USERSPACE +extern uint64_t user_timestamp_overhead; +#endif +extern uint64_t timestamp_overhead; extern int error_count;