provide ipipe_traceing via nucleus interface
PATCH 1/1 provide ipipe_traceing via nucleus interface
Hi,
having to load xeno_timerbench and to open its device just for triggering the I-pipe tracer was not a smart decision of mine. This patch makes is more comfortable to call the tracer from user space.
The latency test still traces fine, but cyclic suffers from some likely unrelated problem on my box (doesn't run at all, no xeno-thread except the main one) - needs a closer look later.
Jan
PS: I realised that rttesting.h and the related devices are not yet cleanly structured with respect to the RTDM profile idea (timer benchmark and switch test devices have no interface in common). I'm currently considering to merge all tests into a single device (maybe using multiple source files), also reducing the complexity for the test user. Comments are welcome.
asm-generic/syscall.h +7 -0
@@ -30,6 +30,13 @@#define __xn_sys_info 4/* xnshadow_get_info(muxid,&info) */ #define __xn_sys_arch 5/* r = xnarch_local_syscall(args) */ +#define __xn_sys_trace_begin 6/* ipipe_trace_begin(v) */ +#define __xn_sys_trace_end 7/* ipipe_trace_end(v) */ +#define __xn_sys_trace_freeze 8/* ipipe_trace_freeze(v) */ +#define __xn_sys_trace_specl 9/* ipipe_trace_special(special_id, v) */ +#define __xn_sys_trace_mreset 10/* ipipe_trace_max_reset() */ +#define __xn_sys_trace_freset 11/* ipipe_trace_frozen_reset() */ +#define XENOMAI_LINUX_DOMAIN 0#define XENOMAI_XENO_DOMAIN 1
rtdm/rttesting.h +5 -28
@@ -1,6 +1,6 @@/** * @file -* Real-Time Driver Model for Xenomai, benchmark device profile header +* Real-Time Driver Model for Xenomai, testing device profile header * * @note Copyright (C) 2005 Jan Kiszka <[email protected]> *
@@ -18,16 +18,16 @@* along with Xenomai; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -* @ingroup rtbenchmark +* @ingroup rttesting */ /*! * @ingroup profiles -* @defgroup rtbenchmark Timer benchmark Device +* @defgroup rttesting Testing Device * -* This group of devices is intended to provide in-kernel benchmark results. +* This group of devices is intended to provide in-kernel testing results. * Feel free to comment on this profile via the Xenomai mailing list -* ([email protected]) or directly to the author ([email protected]). @n +* ([email protected]) or directly to the author ([email protected]). @n * @n * * @par Device Characteristics
@@ -91,11 +91,6 @@ typedef struct rtbnch_overall_result {long *histogram_max; } rtbnch_overall_result_t; -typedef struct rtbnch_trace_special { -unsigned char id; -long v; -}rtbnch_trace_special_t ; -#define RTIOC_TYPE_BENCHMARK RTDM_CLASS_TESTING
@@ -120,24 +115,6 @@ typedef struct rtbnch_trace_special {#define RTBNCH_RTIOC_STOP_TMTEST \ _IOWR(RTIOC_TYPE_BENCHMARK, 0x11, struct rtbnch_overall_result) - -#define RTBNCH_RTIOC_BEGIN_TRACE \ - _IOW(RTIOC_TYPE_BENCHMARK, 0x20, long) - -#define RTBNCH_RTIOC_END_TRACE \ - _IOW(RTIOC_TYPE_BENCHMARK, 0x21, long) - -#define RTBNCH_RTIOC_FREEZE_TRACE \ - _IOW(RTIOC_TYPE_BENCHMARK, 0x22, long) - -#define RTBNCH_RTIOC_REFREEZE_TRACE \ - _IOW(RTIOC_TYPE_BENCHMARK, 0x23, long) - -#define RTBNCH_RTIOC_SPECIAL_TRACE \ - _IOW(RTIOC_TYPE_BENCHMARK, 0x24, unsigned char) - -#define RTBNCH_RTIOC_SPECIAL_TRACE_EX \ - _IOW(RTIOC_TYPE_BENCHMARK, 0x25, struct rtbnch_trace_special)/** @} */
nucleus/ipipe_trace.h +82 -0
82 lines not on this page · raw message
testsuite/latency/latency.c +3 -3
@@ -12,6 +12,7 @@#include <native/timer.h> #include <native/sem.h> #include <rtdm/rttesting.h> +#include <nucleus/ipipe_trace.h> RT_TASK latency_task, display_task;
@@ -130,8 +131,7 @@ void latency (void *cookie)if (freeze_max && (dt > gmaxjitter) && !(finished || warmup)) { -rt_dev_ioctl (benchdev,RTBNCH_RTIOC_REFREEZE_TRACE , -rt_timer_tsc2ns (dt)); +ipipe_trace_refreeze (rt_timer_tsc2ns (dt)); gmaxjitter = dt; }
@@ -545,7 +545,7 @@ int main (int argc, char **argv)mlockall (MCL_CURRENT |MCL_FUTURE ); -if ((test_mode !=USER_TASK ) || freeze_max) +if (test_mode !=USER_TASK ) {char devname[RTDM_MAX_DEVNAME_LEN ];
testsuite/cyclic/cyclictest.c +3 -15
@@ -36,7 +36,7 @@#include <sys/mman.h> #if IPIPE_TRACE -#include <rtdm/rttesting.h> +#include <nucleus/ipipe_trace.h> #endif /* Ugly, but .... */
@@ -93,11 +93,6 @@ struct thread_stat {static int test_shutdown;static int tracelimit =100000 ;static struct timespec start; -#if IPIPE_TRACE -static int benchdev =-1 ; -#else -#define benchdev -1 -#endif static inline void tsnorm (struct timespec *ts) {
@@ -266,7 +261,7 @@ void *timerthread(void *param) stat->max = diff;#if IPIPE_TRACE if (stat->traced) -ioctl (benchdev,RTBNCH_RTIOC_REFREEZE_TRACE , diff); +ipipe_trace_refreeze (diff);#endif }
@@ -411,9 +406,6 @@ static void process_options (int argc, cstatic void sighand (int sig) { -#if IPIPE_TRACE -close (benchdev); -#endif test_shutdown =1 ; }
@@ -469,10 +461,6 @@ int main(int argc, char **argv)if (!stat) goto outpar; -#if IPIPE_TRACE - benchdev =open ("rtbenchmark0" ,O_RDWR ); -#endif -clock_gettime (clocksources[clocksel], &start);for (i =0 ; i < num_threads; i++) {
@@ -500,7 +488,7 @@ int main(int argc, char **argv)pthread_attr_setstacksize (&thattr,131072 );pthread_create (&stat[i].thread, &thattr, timerthread, &par[i]); stat[i].threadstarted =1 ; - stat[i].traced = (i ==0 && benchdev >=0 ); + stat[i].traced = (i ==0 &&IPIPE_TRACE >0 ); }while (!test_shutdown) {
drivers/testing/timerbench.c +0 -55
73 lines not on this page · raw message
nucleus/shadow.c +53 -0
65 lines not on this page · raw message
Quoted 11 lines · Jan Kiszka
Hi,
having to load
xeno_timerbenchand to open its device just for triggering the I-pipe tracer was not a smart decision of mine. This patch makes is more comfortable to call the tracer from user space.Index:
include/asm-generic/syscall.h
===================================================================
asm-generic/syscall.h line 36
Quoted 7 lines
asm-generic/syscall.h +4
-0@@ -30,6 +30,13 @@#define __xn_sys_info 4/* xnshadow_get_info(muxid,&info) */ #define __xn_sys_arch 5/* r = xnarch_local_syscall(args) */ +#define __xn_sys_trace_begin 6/* ipipe_trace_begin(v) */ +#define __xn_sys_trace_end 7/* ipipe_trace_end(v) */ +#define __xn_sys_trace_freeze 8/* ipipe_trace_freeze(v) */ +#define __xn_sys_trace_specl 9/*
ipipe_trace_special(special_id, v) */
asm-generic/syscall.h line 39
Quoted 3 lines
asm-generic/syscall.h +3
-0+#define __xn_sys_trace_mreset 10/* ipipe_trace_max_reset() */ +#define __xn_sys_trace_freset 11/* ipipe_trace_frozen_reset() */ +
Ok for providing a tracer syscall from the nucleus table, but let's not pollute the namespace uselessly. We could just have a single tracer entry point, using the first arg as a function code for begin, end, freeze etc. Given that those ops are not on the fast path, there is nothing to gain in having them as separate calls. See __xn_sys_arch for ARM.
Quoted 3 lines
Index:
include/nucleus/ipipe_trace.h
===================================================================
This file should go to include/asm-generic/ since it depends on the underlying real-time enabler (i.e. I-pipe). This way, there would be no need to check for __XENO_SIM__.
Quoted 17 lines
nucleus/ipipe_trace.h +1
-0@@ -0,0 +1,82 @@ +/* Index:
src/testsuite/latency/latency.c
===================================================================testsuite/latency/latency.c +1
-0@@ -12,6 +12,7 @@#include <native/timer.h> #include <native/sem.h> #include <rtdm/rttesting.h> +#include <nucleus/ipipe_trace.h> RT_TASK latency_task, display_task;
testsuite/latency/latency.c void latency (void *cookie) · line 132
Quoted 2 lines
testsuite/latency/latency.c +0
-0@@ -130,8 +131,7 @@ void latency (void *cookie) if (freeze_max && (dt > gmaxjitter) && !(finished ||
warmup))
testsuite/latency/latency.c void latency (void *cookie) · line 134
Quoted 4 lines
testsuite/latency/latency.c +1
-2{ -rt_dev_ioctl (benchdev,RTBNCH_RTIOC_REFREEZE_TRACE , -rt_timer_tsc2ns (dt)); +ipipe_trace_refreeze (rt_timer_tsc2ns (dt));
I don't like the idea of spreading ipipe-something symbols and dependancies all over the entire source code including the generic one, especially when considering that at some point, we are going to have preempt-rt as the other possible real-time enabler, like Adeos is already used now. We should use something more generic. "tracer*" would be ok, I guess.
Signature · 1 line
Philippe.
Quoted 20 lines · Philippe Gerum
Quoted 11 lines · Jan Kiszka
Hi,
having to load
xeno_timerbenchand to open its device just for triggering the I-pipe tracer was not a smart decision of mine. This patch makes is more comfortable to call the tracer from user space.Index:
include/asm-generic/syscall.h
===================================================================asm-generic/syscall.h line 36
Quoted 7 lines
asm-generic/syscall.h +4
-0@@ -30,6 +30,13 @@#define __xn_sys_info 4/* xnshadow_get_info(muxid,&info) */ #define __xn_sys_arch 5/* r = xnarch_local_syscall(args) */ +#define __xn_sys_trace_begin 6/* ipipe_trace_begin(v) */ +#define __xn_sys_trace_end 7/* ipipe_trace_end(v) */ +#define __xn_sys_trace_freeze 8/* ipipe_trace_freeze(v) */ +#define __xn_sys_trace_specl 9/*
ipipe_trace_special(special_id, v)*/
Quoted 10 lines
asm-generic/syscall.h line 39
Quoted 3 lines
asm-generic/syscall.h +3
-0+#define __xn_sys_trace_mreset 10/* ipipe_trace_max_reset() */ +#define __xn_sys_trace_freset 11/* ipipe_trace_frozen_reset() */ +Ok for providing a tracer syscall from the nucleus table, but let's not pollute the namespace uselessly. We could just have a single tracer entry point, using the first arg as a function code for begin, end, freeze etc. Given that those ops are not on the fast path, there is nothing to gain in having them as separate calls. See
__xn_sys_archfor ARM.
Ok, will change.
Quoted 8 lines
Quoted 4 lines
Index:
include/nucleus/ipipe_trace.h
===================================================================This file should go to
include/asm-generic/since it depends on the underlying real-time enabler (i.e. I-pipe). This way, there would be no need to check for__XENO_SIM__.
Ok, but how is the user supposed to include the API then? Or can we drag it in implicitly somehow? That would be even nicer I think.
Quoted 26 lines
Quoted 18 lines
nucleus/ipipe_trace.h +1
-0@@ -0,0 +1,82 @@ +/* Index:
src/testsuite/latency/latency.c
===================================================================testsuite/latency/latency.c +1
-0@@ -12,6 +12,7 @@#include <native/timer.h> #include <native/sem.h> #include <rtdm/rttesting.h> +#include <nucleus/ipipe_trace.h> RT_TASK latency_task, display_task;testsuite/latency/latency.c void latency (void *cookie) · line 132
Quoted 2 lines
testsuite/latency/latency.c +0
-0@@ -130,8 +131,7 @@ void latency (void *cookie) if (freeze_max && (dt > gmaxjitter) && !(finished ||warmup))
testsuite/latency/latency.c void latency (void *cookie) · line 134
Quoted 4 lines
testsuite/latency/latency.c +1
-2{ -rt_dev_ioctl (benchdev,RTBNCH_RTIOC_REFREEZE_TRACE , -rt_timer_tsc2ns (dt)); +ipipe_trace_refreeze (rt_timer_tsc2ns (dt));
Quoted 7 lines
I don't like the idea of spreading ipipe-something symbols and dependancies all over the entire source code including the generic one, especially when considering that at some point, we are going to have preempt-rt as the other possible real-time enabler, like Adeos is already used now. We should use something more generic. "tracer*" would be ok, I guess.
I'm going to rescan Ingo's API to define a common interface where feasible (their own user space API seems to hide behind gettimeofday). BTW, looks like that tracer will not make into mainline soon - I noticed no further pushing recently.
Jan
Quoted 10 lines · Jan Kiszka
Quoted 6 lines
Quoted 2 lines
Index:
include/nucleus/ipipe_trace.h
===================================================================This file should go to
include/asm-generic/since it depends on the underlying real-time enabler (i.e. I-pipe). This way, there would be no need to check for__XENO_SIM__.Ok, but how is the user supposed to include the API then? Or can we drag it in implicitly somehow? That would be even nicer I think.
asm-generic/trace.h would be dragged in by include/asm-<arch>/hal.h, so that we get the proper double dependancy on both the architecture if it does provide the tracing feature, and also on the HAL which in turn requires the I-pipe.
Quoted 34 lines
Quoted 26 lines
Quoted 18 lines
nucleus/ipipe_trace.h +1
-0@@ -0,0 +1,82 @@ +/* Index:
src/testsuite/latency/latency.c
===================================================================testsuite/latency/latency.c +1
-0@@ -12,6 +12,7 @@#include <native/timer.h> #include <native/sem.h> #include <rtdm/rttesting.h> +#include <nucleus/ipipe_trace.h> RT_TASK latency_task, display_task;testsuite/latency/latency.c void latency (void *cookie) · line 132
Quoted 2 lines
testsuite/latency/latency.c +0
-0@@ -130,8 +131,7 @@ void latency (void *cookie) if (freeze_max && (dt > gmaxjitter) && !(finished ||warmup))
testsuite/latency/latency.c void latency (void *cookie) · line 134
Quoted 4 lines
testsuite/latency/latency.c +1
-2{ -rt_dev_ioctl (benchdev,RTBNCH_RTIOC_REFREEZE_TRACE , -rt_timer_tsc2ns (dt)); +ipipe_trace_refreeze (rt_timer_tsc2ns (dt));Quoted 7 lines
I don't like the idea of spreading ipipe-something symbols and dependancies all over the entire source code including the generic one, especially when considering that at some point, we are going to have preempt-rt as the other possible real-time enabler, like Adeos is already used now. We should use something more generic. "tracer*" would be ok, I guess.
Quoted 2 lines
I'm going to rescan Ingo's API to define a common interface where feasible (their own user space API seems to hide behind gettimeofday).
Thanks. We should definitely consider the underlying the real-time enabling technology Xenomai uses to run skins over as an interchangeable component.
Signature · 1 line
Philippe.
Quoted 6 lines · Philippe Gerum
Quoted 5 lines · Jan Kiszka
Quoted 5 lines
Quoted 2 lines
Index:
include/nucleus/ipipe_trace.h
===================================================================This file should go to
include/asm-generic/since it depends on the underlying real-time enabler (i.e. I-pipe). This way, there would be no need to check for__XENO_SIM__.
Quoted 8 lines
Quoted 3 lines
Ok, but how is the user supposed to include the API then? Or can we drag it in implicitly somehow? That would be even nicer I think.
asm-generic/trace.hwould be dragged in by include/asm-<arch>/hal.h, so that we get the proper double dependancy on both the architecture if it does provide the tracing feature, and also on the HAL which in turn requires the I-pipe.
Err, asm-<arch>/hal.h are pure kernel space headers, aren't they? But we need user space support as well.
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 18 lines
nucleus/ipipe_trace.h +1
-0@@ -0,0 +1,82 @@ +/* Index:
src/testsuite/latency/latency.c
===================================================================testsuite/latency/latency.c +1
-0@@ -12,6 +12,7 @@#include <native/timer.h> #include <native/sem.h> #include <rtdm/rttesting.h> +#include <nucleus/ipipe_trace.h> RT_TASK latency_task, display_task;testsuite/latency/latency.c void latency (void *cookie) · line 132
Quoted 2 lines
testsuite/latency/latency.c +0
-0@@ -130,8 +131,7 @@ void latency (void *cookie) if (freeze_max && (dt > gmaxjitter) && !(finished ||warmup))
testsuite/latency/latency.c void latency (void *cookie) · line 134
Quoted 4 lines
testsuite/latency/latency.c +1
-2{ -rt_dev_ioctl (benchdev,RTBNCH_RTIOC_REFREEZE_TRACE , -rt_timer_tsc2ns (dt)); +ipipe_trace_refreeze (rt_timer_tsc2ns (dt));I don't like the idea of spreading ipipe-something symbols and dependancies all over the entire source code including the generic one, especially when considering that at some point, we are going to have preempt-rt as the other possible real-time enabler, like Adeos is already used now. We should use something more generic. "tracer*" would be ok, I guess.
Quoted 7 lines
Quoted 2 lines
I'm going to rescan Ingo's API to define a common interface where feasible (their own user space API seems to hide behind gettimeofday).
Thanks. We should definitely consider the underlying the real-time enabling technology Xenomai uses to run skins over as an interchangeable component.
Unfortunately, Ingo's semantics are still quite different, partly incompatible (and unhandy as well - you can only trace one event, not the worst of a series like with the ipipe tracer). So we may need special user code to deal with these differences (like in cyclictest).
The most critical point is that Ingo's tracer nukes any timing guarantees when it fires. In contrast, the ipipe variant is RT-safe.
Anyway, let's try to go for these names and semantics (implementation:
ipipe / Ingo):
xntrace_max_begin(unsigned long v):
Mark the worst-case path beginning together with an arbitrary ulong. This path is separated from the user path below.
ipipe_trace_begin(v); / -
xntrace_max_end(unsigned long v):
Mark the worst-case path end together with an arbitrary ulong. The path with maximum length can be obtained from the logs.
ipipe_trace_end(v); / -
xntrace_user_start(void):
Start the user trace path. ipipe_trace_frozen_reset(); / user_trace_start();
xntrace_user_stop(unsigned long v):
Record an arbitrary ulong and stop the user trace path. The result is kept until the next invocation of xntrace_user_start() or xntrace_user_freeze(..., 0). ipipe_trace_freeze(v); / trace_special(v, 0, 0); user_trace_stop();
xntrace_user_freeze(unsigned long v, int once):
Record an arbitrary ulong and freeze the user trace path. If once is 0, the tracer keeps running after the freeze so that always the latest result can be obtained. Otherwise, this call is equivalent to xntrace_user_stop(v).
if (once)
xntrace_user_stop(v);
else
ipipe_trace_frozen_reset(); ipipe_trace_freeze(v) / -
xntrace_special(unsigned char id, unsigned long v):
Record an arbitrary uchar + ulong. ipipe_trace_special(id, v); / trace_special(v, 0, id);
xntrace_special_u64(unsigned char id, unsigned long long v):
Record an arbitrary uchar + u64. ipipe_trace_special(id, v >> 32); ipipe_trace_special(id, v & 0xFFFFFFFF); / trace_special_u64(v, id);
I choose xntrace as prefix because Xenomai is used here to provide an abstraction layer. Do you agree with the naming? Then this API should be made available symmetrically in both kernel and use space. Still, the question is via which header file...
Jan