Various refactoring and new IRQ test
cover Various refactoring and new IRQ test
Hi,
this series of patches motivated me to dive deeper into the quilt usage. So, if anything pops up brokenly on the list, blame it on my inability to use this nice tool. But let's go to business:
I've refactored the I-pipe tracer interface (i.e reworked my previous xn_sys_ipipe_trace.patch), and also tried to cleanup and restructure the RTDM testing device profile. Along this way, a few smaller improvements (at least as I see them) were added, check the patch headers. And, finally, I would like to introduce a new benchmarking tool, irqbench, for analysing external IRQ latencies.
Some remarks on irqbench: it's "version 2" of Fu's irLat test which he used for comparisons between Xenomai and preempt-rt. "Version 2" means I picked up his good ideas but went for a re-write in order to integrate it cleanly in the RTDM concept, to improve its convenience (pure user-space measurement tool), and to add I-pipe tracer support =8). [Fu, porting the kernel driver to preempt-rt should be straightforward, and all user-mode tools should be directly reusable...]
The test works over null modem (RS232) or parallel port link. Ok, the latter only works in theory; it's absolutely untested and badly hacked together. If anyone is interested in soldering some parallel cable together (maybe a laplink cable could be reused as well, haven't thought about this), let me know. Even more welcome would be patches to make the parallel test work as well!
The output of irqbench is fairly primitive so far. The reason is that I would rather like to motivate a discussion about and development of a generic latency measuring and evaluation library (or interface+tools). Also, now that the funny part is hacked, I prefer to leave the real work to others. :)
My consideration: we have the timer benchmark (latency), the switch test, and now also this IRQ latency test. All tests consist of measuring some interval, analysing its minimum, maximum, and average, generating histograms, maybe one day even writing logs to disk or plotting some diagrams, and so forth. There is so much in common that we should unify this, also to simplify the automated tests evaluation. I'm specifically counting on our test team here ;), but any contribution is welcome.
Jan
--
PATCH 1/6 Refactor tracer API
This patch encapsulates the I-pipe tracer facilities more cleanly according to the Xenomai layers. The changes are propagated to all current ipipe_trace_xxx users. Furthermore, the patch introduces a user-space inline API to invoke the tracer without the previous need to go through xeno_timerbench.
--- include/asm-generic/hal.h | 83 ++++++++++++++++++++++++++++++++ include/asm-generic/syscall.h | 1 include/asm-generic/system.h | 19 ++++--- include/asm-sim/system.h | 13 ++++- include/asm-uvm/system.h | 13 ++++- include/nucleus/assert.h | 4 - include/nucleus/trace.h | 98 ++++++++++++++++++++++++++++++++++++++ include/nucleus/types.h | 2 include/rtdm/rttesting.h | 33 +----------- ksrc/arch/i386/hal.c | 27 ++++------ ksrc/drivers/testing/timerbench.c | 55 --------------------- ksrc/nucleus/shadow.c | 48 ++++++++++++++++++ src/testsuite/cyclic/cyclictest.c | 18 +----- src/testsuite/latency/latency.c | 6 +- 14 files changed, 289 insertions(+), 131 deletions(-)
asm-generic/syscall.h renamed from asm-generic/syscall.h.orig +1 -0
@@ -29,6 +29,7 @@#define __xn_sys_barrier 3/* started = xnshadow_wait_barrier(&entry,&cookie) */ #define __xn_sys_info 4/* xnshadow_get_info(muxid,&info) */ #define __xn_sys_arch 5/* r = xnarch_local_syscall(args) */ +#define __xn_sys_trace 6/* r = xntrace_xxx(...) */ #define XENOMAI_LINUX_DOMAIN 0#define XENOMAI_XENO_DOMAIN 1
rtdm/rttesting.h renamed from rtdm/rttesting.h.orig +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)/** @} */
testsuite/latency/latency.c renamed from testsuite/latency/latency.c.orig +3 -3
@@ -12,6 +12,7 @@#include <native/timer.h> #include <native/sem.h> #include <rtdm/rttesting.h> +#include <nucleus/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)); +xntrace_user_freeze (rt_timer_tsc2ns (dt),0 ); 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 renamed from testsuite/cyclic/cyclictest.c.orig +3 -15
@@ -36,7 +36,7 @@#include <sys/mman.h> #if IPIPE_TRACE -#include <rtdm/rttesting.h> +#include <nucleus/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); +xntrace_user_freeze (diff,0 );#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 renamed from drivers/testing/timerbench.c.orig +0 -55
73 lines not on this page · raw message
nucleus/shadow.c renamed from nucleus/shadow.c.orig +47 -1
72 lines not on this page · raw message
asm-generic/hal.h renamed from asm-generic/hal.h.orig +83 -0
89 lines not on this page · raw message
asm-generic/system.h renamed from asm-generic/system.h.orig +12 -7
@@ -40,12 +40,17 @@#include <asm/xenomai/atomic.h> #include <nucleus/shadow.h> -#ifdef CONFIG_IPIPE_TRACE -#include <linux/ipipe_trace.h> -#else /* !CONFIG_IPIPE_TRACE */ -#define ipipe_trace_panic_freeze () -#define ipipe_trace_panic_dump () -#endif /* CONFIG_IPIPE_TRACE */ +/* Tracer interface */ +#define xnarch_trace_max_begin (v) rthal_trace_max_begin(v) +#define xnarch_trace_max_end (v) rthal_trace_max_end(v) +#define xnarch_trace_max_reset () rthal_trace_max_reset() +#define xnarch_trace_user_start () rthal_trace_user_start() +#define xnarch_trace_user_stop (v) rthal_trace_user_stop(v) +#define xnarch_trace_user_freeze (v, once) rthal_trace_user_freeze(v, once) +#define xnarch_trace_special (id, v) rthal_trace_special(id, v) +#define xnarch_trace_special_u64 (id, v) rthal_trace_special_u64(id, v) +#define xnarch_trace_panic_freeze () rthal_trace_panic_freeze() +#define xnarch_trace_panic_dump () rthal_trace_panic_dump()#define module_param_value (parm) (parm)
@@ -199,7 +204,7 @@ do { \rthal_emergency_console (); \xnarch_logerr ("fatal: %s\n" ,emsg); \show_stack (NULL ,NULL ); \ -ipipe_trace_panic_dump (); \ +xnarch_trace_panic_dump (); \for (;;)cpu_relax (); \ }while (0 )
asm-sim/system.h renamed from asm-sim/system.h.orig +11 -2
@@ -762,8 +762,17 @@ if (cond) \__mvm_breakable (mvm_post_graph)(&(obj)->__mvm_display_context,state); \while (0 ) -/* Ipipe-tracer */ -#define ipipe_trace_panic_freeze () +/* Tracer interface */ +#define xnarch_trace_max_begin (v) ({-ENOSYS;}) +#define xnarch_trace_max_end (v) ({-ENOSYS;}) +#define xnarch_trace_max_reset () ({-ENOSYS;}) +#define xnarch_trace_user_start () ({-ENOSYS;}) +#define xnarch_trace_user_stop (v) ({-ENOSYS;}) +#define xnarch_trace_user_freeze (v, once) ({-ENOSYS;}) +#define xnarch_trace_special (id, v) ({-ENOSYS;}) +#define xnarch_trace_special_u64 (id, v) ({-ENOSYS;}) +#define xnarch_trace_panic_freeze () ({-ENOSYS;}) +#define xnarch_trace_panic_dump () ({-ENOSYS;})#ifndef PAGE_SIZE #define PAGE_SIZE sysconf(_SC_PAGESIZE)
asm-uvm/system.h renamed from asm-uvm/system.h.orig +11 -2
@@ -784,7 +784,16 @@ static inline void xnarch_sysfree (void#define xnarch_post_graph (obj,state)#define xnarch_post_graph_if (obj,state,cond) -/* Ipipe-tracer */ -#define ipipe_trace_panic_freeze () +/* Tracer interface */ +#define xnarch_trace_max_begin (v) ({-ENOSYS;}) +#define xnarch_trace_max_end (v) ({-ENOSYS;}) +#define xnarch_trace_max_reset () ({-ENOSYS;}) +#define xnarch_trace_user_start () ({-ENOSYS;}) +#define xnarch_trace_user_stop (v) ({-ENOSYS;}) +#define xnarch_trace_user_freeze (v, once) ({-ENOSYS;}) +#define xnarch_trace_special (id, v) ({-ENOSYS;}) +#define xnarch_trace_special_u64 (id, v) ({-ENOSYS;}) +#define xnarch_trace_panic_freeze () ({-ENOSYS;}) +#define xnarch_trace_panic_dump () ({-ENOSYS;})#endif /* !_XENO_ASM_UVM_SYSTEM_H */
nucleus/assert.h renamed from nucleus/assert.h.orig +2 -2
@@ -24,9 +24,9 @@#define XENO_ASSERT (subsystem,cond,action) do { \ if (unlikely(CONFIG_XENO_OPT_DEBUG_##subsystem > 0 && !(cond))) { \ - ipipe_trace_panic_freeze(); \ + xnarch_trace_panic_freeze(); \ xnlogerr("assertion failed at %s:%d (%s)\n", __FILE__, __LINE__, (#cond)); \ - ipipe_trace_panic_dump(); \ + xnarch_trace_panic_dump(); \ action; \ } \ } while(0)
nucleus/trace.h new file +98 -0
98 lines not on this page · raw message
nucleus/types.h renamed from nucleus/types.h.orig +1 -1
@@ -112,7 +112,7 @@ void __xeno_user_exit(void); #define xnpod_fatal(format,args...) \ do { \ const char *panic; \ - ipipe_trace_panic_freeze(); \ + xnarch_trace_panic_freeze(); \ panic = xnpod_fatal_helper(format,##args); \ xnarch_halt(panic); \ } while (0)
arch/i386/hal.c renamed from arch/i386/hal.c.orig +12 -15
@@ -61,9 +61,6 @@#endif /* CONFIG_X86_LOCAL_APIC */ #include <asm/xenomai/hal.h> #include <stdarg.h> -#ifdef CONFIG_IPIPE_TRACE -#include <linux/ipipe_trace.h> -#endif /* CONFIG_IPIPE_TRACE */ extern struct desc_struct idt_table[];
@@ -176,7 +173,7 @@ unsigned long rthal_timer_calibrate(void#ifdef CONFIG_IPIPE_TRACE_IRQSOFF /* reset the max trace, it contains the excessive calibration now */ -ipipe_trace_max_reset (); +rthal_trace_max_reset ();#endif /* CONFIG_IPIPE_TRACE_IRQSOFF */ return rthal_imuldiv (dt,100000 ,RTHAL_CPU_FREQ );
@@ -211,16 +208,16 @@ void die_nmi(struct pt_regs *regs, conststatic void rthal_latency_above_max (struct pt_regs *regs) { -#ifdef CONFIG_IPIPE_TRACE -ipipe_trace_freeze (rthal_maxlat_us); -#else /* !CONFIG_IPIPE_TRACE */ -char buf[128 ]; -snprintf (buf, -sizeof (buf), -"NMI watchdog detected timer latency above %u us\n" , - rthal_maxlat_us); -die_nmi (regs, buf); -#endif /* CONFIG_IPIPE_TRACE */ +/* Try to report via latency tracer first, then fall back to panic. */ +if (rthal_trace_user_freeze (rthal_maxlat_us,1 ) <0 ) { +char buf[128 ]; + +snprintf (buf, +sizeof (buf), +"NMI watchdog detected timer latency above %u us\n" , + rthal_maxlat_us); +die_nmi (regs, buf); + } }#endif /* CONFIG_XENO_HW_NMI_DEBUG_LATENCY */
@@ -341,7 +338,7 @@ unsigned long rthal_timer_calibrate(void#ifdef CONFIG_IPIPE_TRACE_IRQSOFF /* reset the max trace, it contains the excessive calibration now */ -ipipe_trace_max_reset (); +rthal_trace_max_reset ();#endif /* CONFIG_IPIPE_TRACE_IRQSOFF */ return rthal_imuldiv (dt,100000 ,RTHAL_CPU_FREQ );
--
PATCH 2/6 Improve fault report
In reply to [email protected]Introduce xnarch_fault_um() to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.
--- include/asm-generic/system.h | 5 +++++ include/asm-sim/system.h | 1 + include/asm-uvm/system.h | 1 + ksrc/nucleus/pod.c | 11 ++++++++++- 4 files changed, 17 insertions(+), 1 deletion(-)
include/asm-generic/system.h +5 -0
@@ -35,6 +35,7 @@#include <asm/uaccess.h> #include <asm/param.h> #include <asm/mmu_context.h> +#include <asm/ptrace.h> #include <linux/config.h> #include <asm/xenomai/hal.h> #include <asm/xenomai/atomic.h>
@@ -52,6 +53,10 @@#define xnarch_trace_panic_freeze () rthal_trace_panic_freeze()#define xnarch_trace_panic_dump () rthal_trace_panic_dump() +#ifndef xnarch_fault_um +#define xnarch_fault_um (fi) user_mode(fi->regs) +#endif +#define module_param_value (parm) (parm)typedef unsigned long spl_t ;
include/asm-sim/system.h +1 -0
@@ -56,6 +56,7 @@ typedef void *xnarch_fltinfo_t; /* Unuse#define xnarch_fault_code (fi) 0#define xnarch_fault_pc (fi) 0L#define xnarch_fault_notify (fi) 1 +#define xnarch_fault_um (fi) 0typedef int spl_t ;
include/asm-uvm/system.h +1 -0
@@ -192,6 +192,7 @@ typedef void *xnarch_fltinfo_t; /* Unuse#define xnarch_fault_code (fi) 0#define xnarch_fault_pc (fi) 0L#define xnarch_fault_notify (fi) 1 +#define xnarch_fault_um (fi) 0 typedef struct xnarch_heapcb {
ksrc/nucleus/pod.c +10 -1
@@ -194,7 +194,16 @@ static int xnpod_fault_handler(xnarch_flif (xnpod_shadow_p ()) {#ifdef CONFIG_XENO_OPT_DEBUG -if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ +if (!xnarch_fault_um (fltinfo)) { +xnarch_trace_panic_freeze (); +xnprintf + ("Switching %s to secondary mode after exception #%u in " +"kernel-space at 0x%lx (pid %d)\n" , thread->name, +xnarch_fault_trap (fltinfo), +xnarch_fault_pc (fltinfo), +xnthread_user_pid (thread)); +xnarch_trace_panic_dump (); + }else if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ xnprintf ("Switching %s to secondary mode after exception #%u from " "user-space at 0x%lx (pid %d)\n", thread->name,
--
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 198
Quoted 8 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUGksrc/nucleus/pod.c +2
-1-if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ +if (!xnarch_fault_um (fltinfo)) { +xnarch_trace_panic_freeze ();
KGDB breakpoint issue?
Quoted 8 lines
ksrc/nucleus/pod.c +8
-0+xnprintf + ("Switching %s to secondary mode after exception #%u in " +"kernel-space at 0x%lx (pid %d)\n" , thread->name, +xnarch_fault_trap (fltinfo), +xnarch_fault_pc (fltinfo), +xnthread_user_pid (thread)); +xnarch_trace_panic_dump (); + }else if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */
Signature · 1 line
Philippe.
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 11 lines · Philippe Gerum
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 198
Quoted 8 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUGksrc/nucleus/pod.c +2
-1-if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ +if (!xnarch_fault_um (fltinfo)) { +xnarch_trace_panic_freeze ();KGDB breakpoint issue?
Sorry, please switch on verbose mode, didn't get yet what you mean.
Quoted 10 lines
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 206
Quoted 9 lines
ksrc/nucleus/pod.c +8
-0+xnprintf + ("Switching %s to secondary mode after exception #%u in " +"kernel-space at 0x%lx (pid %d)\n" , thread->name, +xnarch_fault_trap (fltinfo), +xnarch_fault_pc (fltinfo), +xnthread_user_pid (thread)); +xnarch_trace_panic_dump (); + }else if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */
Jan
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 13 lines · Jan Kiszka
Quoted 11 lines · Philippe Gerum
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 198
Quoted 8 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUGksrc/nucleus/pod.c +2
-1-if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ +if (!xnarch_fault_um (fltinfo)) { +xnarch_trace_panic_freeze ();KGDB breakpoint issue?
Quoted 1 line
Sorry, please switch on verbose mode, didn't get yet what you mean.
Oops, sorry. I meant: what if a KGDB breakpoint is hit from kernel space while running a shadow thread? The way I read the modified test sequence above, such bp trap is going to trigger a panic, instead of being silently passed to Linux.
Quoted 14 lines
Quoted 11 lines
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 206
Quoted 10 lines
ksrc/nucleus/pod.c +8
-0+xnprintf + ("Switching %s to secondary mode after exception #%u in " +"kernel-space at 0x%lx (pid %d)\n" , thread->name, +xnarch_fault_trap (fltinfo), +xnarch_fault_pc (fltinfo), +xnthread_user_pid (thread)); +xnarch_trace_panic_dump (); + }else if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ Jan
Signature · 1 line
Philippe.
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 11 lines · Philippe Gerum
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Philippe Gerum
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 198
Quoted 7 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUGksrc/nucleus/pod.c +2
-1-if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ +if (!xnarch_fault_um (fltinfo)) { +xnarch_trace_panic_freeze ();KGDB breakpoint issue?
Quoted 6 lines
Quoted 1 line
Sorry, please switch on verbose mode, didn't get yet what you mean.
Oops, sorry. I meant: what if a KGDB breakpoint is hit from kernel space while running a shadow thread? The way I read the modified test sequence above, such bp trap is going to trigger a panic, instead of being silently passed to Linux.
I would say: KGDB will not come along here with a breakpoint. It should already got involved in __ipipe_divert_exception().
Jan
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 14 lines · Jan Kiszka
Quoted 13 lines · Philippe Gerum
Quoted 11 lines · Jan Kiszka
Quoted 9 lines · Philippe Gerum
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 198
Quoted 7 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUGksrc/nucleus/pod.c +2
-1-if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ +if (!xnarch_fault_um (fltinfo)) { +xnarch_trace_panic_freeze ();KGDB breakpoint issue?
Sorry, please switch on verbose mode, didn't get yet what you mean.
Quoted 7 lines
Quoted 4 lines
Oops, sorry. I meant: what if a KGDB breakpoint is hit from kernel space while running a shadow thread? The way I read the modified test sequence above, such bp trap is going to trigger a panic, instead of being silently passed to Linux.
I would say: KGDB will not come along here with a breakpoint. It should already got involved in
__ipipe_divert_exception().
Ok, so the only problem that remains would be inlined asm("int 1/3") in kernel space not handled by KGDB (whether the KGDB patch is in or not). I'm still scratching my head pondering if we can live with this or not.
Quoted 3 lines
Jan
Signature · 1 line
Philippe.
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 18 lines · Philippe Gerum
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Philippe Gerum
Quoted 11 lines · Jan Kiszka
Quoted 9 lines · Philippe Gerum
ksrc/nucleus/pod.c static int xnpod_fault_handler(xnarch_fl · line 198
Quoted 7 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUGksrc/nucleus/pod.c +2
-1-if (xnarch_fault_notify (fltinfo))/* Don't report debug traps */ +if (!xnarch_fault_um (fltinfo)) { +xnarch_trace_panic_freeze ();KGDB breakpoint issue?
Sorry, please switch on verbose mode, didn't get yet what you mean.
Oops, sorry. I meant: what if a KGDB breakpoint is hit from kernel space while running a shadow thread? The way I read the modified test sequence above, such bp trap is going to trigger a panic, instead of being silently passed to Linux.
Quoted 6 lines
Quoted 2 lines
I would say: KGDB will not come along here with a breakpoint. It should already got involved in
__ipipe_divert_exception().Ok, so the only problem that remains would be inlined
asm("int 1/3")in kernel space not handled by KGDB (whether the KGDB patch is in or not). I'm still scratching my head pondering if we can live with this or not.
But this is perfectly one of the situations my patch tries to catch: a fatal bug in the kernel! Such a hand-coded kernel breakpoint without a debugger caring is a bug to me.
Jan
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 22 lines · Jan Kiszka
Quoted 21 lines · Philippe Gerum
Quoted 19 lines · Jan Kiszka
Quoted 11 lines · Philippe Gerum
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Philippe Gerum
Review
Quoted 7 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUG(quoted diff) +2
-1- if (xnarch_fault_notify(fltinfo)) /* Don't report debug traps */ + if (!xnarch_fault_um(fltinfo)) { + xnarch_trace_panic_freeze();KGDB breakpoint issue?
Quoted 5 lines
Quoted 1 line
Sorry, please switch on verbose mode, didn't get yet what you mean.
Oops, sorry. I meant: what if a KGDB breakpoint is hit from kernel space while running a shadow thread? The way I read the modified test sequence above, such bp trap is going to trigger a panic, instead of being silently passed to Linux.
I would say: KGDB will not come along here with a breakpoint. It should already got involved in
__ipipe_divert_exception().
Quoted 7 lines
Quoted 3 lines
Ok, so the only problem that remains would be inlined
asm("int 1/3")in kernel space not handled by KGDB (whether the KGDB patch is in or not). I'm still scratching my head pondering if we can live with this or not.But this is perfectly one of the situations my patch tries to catch: a fatal bug in the kernel! Such a hand-coded kernel breakpoint without a debugger caring is a bug to me.
Not that sure: passive debug code may exist. Only the presence of the debugger should activate it.
Quoted 3 lines
Jan
Signature · 1 line
Philippe.
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 25 lines · Philippe Gerum
Quoted 24 lines · Jan Kiszka
Quoted 23 lines · Philippe Gerum
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Philippe Gerum
Quoted 10 lines · Jan Kiszka
Quoted 9 lines · Philippe Gerum
Review
Quoted 7 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUG(quoted diff) +2
-1- if (xnarch_fault_notify(fltinfo)) /* Don't report debug traps */ + if (!xnarch_fault_um(fltinfo)) { + xnarch_trace_panic_freeze();KGDB breakpoint issue?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Sorry, please switch on verbose mode, didn't get yet what you mean.
Oops, sorry. I meant: what if a KGDB breakpoint is hit from kernel space while running a shadow thread? The way I read the modified test sequence above, such bp trap is going to trigger a panic, instead of being silently passed to Linux.
I would say: KGDB will not come along here with a breakpoint. It should already got involved in
__ipipe_divert_exception().Ok, so the only problem that remains would be inlined
asm("int 1/3")in kernel space not handled by KGDB (whether the KGDB patch is in or not). I'm still scratching my head pondering if we can live with this or not.
Quoted 7 lines
Quoted 3 lines
But this is perfectly one of the situations my patch tries to catch: a fatal bug in the kernel! Such a hand-coded kernel breakpoint without a debugger caring is a bug to me.
Not that sure: passive debug code may exist. Only the presence of the debugger should activate it.
...but remains a bug for me /w RT code. We now complain about this exception happened. And there is no crash/BUG in this case, just a desirable warning with back-trace in the log.
Jan
PS: Other OSes show you a nice blue-screen when they ran on such orphaned breakpoints.
Re: [Xenomai-core] [PATCH 2/6] Improve fault report
Quoted 30 lines · Jan Kiszka
Quoted 29 lines · Philippe Gerum
Quoted 27 lines · Jan Kiszka
Quoted 18 lines · Philippe Gerum
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Philippe Gerum
Quoted 11 lines · Jan Kiszka
Quoted 9 lines · Philippe Gerum
Review
Quoted 7 lines · On Mon, 2006-06-26 at 19:21 +0200, [email protected] wrote:
plain text document attachment (enhance-kernel-fault-report.patch)
Introducexnarch_fault_um()to test if a fault happened in user-mode and applies the new feature to report core and driver crashes more verbosely.if (xnpod_shadow_p()) {#ifdef
CONFIG_XENO_OPT_DEBUG(quoted diff) +2
-1- if (xnarch_fault_notify(fltinfo)) /* Don't report debug traps */ + if (!xnarch_fault_um(fltinfo)) { + xnarch_trace_panic_freeze();KGDB breakpoint issue?
Sorry, please switch on verbose mode, didn't get yet what you mean.
Oops, sorry. I meant: what if a KGDB breakpoint is hit from kernel space while running a shadow thread? The way I read the modified test sequence above, such bp trap is going to trigger a panic, instead of being silently passed to Linux.
Quoted 5 lines
Quoted 2 lines
I would say: KGDB will not come along here with a breakpoint. It should already got involved in
__ipipe_divert_exception().Ok, so the only problem that remains would be inlined
asm("int 1/3")in kernel space not handled by KGDB (whether the KGDB patch is in or not). I'm still scratching my head pondering if we can live with this or not.But this is perfectly one of the situations my patch tries to catch: a fatal bug in the kernel! Such a hand-coded kernel breakpoint without a debugger caring is a bug to me.
Quoted 5 lines
Quoted 3 lines
Not that sure: passive debug code may exist. Only the presence of the debugger should activate it.
...but remains a bug for me /w RT code.
Someone inserting such passive breakpoints would have to know what she's doing, in any case. Looking the relax counter in /proc/xenomai/stats (which is among the first things to do when chasing unexpected latencies) would also give a serious hint to the inattentive folks. What bothers me is to restrict the usage one can do of debug vectors on certain archs, just for the purpose of saving one's from careless coding.
Quoted 4 lines
We now complain about this
exception happened. And there is no crash/BUG in this case, just a desirable warning with back-trace in the log.
Ok, If *_panic() routines do not actually panic at all, it's acceptable.
Quoted 4 lines
PS: Other OSes show you a nice blue-screen when they ran on such orphaned breakpoints.
What other O/S do in this respect is not relevant; it's not an inter-operability or compatibility issue between Xenomai and others, it's a decision to make about which behaviour is the least intrusive wrt debug strategies.
Quoted 1 line
Signature · 1 line
Philippe.
PATCH 3/6 Refactor rttesting device interface
In reply to [email protected]Refactors the RTDM rttesting header to apply more regular naming and propagates the changes through all users. The patch also extends the testing devices to automatically acquire a free rttestX device name if the first one is busy.
--- include/rtdm/rttesting.h | 129 ++++++++++++++++++-------------------- ksrc/drivers/testing/switchtest.c | 97 +++++++++++++++------------- ksrc/drivers/testing/timerbench.c | 111 +++++++++++++++++--------------- src/testsuite/latency/latency.c | 26 +++---- src/testsuite/switchtest/switch.c | 69 ++++++++++---------- 5 files changed, 223 insertions(+), 209 deletions(-)
include/rtdm/rttesting.h +62 -67
@@ -31,9 +31,9 @@* @n * * @par Device Characteristics -* @ref rtdm_device.device_flags "Device Flags": @c RTDM_NAMED_DEVICE, @c RTDM_EXCLUSIVE @n +* @ref rtdm_device.device_flags "Device Flags": @c RTDM_NAMED_DEVICE @n * @n -* @ref rtdm_device.device_name "Device Name": @c "rtbenchmark<N>", N >= 0 @n +* @ref rtdm_device.device_name "Device Name": @c "rttest<N>", N >= 0 @n * @n * @ref rtdm_device.device_class "Device Class": @c RTDM_CLASS_TESTING @n * @n
@@ -48,8 +48,8 @@* Specific return values: none @n * @n * @b IOCTL @n -* Mandatory Environments: see @ref TIMER_IOCTLs "below" @n -* Specific return values: see @ref TIMER_IOCTLs "below" @n +* Mandatory Environments: see @ref IOCTLs below @n +* Specific return values: see @ref IOCTLs below @n * * @{ */
@@ -59,105 +59,100 @@#include <rtdm/rtdm.h> -#define RTBNCH_TIMER_TASK 0 -#define RTBNCH_TIMER_HANDLER 1 - -typedef struct rtbnch_result { +typedef struct rttst_bench_res {long long avg;long min;long max;long overruns;long test_loops; -}rtbnch_result_t ; +}rttst_bench_res_t ; + +typedef struct rttst_interm_bench_res { +struct rttst_bench_res last; +struct rttst_bench_res overall; +}rttst_interm_bench_res_t ; + +typedef struct rttst_overall_bench_res { +struct rttst_bench_res result; +long *histogram_avg; +long *histogram_min; +long *histogram_max; +}rttst_overall_bench_res_t ; + + +#define RTTST_TMBENCH_TASK 0 +#define RTTST_TMBENCH_HANDLER 1 -typedef struct rtbnch_timerconfig { +typedef struct rttst_tmbench_config {int mode;uint64_t period;int warmup_loops;int histogram_size;int histogram_bucketsize;int freeze_max; -}rtbnch_timerconfig_t ; +}rttst_tmbench_config_t ; -typedef struct rtbnch_interm_result { -struct rtbnch_result last; -struct rtbnch_result overall; -}rtbnch_interm_result_t ; -typedef struct rtbnch_overall_result { -struct rtbnch_result result; -long *histogram_avg; -long *histogram_min; -long *histogram_max; -}rtbnch_overall_result_t ; +#define RTTST_SWTEST_FPU 0x1 +#define RTTST_SWTEST_USE_FPU 0x2/* Only for kernel-space tasks. */ + +struct rttst_swtest_task { +unsigned index; +unsigned flags; +}; + +struct rttst_swtest_dir { +unsigned from; +unsigned to; +}; -#define RTIOC_TYPE_BENCHMARK RTDM_CLASS_TESTING +#define RTIOC_TYPE_TESTING RTDM_CLASS_TESTING/*! * @name Sub-Classes of RTDM_CLASS_TESTING * @{ */ -#define RTDM_SUBCLASS_TIMER 0 - -#define RTDM_SUBCLASS_SWITCH 1 +#define RTDM_SUBCLASS_TIMERBENCH 0 +#define RTDM_SUBCLASS_IRQBENCH 1 +#define RTDM_SUBCLASS_SWITCHTEST 2/** @} */ /*! -* @anchor TIMER_IOCTLs @name TIMER_IOCTLs -* Timer benchmark device IOCTLs +* @anchor IOCTLs @name IOCTLs +* Testing device IOCTLs * @{ */ -#define RTBNCH_RTIOC_INTERM_RESULT \ - _IOWR(RTIOC_TYPE_BENCHMARK, 0x00, struct rtbnch_interm_result) - -#define RTBNCH_RTIOC_START_TMTEST \ - _IOW(RTIOC_TYPE_BENCHMARK, 0x10, struct rtbnch_timerconfig) - -#define RTBNCH_RTIOC_STOP_TMTEST \ - _IOWR(RTIOC_TYPE_BENCHMARK, 0x11, struct rtbnch_overall_result) -/** @} */ - +#define RTTST_RTIOC_INTERM_BENCH_RES \ + _IOWR(RTIOC_TYPE_TESTING, 0x00, struct rttst_interm_bench_res) -#define RTIOC_TYPE_SWITCH RTDM_CLASS_TESTING -#define RTSWITCH_FPU 0x1 -#define RTSWITCH_USE_FPU 0x2/* Only for kernel-space tasks. */ +#define RTTST_RTIOC_TMBENCH_START \ + _IOW(RTIOC_TYPE_TESTING, 0x10, struct rttst_tmbench_config) +#define RTTST_RTIOC_TMBENCH_STOP \ + _IOWR(RTIOC_TYPE_TESTING, 0x11, struct rttst_overall_bench_res) -struct rtswitch_task { -unsigned index; -unsigned flags; -}; - -struct rtswitch { -unsigned from; -unsigned to; -}; -/** -* @anchor SWITCH_IOCTLs @name @SWITCH_IOCTLs -* Context-switch testing device IOCTLs -* @{ */ -#define RTSWITCH_RTIOC_TASKS_COUNT \ - _IOW(RTIOC_TYPE_SWITCH, 0x30, unsigned long) +#define RTTST_RTIOC_SWTEST_SET_TASKS_COUNT \ + _IOW(RTIOC_TYPE_TESTING, 0x30, unsigned long) -#define RTSWITCH_RTIOC_SET_CPU \ - _IOW(RTIOC_TYPE_SWITCH, 0x31, unsigned long) +#define RTTST_RTIOC_SWTEST_SET_CPU \ + _IOW(RTIOC_TYPE_TESTING, 0x31, unsigned long) -#define RTSWITCH_RTIOC_REGISTER_UTASK \ - _IOW(RTIOC_TYPE_SWITCH, 0x32, struct rtswitch_task) +#define RTTST_RTIOC_SWTEST_REGISTER_UTASK \ + _IOW(RTIOC_TYPE_TESTING, 0x32, struct rttst_swtest_task) -#define RTSWITCH_RTIOC_CREATE_KTASK \ - _IOWR(RTIOC_TYPE_SWITCH, 0x33, struct rtswitch_task) +#define RTTST_RTIOC_SWTEST_CREATE_KTASK \ + _IOWR(RTIOC_TYPE_TESTING, 0x33, struct rttst_swtest_task) -#define RTSWITCH_RTIOC_PEND \ - _IOR(RTIOC_TYPE_SWITCH, 0x34, struct rtswitch_task) +#define RTTST_RTIOC_SWTEST_PEND \ + _IOR(RTIOC_TYPE_TESTING, 0x34, struct rttst_swtest_task) -#define RTSWITCH_RTIOC_SWITCH_TO \ - _IOR(RTIOC_TYPE_SWITCH, 0x35, struct rtswitch) +#define RTTST_RTIOC_SWTEST_SWITCH_TO \ + _IOR(RTIOC_TYPE_TESTING, 0x35, struct rttst_swtest_dir) -#define RTSWITCH_RTIOC_GET_SWITCHES_COUNT \ - _IOR(RTIOC_TYPE_SWITCH, 0x36, unsigned long) +#define RTTST_RTIOC_SWTEST_GET_SWITCHES_COUNT \ + _IOR(RTIOC_TYPE_TESTING, 0x36, unsigned long)/** @} */ /** @} */
ksrc/drivers/testing/switchtest.c +54 -43
241 lines not on this page · raw message
ksrc/drivers/testing/timerbench.c +59 -52
216 lines not on this page · raw message
src/testsuite/latency/latency.c +13 -13
@@ -77,7 +77,7 @@ void latency (void *cookie)RT_TIMER_INFO timer_info; err =rt_timer_inquire (&timer_info); - +if (err) {fprintf (stderr,"latency: rt_timer_inquire, code %d\n" ,err);
@@ -107,7 +107,7 @@ void latency (void *cookie)for (count = sumj =0 ; count < nsamples; count++) { -unsigned long ov; +unsigned long ov; expected_tsc += period_tsc; err =rt_task_wait_period (&ov);
@@ -186,12 +186,12 @@ void display (void *cookie) } }else { -struct rtbnch_timerconfig config; +struct rttst_tmbench_config config;if (test_mode ==KERNEL_TASK ) - config.mode =RTBNCH_TIMER_TASK ; + config.mode =RTTST_TMBENCH_TASK ;else - config.mode =RTBNCH_TIMER_HANDLER ; + config.mode =RTTST_TMBENCH_HANDLER ; config.period = period_ns; config.warmup_loops =WARMUP_TIME ;
@@ -199,7 +199,7 @@ void display (void *cookie) config.histogram_bucketsize = bucketsize; config.freeze_max = freeze_max; - err =rt_dev_ioctl (benchdev,RTBNCH_RTIOC_START_TMTEST , &config); + err =rt_dev_ioctl (benchdev,RTTST_RTIOC_TMBENCH_START , &config);if (err) {
@@ -239,14 +239,14 @@ void display (void *cookie) gmaxj =rt_timer_tsc2ns (gmaxjitter); }else { -struct rtbnch_interm_result result; +struct rttst_interm_bench_res result; - err =rt_dev_ioctl (benchdev,RTBNCH_RTIOC_INTERM_RESULT , &result); + err =rt_dev_ioctl (benchdev,RTTST_RTIOC_INTERM_BENCH_RES , &result);if (err) {if (err != -EIDRM ) -fprintf (stderr,"latency: failed to call RTBNCH_RTIOC_INTERM_RESULT, code %d\n" ,err); +fprintf (stderr,"latency: failed to call RTTST_RTIOC_INTERM_BENCH_RES, code %d\n" ,err);return ; }
@@ -375,13 +375,13 @@ void cleanup_upon_sig(int sig __attribut gmaxj =rt_timer_tsc2ns (gmaxjitter); gavgj =rt_timer_tsc2ns (gavgjitter); }else { -struct rtbnch_overall_result overall; +struct rttst_overall_bench_res overall; overall.histogram_min = histogram_min; overall.histogram_max = histogram_max; overall.histogram_avg = histogram_avg; -rt_dev_ioctl (benchdev,RTBNCH_RTIOC_STOP_TMTEST , &overall); +rt_dev_ioctl (benchdev,RTTST_RTIOC_TMBENCH_STOP , &overall); gminj = overall.result.min; gmaxj = overall.result.max;
@@ -499,7 +499,7 @@ int main (int argc, char **argv)" [-l <data-lines per header>] # default=21, 0 to supress headers\n" " [-T <test_duration_seconds>] # default=0, so ^C to end\n" " [-q] # supresses RTD, RTH lines if -T is used\n" -" [-D <benchmark_device_no>] # number of benchmark device, default=0\n" +" [-D <testing_device_no>] # number of testing device, default=0\n" " [-t <test_mode>] # 0=user task (default), 1=kernel task, 2=timer IRQ\n" " [-f] # freeze trace for each new max latency\n" " [-c <cpu>] # pin measuring task down to given CPU\n");
@@ -549,7 +549,7 @@ int main (int argc, char **argv) {char devname[RTDM_MAX_DEVNAME_LEN ]; -snprintf (devname,RTDM_MAX_DEVNAME_LEN ,"rtbenchmark%d" , benchdev_no); +snprintf (devname,RTDM_MAX_DEVNAME_LEN ,"rttest%d" , benchdev_no); benchdev =rt_dev_open (devname,O_RDWR );if (benchdev <0 )
src/testsuite/switchtest/switch.c +35 -34
203 lines not on this page · raw message
--
PATCH 4/6 Add prio switch to latency test
In reply to [email protected]Introduces -P <priority> switch to the latency test and extends xeno_timerbench to respect this for the kernel-based timer task as well. The patch also allows now to run multiple latency tests (both in-kernel and user-space) in parallel.
--- include/rtdm/rttesting.h | 1 + ksrc/drivers/testing/timerbench.c | 4 ++-- src/testsuite/latency/latency.c | 20 ++++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-)
include/rtdm/rttesting.h +1 -0
@@ -86,6 +86,7 @@ typedef struct rttst_overall_bench_res { typedef struct rttst_tmbench_config { int mode; uint64_t period; + int priority; int warmup_loops; int histogram_size; int histogram_bucketsize;
ksrc/drivers/testing/timerbench.c +2 -2
@@ -305,7 +305,7 @@ int rt_tmbench_ioctl_nrt(struct rtdm_dev ctx->mode =RTTST_TMBENCH_TASK ; ret =rtdm_task_init (&ctx->timer_task,"timerbench" , timer_task_proc, ctx, -RTDM_TASK_HIGHEST_PRIORITY ,0 ); + config->priority,0 ); } }else {/* FIXME: convert to RTDM timers */
@@ -465,7 +465,7 @@ int rt_tmbench_ioctl_rt(struct rtdm_dev_static struct rtdm_device device = { struct_version:RTDM_DEVICE_STRUCT_VER , - device_flags:RTDM_NAMED_DEVICE |RTDM_EXCLUSIVE , + device_flags:RTDM_NAMED_DEVICE , context_size:sizeof (struct rt_tmbench_context ), device_name:"" ,
src/testsuite/latency/latency.c +16 -4
@@ -34,6 +34,7 @@ int quiet = 0; /* suppress prinint benchdev_no =0 ;int benchdev =-1 ;int freeze_max =0 ; +int priority =T_HIPRIO ;#define USER_TASK 0#define KERNEL_TASK 1
@@ -194,6 +195,7 @@ void display (void *cookie) config.mode =RTTST_TMBENCH_HANDLER ; config.period = period_ns; + config.priority = priority; config.warmup_loops =WARMUP_TIME ; config.histogram_size = (do_histogram || do_stats) ? histogram_size :0 ; config.histogram_bucketsize = bucketsize;
@@ -425,7 +427,7 @@ int main (int argc, char **argv)char task_name[16 ];int cpu =0 ; -while ((c =getopt (argc,argv,"hp:l:T:qH:B:sD:t:fc:" )) !=EOF ) +while ((c =getopt (argc,argv,"hp:l:T:qH:B:sD:t:fc:P:" )) !=EOF )switch (c) {case 'h' :
@@ -488,6 +490,10 @@ int main (int argc, char **argv) cpu =T_CPU (atoi (optarg));break ; +case 'P' : + priority =atoi (optarg); +break ; +default : fprintf(stderr, "usage: latency [options]\n"
@@ -502,7 +508,8 @@ int main (int argc, char **argv)" [-D <testing_device_no>] # number of testing device, default=0\n" " [-t <test_mode>] # 0=user task (default), 1=kernel task, 2=timer IRQ\n" " [-f] # freeze trace for each new max latency\n" - " [-c <cpu>] # pin measuring task down to given CPU\n"); +" [-c <cpu>] # pin measuring task down to given CPU\n" + " [-P <priority>] # task priority (test mode 0 and 1 only)\n");exit (2 ); }
@@ -530,6 +537,11 @@ int main (int argc, char **argv)if (period_ns ==0 ) period_ns =100000LL ;/* ns */ +if (priority <=T_LOPRIO ) + priority =T_LOPRIO +1 ; +else if (priority >T_HIPRIO ) + priority =T_HIPRIO ; +signal (SIGINT , cleanup_upon_sig);signal (SIGTERM , cleanup_upon_sig);signal (SIGHUP , cleanup_upon_sig);
@@ -563,7 +575,7 @@ int main (int argc, char **argv)rt_timer_set_mode (TM_ONESHOT );/* Force aperiodic timing. */ snprintf (task_name,sizeof (task_name),"display-%d" ,getpid ()); - err =rt_task_create (&display_task,task_name,0 ,98 ,T_FPU ); + err =rt_task_create (&display_task,task_name,0 ,0 ,T_FPU );if (err) {
@@ -581,7 +593,7 @@ int main (int argc, char **argv)if (test_mode ==USER_TASK ) {snprintf (task_name,sizeof (task_name),"sampling-%d" ,getpid ()); - err =rt_task_create (&latency_task,task_name,0 ,99 ,T_FPU |cpu); + err =rt_task_create (&latency_task,task_name,0 ,priority,T_FPU |cpu);if (err) {
--
Re: [Xenomai-core] [PATCH 4/6] Add prio switch to latency test
This is just a rebased version of the patch over revision #1275.
Jan
Subject: Add prio switch to latency test
Introduces -P <priority> switch to the latency test and extends xeno_timerbench to respect this for the kernel-based timer task as well. The patch also allows now to run multiple latency tests (both in-kernel and user-space) in parallel.
--- include/rtdm/rttesting.h | 1 + ksrc/drivers/testing/timerbench.c | 4 ++-- src/testsuite/latency/latency.c | 20 ++++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-)
include/rtdm/rttesting.h +1 -0
@@ -86,6 +86,7 @@ typedef struct rttst_overall_bench_res { typedef struct rttst_tmbench_config { int mode; uint64_t period; + int priority; int warmup_loops; int histogram_size; int histogram_bucketsize;
ksrc/drivers/testing/timerbench.c +2 -2
@@ -305,7 +305,7 @@ int rt_tmbench_ioctl_nrt(struct rtdm_dev ctx->mode =RTTST_TMBENCH_TASK ; ret =rtdm_task_init (&ctx->timer_task,"timerbench" , timer_task_proc, ctx, -RTDM_TASK_HIGHEST_PRIORITY ,0 ); + config->priority,0 ); } }else {/* FIXME: convert to RTDM timers */
@@ -465,7 +465,7 @@ int rt_tmbench_ioctl_rt(struct rtdm_dev_static struct rtdm_device device = { struct_version:RTDM_DEVICE_STRUCT_VER , - device_flags:RTDM_NAMED_DEVICE |RTDM_EXCLUSIVE , + device_flags:RTDM_NAMED_DEVICE , context_size:sizeof (struct rt_tmbench_context ), device_name:"" ,
src/testsuite/latency/latency.c +16 -4
@@ -34,6 +34,7 @@ int quiet = 0; /* suppress prinint benchdev_no =0 ;int benchdev =-1 ;int freeze_max =0 ; +int priority =T_HIPRIO ;#define USER_TASK 0#define KERNEL_TASK 1
@@ -194,6 +195,7 @@ void display (void *cookie) config.mode =RTTST_TMBENCH_HANDLER ; config.period = period_ns; + config.priority = priority; config.warmup_loops =WARMUP_TIME ; config.histogram_size = (do_histogram || do_stats) ? histogram_size :0 ; config.histogram_bucketsize = bucketsize;
@@ -424,7 +426,7 @@ int main (int argc, char **argv)char task_name[16 ];int cpu =0 ; -while ((c =getopt (argc,argv,"hp:l:T:qH:B:sD:t:fc:" )) !=EOF ) +while ((c =getopt (argc,argv,"hp:l:T:qH:B:sD:t:fc:P:" )) !=EOF )switch (c) {case 'h' :
@@ -487,6 +489,10 @@ int main (int argc, char **argv) cpu =T_CPU (atoi (optarg));break ; +case 'P' : + priority =atoi (optarg); +break ; +default : fprintf(stderr, "usage: latency [options]\n"
@@ -501,7 +507,8 @@ int main (int argc, char **argv)" [-D <testing_device_no>] # number of testing device, default=0\n" " [-t <test_mode>] # 0=user task (default), 1=kernel task, 2=timer IRQ\n" " [-f] # freeze trace for each new max latency\n" - " [-c <cpu>] # pin measuring task down to given CPU\n"); +" [-c <cpu>] # pin measuring task down to given CPU\n" + " [-P <priority>] # task priority (test mode 0 and 1 only)\n");exit (2 ); }
@@ -529,6 +536,11 @@ int main (int argc, char **argv)if (period_ns ==0 ) period_ns =100000LL ;/* ns */ +if (priority <=T_LOPRIO ) + priority =T_LOPRIO +1 ; +else if (priority >T_HIPRIO ) + priority =T_HIPRIO ; +signal (SIGINT , sighand);signal (SIGTERM , sighand);signal (SIGHUP , sighand);
@@ -562,7 +574,7 @@ int main (int argc, char **argv)rt_timer_set_mode (TM_ONESHOT );/* Force aperiodic timing. */ snprintf (task_name,sizeof (task_name),"display-%d" ,getpid ()); - err =rt_task_create (&display_task,task_name,0 ,98 ,T_FPU ); + err =rt_task_create (&display_task,task_name,0 ,0 ,T_FPU );if (err) {
@@ -580,7 +592,7 @@ int main (int argc, char **argv)if (test_mode ==USER_TASK ) {snprintf (task_name,sizeof (task_name),"sampling-%d" ,getpid ()); - err =rt_task_create (&latency_task,task_name,0 ,99 ,T_FPU |cpu); + err =rt_task_create (&latency_task,task_name,0 ,priority,T_FPU |cpu);if (err) {
PATCH 5/6 Overread dev-prefix on posix open
In reply to [email protected]Adds support to the posix user-space lib to address RTDM-devices also with a (here meaningless) "/dev/" name prefix. Intended to increase user convenience slightly.
--- src/skins/posix/rtdm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/skins/posix/rtdm.c +6 -1
@@ -41,10 +41,15 @@ static inline int set_errno(int ret)int __wrap_open (const char *path,int oflag, ...) {int ret, oldtype; +char *rtdm_path = path;pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS , &oldtype); - ret =XENOMAI_SKINCALL2 (__rtdm_muxid, __rtdm_open, path, oflag); +/* skip path prefix for RTDM invocation */ +if (strncmp (path,"/dev/" ,5 ) ==0 ) + rtdm_path +=5 ; + + ret =XENOMAI_SKINCALL2 (__rtdm_muxid, __rtdm_open, rtdm_path, oflag);pthread_setcanceltype (oldtype,NULL );
--
Re: [Xenomai-core] [PATCH 5/6] Overread dev-prefix on posix open
Update to fix a compiler warning (char * vs. const char *).
Jan
Subject: Overread dev-prefix on posix open
Adds support to the posix user-space lib to address RTDM-devices also with a (here meaningless) "/dev/" name prefix. Intended to increase user convenience slightly.
--- src/skins/posix/rtdm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/skins/posix/rtdm.c +6 -1
@@ -41,10 +41,15 @@ static inline int set_errno(int ret)int __wrap_open (const char *path,int oflag, ...) {int ret, oldtype; +const char *rtdm_path = path;pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS , &oldtype); - ret =XENOMAI_SKINCALL2 (__rtdm_muxid, __rtdm_open, path, oflag); +/* skip path prefix for RTDM invocation */ +if (strncmp (path,"/dev/" ,5 ) ==0 ) + rtdm_path +=5 ; + + ret =XENOMAI_SKINCALL2 (__rtdm_muxid, __rtdm_open, rtdm_path, oflag);pthread_setcanceltype (oldtype,NULL );
PATCH 6/6 Introduce IRQ latency benchmark
In reply to [email protected]This patch introduces another rttesting driver, xeno_irqbench, for measuring external IRQ latencies. The irqbench device is controlled by a user-mode tool irqloop. A second tool for plain Linux, irqbench, is provided to trigger the event over serial or parallel cross-link (the latter is incomplete yet) and measure the reaction latency.
--- configure.in | 1 include/rtdm/rttesting.h | 38 ++ ksrc/drivers/Makefile | 2 ksrc/drivers/testing/Kconfig | 21 + ksrc/drivers/testing/Makefile | 13 - ksrc/drivers/testing/irqbench.c | 472 +++++++++++++++++++++++++++++++++++++ src/testsuite/Makefile.am | 2 src/testsuite/irqbench/Makefile.am | 47 +++ src/testsuite/irqbench/irqbench.c | 301 +++++++++++++++++++++++ src/testsuite/irqbench/irqloop.c | 169 +++++++++++++ src/testsuite/irqbench/runinfo | 1 11 files changed, 1056 insertions(+), 11 deletions(-)
include/rtdm/rttesting.h +38 -0
@@ -94,6 +94,28 @@ typedef struct rttst_tmbench_config { } rttst_tmbench_config_t; +#define RTTST_IRQBENCH_USER_TASK 0 +#define RTTST_IRQBENCH_KERNEL_TASK 1 +#define RTTST_IRQBENCH_HANDLER 2 + +#define RTTST_IRQBENCH_SERPORT 0 +#define RTTST_IRQBENCH_PARPORT 1 + +struct rttst_irqbench_config { +int mode; +int priority; +int calibration_loops; +unsigned int port_type; +unsigned long port_ioaddr; +unsigned int port_irq; +} rttst_irqbench_config_t; + +struct rttst_irqbench_stats { +unsigned long long irqs_received; +unsigned long long irqs_acknowledged; +} rttst_irqbench_stats_t; + +#define RTTST_SWTEST_FPU 0x1#define RTTST_SWTEST_USE_FPU 0x2/* Only for kernel-space tasks. */
@@ -134,6 +156,22 @@ struct rttst_swtest_dir { _IOWR(RTIOC_TYPE_TESTING, 0x11, struct rttst_overall_bench_res) +#define RTTST_RTIOC_IRQBENCH_START \ + _IOW(RTIOC_TYPE_TESTING, 0x20, struct rttst_irqbench_config) + +#define RTTST_RTIOC_IRQBENCH_STOP \ + _IO(RTIOC_TYPE_TESTING, 0x21) + +#define RTTST_RTIOC_IRQBENCH_GET_STATS \ + _IOR(RTIOC_TYPE_TESTING, 0x22, struct rttst_irqbench_stats) + +#define RTTST_RTIOC_IRQBENCH_WAIT_IRQ \ + _IO(RTIOC_TYPE_TESTING, 0x23) + +#define RTTST_RTIOC_IRQBENCH_REPLY_IRQ \ + _IO(RTIOC_TYPE_TESTING, 0x24) + +#define RTTST_RTIOC_SWTEST_SET_TASKS_COUNT \ _IOW(RTIOC_TYPE_TESTING, 0x30, unsigned long)
configure.in +1 -0
@@ -602,6 +602,7 @@ AC_CONFIG_FILES([ \ src/testsuite/switchbench/Makefile \ src/testsuite/cyclic/Makefile \ src/testsuite/switchtest/Makefile \ + src/testsuite/irqbench/Makefile \ include/Makefile \ include/asm-generic/Makefile \ include/asm-blackfin/Makefile \
ksrc/drivers/Makefile +1 -1
@@ -11,7 +11,7 @@ else subdir-$(CONFIG_XENO_DRIVERS_16550A) += 16550A subdir-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += testing - +subdir-$(CONFIG_XENO_DRIVERS_IRQBENCH) += testing subdir-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += testing include $(TOPDIR)/Rules.make
ksrc/drivers/testing/Kconfig +15 -6
@@ -6,10 +6,19 @@ config XENO_DRIVERS_TIMERBENCH Kernel-based benchmark driver for timer latency evaluation. See testsuite/latency for a possible front-end. +config XENO_DRIVERS_IRQBENCH + depends on XENO_SKIN_RTDM + tristate "IRQ benchmark driver" + default n + help + Loopback driver for IRQ latency evaluation over serial or parallel + port links. Additionally requires user-space helper and a logging tool + (see testsuite/irqbench). + config XENO_DRIVERS_SWITCHTEST - depends on XENO_SKIN_RTDM - tristate "Context switch unit testing driver" - default n - help - Kernel-based driver for unit testing context switches and - FPU switches. + depends on XENO_SKIN_RTDM + tristate "Context switch unit testing driver" + default n + help + Kernel-based driver for unit testing context switches and + FPU switches.
ksrc/drivers/testing/Makefile +10 -3
@@ -5,11 +5,13 @@ ifeq ($(PATCHLEVEL),6) EXTRA_CFLAGS += -Iinclude/xenomai obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o - +obj-$(CONFIG_XENO_DRIVERS_IRQBENCH) += xeno_irqbench.o obj-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += xeno_switchtest.o xeno_timerbench-y := timerbench.o +xeno_irqbench-y := irqbench.o + xeno_switchtest-y := switchtest.o EXTRA_CFLAGS += -Iinclude/xenomai
@@ -21,14 +23,16 @@ else O_TARGET := built-in.o obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o - +obj-$(CONFIG_XENO_DRIVERS_IRQBENCH) += xeno_irqbench.o obj-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += xeno_switchtest.o xeno_timerbench-objs := timerbench.o +xeno_irqbench-objs := irqbench.o + xeno_switchtest-objs := switchtest.o -export-objs := $(xeno_timerbench-objs) $(xeno_switchtest-objs) +export-objs := $(xeno_timerbench-objs) $(xeno_irqbench-objs) $(xeno_switchtest-objs) EXTRA_CFLAGS += -I$(TOPDIR)/include/xenomai -I$(TOPDIR)/include/xenomai/compat
@@ -37,6 +41,9 @@ include $(TOPDIR)/Rules.make xeno_timerbench.o: $(xeno_timerbench-objs) $(LD) -r -o $@ $(xeno_timerbench-objs) +xeno_irqbench.o: $(xeno_irqbench-objs) + $(LD) -r -o $@ $(xeno_irqbench-objs) + xeno_switchtest.o: $(xeno_switchtest-objs) $(LD) -r -o $@ $(xeno_switchtest-objs)
ksrc/drivers/testing/irqbench.c new file +472 -0
472 lines not on this page · raw message
src/testsuite/Makefile.am +1 -1
@@ -1 +1 @@ -SUBDIRS = latency switchbench cyclic switchtest +SUBDIRS = latency switchbench cyclic switchtest irqbench
src/testsuite/irqbench/Makefile.am new file +47 -0
47 lines not on this page · raw message
src/testsuite/irqbench/irqbench.c new file +301 -0
301 lines not on this page · raw message
src/testsuite/irqbench/irqloop.c new file +169 -0
169 lines not on this page · raw message
src/testsuite/irqbench/runinfo new file +1 -0
@@ -0,0 +1 @@ +irqloop:posix+rtdm+irqbench:!./irqloop;popall:control_c
--
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 6 lines · [email protected] wrote:
This patch introduces another rttesting driver,
xeno_irqbench, for measuring external IRQ latencies. The irqbench device is controlled by a user-mode tool irqloop. A second tool for plain Linux, irqbench, is provided to trigger the event over serial or parallel cross-link (the latter is incomplete yet) and measure the reaction latency.
As a follow-up, here is a patch to add some documentation for irqbench. I do not repeat the command line args of irqbench/irqloop, but feel free to point out missing explanations.
Jan
doc/txt/irqbench.txt new file +48 -0
@@ -0,0 +1,48 @@ +IRQ Latency Benchmark +--------------------- + +This latency benchmark for external interrupts consists of three parts: + +1. xeno_irqbench (ksrc/drivers/testing) + RTDM driver for the test target to handle and reply to the IRQ events, or + forward them to user-space. + +2. irqloop (src/testsuite/irqbench) + xeno_irqbench control front-end and user-space loop-closer. Runs against + the POSIX skin on the test target. + +3. irqbench (src/testsuite/irqbench) + IRQ triggering and reaction measuring tool for the log system. Runs over + plain Linux on x86 hosts (contains inline assembly, ports to other archs + will be welcome). + +To link both test and log system, a null-modem cable between 8250-compatible +two RS232 ports is required. The infrastructure for parallel port cross-over +is prepared as well, but yet untested and incomplete. The null-modem cable +must provide at least the following links: + + test target log system + ----------- ---------- + CTS(8) <------ RTS(7) IRQ trigger + RTS(7) ------> CTS(8) reply + + DCD(1) + and/or <------ DTR(4) trace trigger (optional) + DSR(6) + + (Pin number on 9-pin sub-D socket) + +Test and log system can be started in arbitrary order, they will wait on +each other. + +The log system runs each single IRQ measurement with local IRQs disabled. It +will wait up to 100 times the current period on the test system's reply (after +initial successful synchronisation, which happens with IRQs enabled). Note that +these timeouts may disturb other processes or drivers on the log system. + +Keep in mind for test evaluations that, by design, irqbench will not trigger a +new IRQ event before the reply on the previous one has arrived or timed out. +Thus the specified test period may be dynamically expended in case of +overload. But maximum a latency close or above the period will clearly +indicate this. +
doc/txt/Makefile.am +1 -0
@@ -2,6 +2,7 @@ txtdocdir = $(datadir)/doc/$(PACKAGE)-$( dist_txtdoc_DATA = \ 16550A-driver.txt \ + irqbench.txt \ pse51-skin.txt \ psos-skin.txt \ rtai-skin.txt \
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
In reply to [email protected]Quoted 296 lines · [email protected] wrote:
Index:
xenomai/src/testsuite/irqbench/irqbench.c
===================================================================src/testsuite/irqbench/irqbench.c new file +291
-0@@ -0,0 +1,301 @@ +/* +* Copyright (C) 2006 Jan Kiszka <[email protected]>. +* +* Xenomai is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* Xenomai is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Xenomai; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <unistd.h> +#include <sys/io.h> +#include <sys/mman.h> + + +#define SERPORT 0 +#define PARPORT 1 + +/* --- Serial port --- */ + +#define MCR_DTR 0x01 +#define MCR_RTS 0x02 +#define MCR_OUT2 0x08 + +#define MSR_DELTA 0x0F + +#define LCR (base) (base + 3)/* Line Control Register */ +#define MCR (base) (base + 4)/* Modem Control Register */ +#define LSR (base) (base + 5)/* Line Status Register */ +#define MSR (base) (base + 6)/* Modem Status Register */ + +/* --- Parallel port --- */ + +#define CTRL_INIT 0x04 + +#define STAT_STROBE 0x10 + +#define DATA (base) (base + 0)/* Data register */ +#define STAT (base) (base + 1)/* Status register */ +#define CTRL (base) (base + 2)/* Control register */ + +double tsc2ns_scale; +long long min_lat =LLONG_MAX ; +long long max_lat =LLONG_MIN ; +long long avg_lat =0 ; +long outer_loops =0 ; +int warmup =1 ; + +static inline long long rdtsc (void ) +{ +unsigned long long tsc; + + __asm__ __volatile__("rdtsc" :"=A" (tsc)); +return tsc; +} + + +static long tsc2ns (long long tsc) +{ +if ((tsc >LONG_MAX ) || (tsc <LONG_MIN )) { +fprintf (stderr,"irqbench: overflow (%lld ns)!\n" , + (long long )(tsc2ns_scale * (double )tsc)); +exit (2 ); + } +return (long )(tsc2ns_scale * (double )tsc); +} + + +static inline long long ns2tsc (long long ns) +{ +return (long long )(((double )ns) / tsc2ns_scale); +} + + +void calibrate_tsc (void ) +{ +FILE *proc; +char *lineptr =NULL ; +size_t len; +double cpu_mhz; + + proc =fopen ("/proc/cpuinfo" ,"r" ); +if (proc ==NULL ) { +perror ("irqbench: Unable to open /proc/cpuinfo" ); +exit (1 ); + } + +while (getline (&lineptr, &len, proc) !=-1 ) +if (strncmp (lineptr,"cpu MHz" ,7 ) ==0 ) { +sscanf (strchr (lineptr,':' ) +1 ,"%lf" , &cpu_mhz); +break ; + } + +if (lineptr) +free (lineptr); +fclose (proc); + +printf ("CPU frequency: %.3lf MHz\n" , cpu_mhz); + + tsc2ns_scale =1000.0 / cpu_mhz; +} + + +void sighand (int signal) +{ +if (!warmup) { + avg_lat /= outer_loops; +printf ("---\n%.3f / %.3f / %.3f us\n" , + ((double )min_lat) /1000.0 , ((double )avg_lat) /1000.0 , + ((double )max_lat) /1000.0 ); + } +exit (0 ); +} + + +int main (int argc,char *argv[]) +{ +int port_type =SERPORT ; +unsigned long port_ioaddr =0x3F8 ; +long long period =100000 ; +long long timeout; +long long start, delay; +unsigned int toggle; +int trigger_trace =0 ; +int c; + + +signal (SIGINT , sighand); +signal (SIGTERM , sighand); +signal (SIGHUP , sighand); +signal (SIGALRM , sighand); + +calibrate_tsc (); + +while ((c =getopt (argc,argv,"p:T:o:a:f" )) !=EOF ) +switch (c) { +case 'p' : + period =atoi (optarg) *1000 ; +break ; + +case 'T' : +alarm (atoi (optarg)); +break ; + +case 'o' : + port_type =atoi (optarg); +break ; + +case 'a' : + port_ioaddr =strtol (optarg,NULL , + (strncmp (optarg,"0x" ,2 ) ==0 ) ?16 :10 ); +break ; + +case 'f' : + trigger_trace =1 ; +break ; + +default : +fprintf (stderr,"usage: irqbench [options]\n" +" [-p <period_us>] # signal period, default=100 us\n" +" [-T <test_duration_seconds>] # default=0, so ^C to end\n" +" [-o <port_type>] # 0=serial (default), 1=parallel\n" +" [-a <port_io_address>] # default=0x3f8\n" +" [-f] # freeze trace for each new max latency\n" ); +exit (2 ); + } + +if (iopl (3 ) <0 ) { +fprintf (stderr,"irqbench: superuser permissions required\n" ); +exit (1 ); + } +mlockall (MCL_CURRENT |MCL_FUTURE ); + +switch (port_type) { +case SERPORT : + toggle =MCR_OUT2 ; +inb (MSR (port_ioaddr)); +break ; + +case PARPORT : + toggle =0xAA ; +outb (0xAA ,DATA (port_ioaddr)); +outb (CTRL_INIT ,CTRL (port_ioaddr)); +break ; + +default : +fprintf (stderr,"irqbench: invalid port type\n" ); +exit (1 ); + } + + period =ns2tsc (period); + +printf ("Port type: %s\n" +"Port address: 0x%lx\n\n" , + (port_type ==SERPORT ) ?"serial" :"parallel" , port_ioaddr); + +printf ("Waiting on target...\n" ); + +while (1 ) +if (port_type ==SERPORT ) { + toggle ^=MCR_RTS ; +outb (toggle,MCR (port_ioaddr)); +usleep (100000 ); +if ((inb (MSR (port_ioaddr)) &MSR_DELTA ) !=0 ) +break ; + }else { +int status =inb (STAT (port_ioaddr)); + + toggle ^=0xFF ; +outb (toggle,DATA (port_ioaddr)); +if (inb (STAT (port_ioaddr)) != status) +break ; + } + +printf ("Warming up...\n" ); + +while (1 ) { +long long loop_timeout =rdtsc () +ns2tsc (1000000000LL ); +long loop_avg =0 ; +int inner_loops; + +for (inner_loops =0 ;rdtsc () < loop_timeout; inner_loops++) { +long lat; + + __asm__ __volatile__("cli" ); + +if (port_type ==SERPORT ) { + start =rdtsc (); + + toggle ^=MCR_RTS ; +outb (toggle,MCR (port_ioaddr)); + + timeout = start + period *100 ; +while (((inb (MSR (port_ioaddr)) &MSR_DELTA ) ==0 ) && + (rdtsc () < timeout)); + + delay =rdtsc () - start; + }else { +int status =inb (STAT (port_ioaddr)); + + start =rdtsc (); + + toggle ^=0xFF ; +outb (toggle,DATA (port_ioaddr)); + + timeout = start + period *100 ; +while ((inb (STAT (port_ioaddr)) == status) && + (rdtsc () < timeout)); + + delay =rdtsc () - start; + } + +if (!warmup) { + lat =tsc2ns (delay); + + loop_avg += lat; +if (lat < min_lat) + min_lat = lat; +if (lat > max_lat) { + max_lat = lat; +if (trigger_trace) { +if (port_type ==SERPORT ) { + toggle ^=MCR_DTR ; +outb (toggle,MCR (port_ioaddr)); + }else { +// todo + } + } + } + } + + __asm__ __volatile__("sti" ); + +while (rdtsc () < start + period); + } +if (!warmup) { + loop_avg /= inner_loops; +
src/testsuite/irqbench/irqbench.c line 301
Quoted 10 lines
src/testsuite/irqbench/irqbench.c new file +10
-0+printf ("%.3f / %.3f / %.3f us\n" , + ((double )min_lat) /1000.0 , ((double )loop_avg) /1000.0 , + ((double )max_lat) /1000.0 ); + + avg_lat += loop_avg; + outer_loops++; + }else + warmup =0 ; + } +}
Is there no way to make this code easier to port for example by using native or posix services for timings measurement and by abstracting the non portable part and moving them to include/asm-i386 ?
Also note that calling printf from a signal handler risk deadlocking if the signal handler get called on the return path of the write call that take place in the middle of a printf call on the main thread.
Signature · 1 line
Gilles Chanteperdrix.
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 303 lines · Gilles Chanteperdrix
Quoted 302 lines · [email protected] wrote:
Index:
xenomai/src/testsuite/irqbench/irqbench.c
===================================================================src/testsuite/irqbench/irqbench.c new file +297
-0@@ -0,0 +1,301 @@ +/* +* Copyright (C) 2006 Jan Kiszka <[email protected]>. +* +* Xenomai is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* Xenomai is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Xenomai; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <unistd.h> +#include <sys/io.h> +#include <sys/mman.h> + + +#define SERPORT 0 +#define PARPORT 1 + +/* --- Serial port --- */ + +#define MCR_DTR 0x01 +#define MCR_RTS 0x02 +#define MCR_OUT2 0x08 + +#define MSR_DELTA 0x0F + +#define LCR (base) (base + 3)/* Line Control Register */ +#define MCR (base) (base + 4)/* Modem Control Register */ +#define LSR (base) (base + 5)/* Line Status Register */ +#define MSR (base) (base + 6)/* Modem Status Register */ + +/* --- Parallel port --- */ + +#define CTRL_INIT 0x04 + +#define STAT_STROBE 0x10 + +#define DATA (base) (base + 0)/* Data register */ +#define STAT (base) (base + 1)/* Status register */ +#define CTRL (base) (base + 2)/* Control register */ + +double tsc2ns_scale; +long long min_lat =LLONG_MAX ; +long long max_lat =LLONG_MIN ; +long long avg_lat =0 ; +long outer_loops =0 ; +int warmup =1 ; + +static inline long long rdtsc (void ) +{ +unsigned long long tsc; + + __asm__ __volatile__("rdtsc" :"=A" (tsc)); +return tsc; +} + + +static long tsc2ns (long long tsc) +{ +if ((tsc >LONG_MAX ) || (tsc <LONG_MIN )) { +fprintf (stderr,"irqbench: overflow (%lld ns)!\n" , + (long long )(tsc2ns_scale * (double )tsc)); +exit (2 ); + } +return (long )(tsc2ns_scale * (double )tsc); +} + + +static inline long long ns2tsc (long long ns) +{ +return (long long )(((double )ns) / tsc2ns_scale); +} + + +void calibrate_tsc (void ) +{ +FILE *proc; +char *lineptr =NULL ; +size_t len; +double cpu_mhz; + + proc =fopen ("/proc/cpuinfo" ,"r" ); +if (proc ==NULL ) { +perror ("irqbench: Unable to open /proc/cpuinfo" ); +exit (1 ); + } + +while (getline (&lineptr, &len, proc) !=-1 ) +if (strncmp (lineptr,"cpu MHz" ,7 ) ==0 ) { +sscanf (strchr (lineptr,':' ) +1 ,"%lf" , &cpu_mhz); +break ; + } + +if (lineptr) +free (lineptr); +fclose (proc); + +printf ("CPU frequency: %.3lf MHz\n" , cpu_mhz); + + tsc2ns_scale =1000.0 / cpu_mhz; +} + + +void sighand (int signal) +{ +if (!warmup) { + avg_lat /= outer_loops; +printf ("---\n%.3f / %.3f / %.3f us\n" , + ((double )min_lat) /1000.0 , ((double )avg_lat) /1000.0 , + ((double )max_lat) /1000.0 ); + } +exit (0 ); +} + + +int main (int argc,char *argv[]) +{ +int port_type =SERPORT ; +unsigned long port_ioaddr =0x3F8 ; +long long period =100000 ; +long long timeout; +long long start, delay; +unsigned int toggle; +int trigger_trace =0 ; +int c; + + +signal (SIGINT , sighand); +signal (SIGTERM , sighand); +signal (SIGHUP , sighand); +signal (SIGALRM , sighand); + +calibrate_tsc (); + +while ((c =getopt (argc,argv,"p:T:o:a:f" )) !=EOF ) +switch (c) { +case 'p' : + period =atoi (optarg) *1000 ; +break ; + +case 'T' : +alarm (atoi (optarg)); +break ; + +case 'o' : + port_type =atoi (optarg); +break ; + +case 'a' : + port_ioaddr =strtol (optarg,NULL , + (strncmp (optarg,"0x" ,2 ) ==0 ) ?16 :10 ); +break ; + +case 'f' : + trigger_trace =1 ; +break ; + +default : +fprintf (stderr,"usage: irqbench [options]\n" +" [-p <period_us>] # signal period, default=100 us\n" +" [-T <test_duration_seconds>] # default=0, so ^C to end\n" +" [-o <port_type>] # 0=serial (default), 1=parallel\n" +" [-a <port_io_address>] # default=0x3f8\n" +" [-f] # freeze trace for each new max latency\n" ); +exit (2 ); + } + +if (iopl (3 ) <0 ) { +fprintf (stderr,"irqbench: superuser permissions required\n" ); +exit (1 ); + } +mlockall (MCL_CURRENT |MCL_FUTURE ); + +switch (port_type) { +case SERPORT : + toggle =MCR_OUT2 ; +inb (MSR (port_ioaddr)); +break ; + +case PARPORT : + toggle =0xAA ; +outb (0xAA ,DATA (port_ioaddr)); +outb (CTRL_INIT ,CTRL (port_ioaddr)); +break ; + +default : +fprintf (stderr,"irqbench: invalid port type\n" ); +exit (1 ); + } + + period =ns2tsc (period); + +printf ("Port type: %s\n" +"Port address: 0x%lx\n\n" , + (port_type ==SERPORT ) ?"serial" :"parallel" , port_ioaddr); + +printf ("Waiting on target...\n" ); + +while (1 ) +if (port_type ==SERPORT ) { + toggle ^=MCR_RTS ; +outb (toggle,MCR (port_ioaddr)); +usleep (100000 ); +if ((inb (MSR (port_ioaddr)) &MSR_DELTA ) !=0 ) +break ; + }else { +int status =inb (STAT (port_ioaddr)); + + toggle ^=0xFF ; +outb (toggle,DATA (port_ioaddr)); +if (inb (STAT (port_ioaddr)) != status) +break ; + } + +printf ("Warming up...\n" ); + +while (1 ) { +long long loop_timeout =rdtsc () +ns2tsc (1000000000LL ); +long loop_avg =0 ; +int inner_loops; + +for (inner_loops =0 ;rdtsc () < loop_timeout; inner_loops++) { +long lat; + + __asm__ __volatile__("cli" ); + +if (port_type ==SERPORT ) { + start =rdtsc (); + + toggle ^=MCR_RTS ; +outb (toggle,MCR (port_ioaddr)); + + timeout = start + period *100 ; +while (((inb (MSR (port_ioaddr)) &MSR_DELTA ) ==0 ) && + (rdtsc () < timeout)); + + delay =rdtsc () - start; + }else { +int status =inb (STAT (port_ioaddr)); + + start =rdtsc (); + + toggle ^=0xFF ; +outb (toggle,DATA (port_ioaddr)); + + timeout = start + period *100 ; +while ((inb (STAT (port_ioaddr)) == status) && + (rdtsc () < timeout)); + + delay =rdtsc () - start; + } + +if (!warmup) { + lat =tsc2ns (delay); + + loop_avg += lat; +if (lat < min_lat) + min_lat = lat; +if (lat > max_lat) { + max_lat = lat; +if (trigger_trace) { +if (port_type ==SERPORT ) { + toggle ^=MCR_DTR ; +outb (toggle,MCR (port_ioaddr)); + }else { +// todo + } + } + } + } + + __asm__ __volatile__("sti" ); + +while (rdtsc () < start + period); + } +if (!warmup) { + loop_avg /= inner_loops; + +printf ("%.3f / %.3f / %.3f us\n" , + ((double )min_lat) /1000.0 , ((double )loop_avg) /1000.0 , + ((double )max_lat) /1000.0 ); + + avg_lat += loop_avg; + outer_loops++;
Quoted 8 lines
src/testsuite/irqbench/irqbench.c line 301
Quoted 4 lines
src/testsuite/irqbench/irqbench.c new file +4
-0+ }else + warmup =0 ; + } +}Is there no way to make this code easier to port for example by using native or posix services for timings measurement and by abstracting the non portable part and moving them to
include/asm-i386?
This tool is intentionally left Xenomai-free. You can put it on any x86 box around (and I assume that there is almost always some...) and run the test. Thus, no need for a second RT-patched system.
Anyway, suggestions or patches to add a porting layer are welcome. The following points need to be addressed: time measuring, irq protection, hardware access. I just wonder if this is worth the effort.
Quoted 5 lines
Also note that calling printf from a signal handler risk deadlocking if the signal handler get called on the return path of the write call that take place in the middle of a printf call on the main thread.
Ok, then we also need a fix for the latency test (this is where I grabbed that pattern from). Is there a high risk that this locks up? I wonder why I never observed or heard of problems with latency.
Jan
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 9 lines · Jan Kiszka
Quoted 5 lines
Also note that calling printf from a signal handler risk deadlocking if the signal handler get called on the return path of the write call that take place in the middle of a printf call on the main thread.
Ok, then we also need a fix for the latency test (this is where I grabbed that pattern from). Is there a high risk that this locks up? I wonder why I never observed or heard of problems with latency.
The mutex used by the stdio lib depends on the file descriptor, so, it is possible to use a different file descriptor in the signal handler and on the interrupted context.
Signature · 1 line
Gilles Chanteperdrix.
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
In reply to Jan KiszkaQuoted 11 lines · Jan Kiszka
Quoted 3 lines
Is there no way to make this code easier to port for example by using native or posix services for timings measurement and by abstracting the non portable part and moving them to
include/asm-i386?This tool is intentionally left Xenomai-free. You can put it on any x86 box around (and I assume that there is almost always some...) and run the test. Thus, no need for a second RT-patched system.
Anyway, suggestions or patches to add a porting layer are welcome. The following points need to be addressed: time measuring, irq protection, hardware access. I just wonder if this is worth the effort.
I do not understand: it appears to me that Xenomai trunk does not compile on other architectures than x86 when applying the IRQ latency benchmark patch. So, something needs to be done. It may be the enabling of an automake conditional in configure.in when compiling for x86.
Quoted 10 lines
Quoted 6 lines
Also note that calling printf from a signal handler risk deadlocking if the signal handler get called on the return path of the write call that take place in the middle of a printf call on the main thread.
Ok, then we also need a fix for the latency test (this is where I grabbed that pattern from). Is there a high risk that this locks up? I wonder why I never observed or heard of problems with latency.
The latency test used to deadlock, that is why the summary printed on signal is printed on stderr. Unfortunately, there seem to be one display left on stdout, so it should still deadlock. The reason why we never see the deadlock is (perhaps) that the continuous intermediate results are printed on the context of the "display" thread, whereas the termination signals are preferably delivered by the kernel to the "main" thread, that only calls pause. Which makes the use of stderr in signals handlers pointless.
Anyway, since your program is frequently using printf on the context of the main thread, the risk of deadlock is real.
Signature · 1 line
Gilles Chanteperdrix.
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
Ok, then we also need a fix for the latency test (this is where I grabbed that pattern from). Is there a high risk that this locks up? I wonder why I never observed or heard of problems with latency.
Quoted 8 lines
The latency test used to deadlock, that is why the summary printed on signal is printed on stderr. Unfortunately, there seem to be one display left on stdout, so it should still deadlock. The reason why we never see the deadlock is (perhaps) that the continuous intermediate results are printed on the context of the "display" thread, whereas the termination signals are preferably delivered by the kernel to the "main" thread, that only calls pause. Which makes the use of stderr in signals handlers pointless.
It's very likely so.
The main thread would use instead something like :
...
while (!sig_term_received)
pause();
do_cleanup_chores();
return 0;
cleanup_upon_sig() should only set the sig_term_received flag up.
Then all other threads must block signal delivering with sigprocmask() so that the main thread is the only one which "accepts" signals.
btw, according to POSIX 1003.1-2003, the write() call is amongst "safe" ones.
http://www.die.net/doc/linux/man/man2/signal.2.html
So write(1, ....); heh... not that nice? :)
Signature · 2 lines
Best regards, Dmitry Adamushko
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 23 lines · Dmitry Adamushko
Quoted 6 lines · Gilles Chanteperdrix
Quoted 4 lines · Jan Kiszka
Ok, then we also need a fix for the latency test (this is where I grabbed that pattern from). Is there a high risk that this locks up? I wonder why I never observed or heard of problems with latency.
Quoted 8 lines
The latency test used to deadlock, that is why the summary printed on signal is printed on stderr. Unfortunately, there seem to be one display left on stdout, so it should still deadlock. The reason why we never see the deadlock is (perhaps) that the continuous intermediate results are printed on the context of the "display" thread, whereas the termination signals are preferably delivered by the kernel to the "main" thread, that only calls pause. Which makes the use of stderr in signals handlers pointless.
It's very likely so.
The main thread would use instead something like :
...
while (!sig_term_received)
pause();
Quoted 7 lines
do_cleanup_chores();
return 0;
cleanup_upon_sig()should only set thesig_term_receivedflag up.Then all other threads must block signal delivering with
sigprocmask()so that the main thread is the only one which "accepts" signals.
Is that required, i.e. does pause() only wake up if the signal handler executed in the main thread's context? Then cyclictest contains a bug as well...
Quoted 8 lines
btw, according to POSIX 1003.1-2003, the
write()call is amongst "safe" ones.
http://www.die.net/doc/linux/man/man2/signal.2.htmlSo
write(1, ....); heh... not that nice? :)
Something like this? Developed on top of my prio-switch patch. So far without signal masking.
Jan
--- src/testsuite/latency/latency.c | 46 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
src/testsuite/latency/latency.c +24 -22
@@ -293,7 +293,7 @@ double dump_histogram (long *histogram,double avg =0 ;/* used to sum hits 1st */ if (do_histogram) -fprintf (stderr,"---|--param|----range-|--samples\n" ); +printf ("---|--param|----range-|--samples\n" );for (n =0 ; n < histogram_size; n++) {
@@ -304,12 +304,11 @@ double dump_histogram (long *histogram, total_hits += hits; avg += n * hits;if (do_histogram) -fprintf (stderr, -"HSD| %s| %3d -%3d | %8ld\n" , - kind, - n, - n+1 , - hits); +printf ("HSD| %s| %3d -%3d | %8ld\n" , + kind, + n, + n+1 , + hits); } }
@@ -338,8 +337,8 @@ void dump_stats (long *histogram, char* variance /= total_hits -1 ; variance =sqrt (variance); -fprintf (stderr,"HSS| %s| %9d| %10.3f| %10.3f\n" , - kind, total_hits, avg, variance); +printf ("HSS| %s| %9d| %10.3f| %10.3f\n" , + kind, total_hits, avg, variance); }void dump_hist_stats (void )
@@ -351,23 +350,18 @@ void dump_hist_stats (void) avgavg =dump_histogram (histogram_avg,"avg" ); maxavg =dump_histogram (histogram_max,"max" ); -fprintf (stderr,"HSH|--param|--samples-|--average--|---stddev--\n" ); +printf ("HSH|--param|--samples-|--average--|---stddev--\n" );dump_stats (histogram_min,"min" , minavg);dump_stats (histogram_avg,"avg" , avgavg);dump_stats (histogram_max,"max" , maxavg); } -void cleanup_upon_sig (int sig __attribute__((unused))) +void cleanup (void ) {time_t actual_duration;long gmaxj, gminj, gavgj; -if (finished) -return ; - - finished =1 ; -if (test_mode ==USER_TASK ) {rt_sem_delete (&display_sem);
@@ -421,6 +415,11 @@ void cleanup_upon_sig(int sig __attributexit (0 ); } +void sighand (int sig __attribute__((unused))) +{ + finished =1 ; +} +int main (int argc,char **argv) {int c, err;
@@ -532,7 +531,7 @@ int main (int argc, char **argv) histogram_min =calloc (histogram_size,sizeof (long ));if (!(histogram_avg && histogram_max && histogram_min)) -cleanup_upon_sig (0 ); +cleanup ();if (period_ns ==0 ) period_ns =100000LL ;/* ns */
@@ -542,10 +541,10 @@ int main (int argc, char **argv)else if (priority >T_HIPRIO ) priority =T_HIPRIO ; -signal (SIGINT , cleanup_upon_sig); -signal (SIGTERM , cleanup_upon_sig); -signal (SIGHUP , cleanup_upon_sig); -signal (SIGALRM , cleanup_upon_sig); +signal (SIGINT , sighand); +signal (SIGTERM , sighand); +signal (SIGHUP , sighand); +signal (SIGALRM , sighand);setlinebuf (stdout);
@@ -610,7 +609,10 @@ int main (int argc, char **argv) } } -pause (); +while (!finished) +pause (); + +cleanup ();return 0 ; }
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 7 lines
Quoted 3 lines
Then all other threads must block signal delivering with
sigprocmask()so that the main thread is the only one which "accepts" signals.Is that required, i.e. does
pause()only wake up if the signal handler executed in the main thread's context? Then cyclictest contains a bug as well...
If strictly speaking, then yes, it's required. But I expect your fix to be working perfectly, just because the current linux implementation always favors the main thread when it comes to choosing a thread to handle the signal.
look at signal.c :: __group_complete_signal() routine where the actual magic happens.
from the comments
/*
* Now find a thread we can wake up to take the signal off the queue. *
* If the main thread wants the signal, it gets first crack.
* Probably the least surprising to the average bear.
*/
...
As I understand, the only case when another thread may handle the signal indeed is when the main thread has already another pending signal. But even then nothing bad happens as pause() (in the main thread) will be interrupted by this pending signal. Just "finished" will be set up by some other thread but it doesn't really matter.
Signature · 2 lines
Best regards, Dmitry Adamushko
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
In reply to Gilles ChanteperdrixQuoted 9 lines · Gilles Chanteperdrix
Quoted 8 lines · Jan Kiszka
Quoted 3 lines
Is there no way to make this code easier to port for example by using native or posix services for timings measurement and by abstracting the non portable part and moving them to
include/asm-i386?This tool is intentionally left Xenomai-free. You can put it on any x86 box around (and I assume that there is almost always some...) and run the test. Thus, no need for a second RT-patched system.
Quoted 9 lines
Quoted 3 lines
Anyway, suggestions or patches to add a porting layer are welcome. The following points need to be addressed: time measuring, irq protection, hardware access. I just wonder if this is worth the effort.
I do not understand: it appears to me that Xenomai trunk does not compile on other architectures than x86 when applying the IRQ latency benchmark patch. So, something needs to be done. It may be the enabling of an automake conditional in configure.in when compiling for x86.
See the patch:
src/testsuite/irqbench/Makefile.am new file +7 -0
@@ -0,0 +1,47 @@ +testdir = $(prefix)/testsuite/irqbench + +test_PROGRAMS = irqloop + +ifeq ($(XENO_TARGET_ARCH),i386) +test_PROGRAMS += irqbench +endif
I just realised that some hint in the documentation that irqbench can easily be compiled outside Xenomai is required.
Quoted 20 lines
Quoted 10 lines
Quoted 6 lines
Also note that calling printf from a signal handler risk deadlocking if the signal handler get called on the return path of the write call that take place in the middle of a printf call on the main thread.
Ok, then we also need a fix for the latency test (this is where I grabbed that pattern from). Is there a high risk that this locks up? I wonder why I never observed or heard of problems with latency.
The latency test used to deadlock, that is why the summary printed on signal is printed on stderr. Unfortunately, there seem to be one display left on stdout, so it should still deadlock. The reason why we never see the deadlock is (perhaps) that the continuous intermediate results are printed on the context of the "display" thread, whereas the termination signals are preferably delivered by the kernel to the "main" thread, that only calls pause. Which makes the use of stderr in signals handlers pointless.
Quoted 3 lines
Anyway, since your program is frequently using printf on the context of the main thread, the risk of deadlock is real.
Ok, I'm going to address this.
Thanks for the hint!
Jan
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
In reply to [email protected]Here comes an update of the irqbench patch.
Changelog:
- avoid printf from signal context in irqloop
- reorder irq-enable code in the driver to avoid spurious replies on startup
- avoid creating/destroying pthread under SCHED_FIFO (but still suffers from prio inversion during cleanup here)
- fix broken conditional compilation of irqbench for x86 (probably unnoticed due to forgotten bootstrap run, sigh)
- include irqbench-doc.patch
Jan
Subject: Introduce IRQ latency benchmark
This patch introduces another rttesting driver, xeno_irqbench, for measuring external IRQ latencies. The irqbench device is controlled by a user-mode tool irqloop. A second tool for plain Linux, irqbench, is provided to trigger the event over serial or parallel cross-link (the latter is incomplete yet) and measure the reaction latency.
--- configure.in | 2 doc/txt/Makefile.am | 1 doc/txt/irqbench.txt | 51 ++++ include/rtdm/rttesting.h | 38 ++ ksrc/drivers/Makefile | 2 ksrc/drivers/testing/Kconfig | 21 + ksrc/drivers/testing/Makefile | 13 - ksrc/drivers/testing/irqbench.c | 470 +++++++++++++++++++++++++++++++++++++ src/testsuite/Makefile.am | 2 src/testsuite/irqbench/Makefile.am | 47 +++ src/testsuite/irqbench/irqbench.c | 306 ++++++++++++++++++++++++ src/testsuite/irqbench/irqloop.c | 173 +++++++++++++ src/testsuite/irqbench/runinfo | 1 13 files changed, 1116 insertions(+), 11 deletions(-)
include/rtdm/rttesting.h +38 -0
@@ -94,6 +94,28 @@ typedef struct rttst_tmbench_config { } rttst_tmbench_config_t; +#define RTTST_IRQBENCH_USER_TASK 0 +#define RTTST_IRQBENCH_KERNEL_TASK 1 +#define RTTST_IRQBENCH_HANDLER 2 + +#define RTTST_IRQBENCH_SERPORT 0 +#define RTTST_IRQBENCH_PARPORT 1 + +struct rttst_irqbench_config { +int mode; +int priority; +int calibration_loops; +unsigned int port_type; +unsigned long port_ioaddr; +unsigned int port_irq; +} rttst_irqbench_config_t; + +struct rttst_irqbench_stats { +unsigned long long irqs_received; +unsigned long long irqs_acknowledged; +} rttst_irqbench_stats_t; + +#define RTTST_SWTEST_FPU 0x1#define RTTST_SWTEST_USE_FPU 0x2/* Only for kernel-space tasks. */
@@ -134,6 +156,22 @@ struct rttst_swtest_dir { _IOWR(RTIOC_TYPE_TESTING, 0x11, struct rttst_overall_bench_res) +#define RTTST_RTIOC_IRQBENCH_START \ + _IOW(RTIOC_TYPE_TESTING, 0x20, struct rttst_irqbench_config) + +#define RTTST_RTIOC_IRQBENCH_STOP \ + _IO(RTIOC_TYPE_TESTING, 0x21) + +#define RTTST_RTIOC_IRQBENCH_GET_STATS \ + _IOR(RTIOC_TYPE_TESTING, 0x22, struct rttst_irqbench_stats) + +#define RTTST_RTIOC_IRQBENCH_WAIT_IRQ \ + _IO(RTIOC_TYPE_TESTING, 0x23) + +#define RTTST_RTIOC_IRQBENCH_REPLY_IRQ \ + _IO(RTIOC_TYPE_TESTING, 0x24) + +#define RTTST_RTIOC_SWTEST_SET_TASKS_COUNT \ _IOW(RTIOC_TYPE_TESTING, 0x30, unsigned long)
configure.in +2 -0
@@ -82,6 +82,7 @@ case "$host" in esac AC_MSG_RESULT([$XENO_TARGET_ARCH]) +AM_CONDITIONAL(XENO_TARGET_ARCH_I386,[test $XENO_TARGET_ARCH = i386]) dnl dnl Parse options
@@ -602,6 +603,7 @@ AC_CONFIG_FILES([ \ src/testsuite/switchbench/Makefile \ src/testsuite/cyclic/Makefile \ src/testsuite/switchtest/Makefile \ + src/testsuite/irqbench/Makefile \ include/Makefile \ include/asm-generic/Makefile \ include/asm-blackfin/Makefile \
ksrc/drivers/Makefile +1 -1
@@ -11,7 +11,7 @@ else subdir-$(CONFIG_XENO_DRIVERS_16550A) += 16550A subdir-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += testing - +subdir-$(CONFIG_XENO_DRIVERS_IRQBENCH) += testing subdir-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += testing include $(TOPDIR)/Rules.make
ksrc/drivers/testing/Kconfig +15 -6
@@ -6,10 +6,19 @@ config XENO_DRIVERS_TIMERBENCH Kernel-based benchmark driver for timer latency evaluation. See testsuite/latency for a possible front-end. +config XENO_DRIVERS_IRQBENCH + depends on XENO_SKIN_RTDM + tristate "IRQ benchmark driver" + default n + help + Loopback driver for IRQ latency evaluation over serial or parallel + port links. Additionally requires user-space helper and a logging tool + (see testsuite/irqbench). + config XENO_DRIVERS_SWITCHTEST - depends on XENO_SKIN_RTDM - tristate "Context switch unit testing driver" - default n - help - Kernel-based driver for unit testing context switches and - FPU switches. + depends on XENO_SKIN_RTDM + tristate "Context switch unit testing driver" + default n + help + Kernel-based driver for unit testing context switches and + FPU switches.
ksrc/drivers/testing/Makefile +10 -3
@@ -5,11 +5,13 @@ ifeq ($(PATCHLEVEL),6) EXTRA_CFLAGS += -Iinclude/xenomai obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o - +obj-$(CONFIG_XENO_DRIVERS_IRQBENCH) += xeno_irqbench.o obj-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += xeno_switchtest.o xeno_timerbench-y := timerbench.o +xeno_irqbench-y := irqbench.o + xeno_switchtest-y := switchtest.o EXTRA_CFLAGS += -Iinclude/xenomai
@@ -21,14 +23,16 @@ else O_TARGET := built-in.o obj-$(CONFIG_XENO_DRIVERS_TIMERBENCH) += xeno_timerbench.o - +obj-$(CONFIG_XENO_DRIVERS_IRQBENCH) += xeno_irqbench.o obj-$(CONFIG_XENO_DRIVERS_SWITCHTEST) += xeno_switchtest.o xeno_timerbench-objs := timerbench.o +xeno_irqbench-objs := irqbench.o + xeno_switchtest-objs := switchtest.o -export-objs := $(xeno_timerbench-objs) $(xeno_switchtest-objs) +export-objs := $(xeno_timerbench-objs) $(xeno_irqbench-objs) $(xeno_switchtest-objs) EXTRA_CFLAGS += -I$(TOPDIR)/include/xenomai -I$(TOPDIR)/include/xenomai/compat
@@ -37,6 +41,9 @@ include $(TOPDIR)/Rules.make xeno_timerbench.o: $(xeno_timerbench-objs) $(LD) -r -o $@ $(xeno_timerbench-objs) +xeno_irqbench.o: $(xeno_irqbench-objs) + $(LD) -r -o $@ $(xeno_irqbench-objs) + xeno_switchtest.o: $(xeno_switchtest-objs) $(LD) -r -o $@ $(xeno_switchtest-objs)
ksrc/drivers/testing/irqbench.c new file +470 -0
470 lines not on this page · raw message
src/testsuite/Makefile.am +1 -1
@@ -1 +1 @@ -SUBDIRS = latency switchbench cyclic switchtest +SUBDIRS = latency switchbench cyclic switchtest irqbench
src/testsuite/irqbench/Makefile.am new file +47 -0
47 lines not on this page · raw message
src/testsuite/irqbench/irqbench.c new file +306 -0
306 lines not on this page · raw message
src/testsuite/irqbench/irqloop.c new file +173 -0
173 lines not on this page · raw message
src/testsuite/irqbench/runinfo new file +1 -0
@@ -0,0 +1 @@ +irqloop:posix+rtdm+irqbench:!./irqloop;popall:control_c
doc/txt/Makefile.am +1 -0
@@ -2,6 +2,7 @@ txtdocdir = $(datadir)/doc/$(PACKAGE)-$( dist_txtdoc_DATA = \ 16550A-driver.txt \ + irqbench.txt \ pse51-skin.txt \ psos-skin.txt \ rtai-skin.txt \
doc/txt/irqbench.txt new file +51 -0
51 lines not on this page · raw message
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 2 lines · Jan Kiszka
Here comes an update of the irqbench patch.
And this add-on fixes a classic copy&paste issue.
Jan
--- ksrc/drivers/testing/irqbench.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
ksrc/drivers/testing/irqbench.c +4 -4
@@ -444,7 +444,7 @@ static struct rtdm_device device = { proc_name: device.device_name, }; -int __init __timerbench_init (void ) +int __init __irqbench_init (void ) {int ret;
@@ -460,11 +460,11 @@ int __init __timerbench_init(void) } -void __exit __timerbench_exit(void) +void __exit __irqbench_exit(void) {rtdm_dev_unregister (&device,1000 ); } -module_init (__timerbench_init); -module_exit (__timerbench_exit); +module_init (__irqbench_init); +module_exit (__irqbench_exit);
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 6 lines · Jan Kiszka
Quoted 2 lines · Jan Kiszka
Here comes an update of the irqbench patch.
And this add-on fixes a classic copy&paste issue.
Merged, along with the generic trace support. Thanks.
Signature · 1 line
Philippe.
Re: [Xenomai-core] [PATCH 6/6] Introduce IRQ latency benchmark
Quoted 10 lines · Philippe Gerum
Quoted 6 lines · Jan Kiszka
Quoted 2 lines · Jan Kiszka
Here comes an update of the irqbench patch.
And this add-on fixes a classic copy&paste issue.
Merged, along with the generic trace support. Thanks.
Almost :) - but it's fixed now.
Jan