Re: [Xenomai-core] Latency spots due to involuntary mode switches to secondary mode.

2010-01-17 Thread Philippe Gerum
On Fri, 2010-01-08 at 11:14 +0100, Gilles Chanteperdrix wrote:
 Hi,
 
 due to bugs, it may happen that the latency test spots are due to
 involuntary mode switches to secondary mode. This is bad, because users
 testing xenomai quickly on their platform may find a bad latency, and go
 quickly to conclusions without even posting a mail on the mailing lists.
 
 Avoiding this looks simple: we should enable T_WARNSW on the sampling
 thread, and make it the default behaviour. But unfortunately, there are
 platforms around such as some low-end ppc where switches to secondary
 mode are normal, so stopping the test when hitting such mode switches
 may not be the best thing to do.
 
 So, what do you think should be done?
 

Let's report those switches in the test output without stopping it, so
that we may have some hints when pathological latencies happen.


-- 
Philippe.



___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [Adeos-main] I-pipe for 2.6.32 PPC

2010-01-17 Thread Philippe Gerum
On Thu, 2010-01-14 at 08:53 +0100, Richard Cochran wrote: 
 On Tue, Jan 12, 2010 at 05:18:02PM -0500, Lennart Sorensen wrote:
  Well I have not been able to find the magic invocation that lets me take
  the DENX tree (which I have had around for a long time just to look at
  occationally, whenever I was trying to get an ipipe patch to apply),
  apply the ipipe patch, revert the DENX changes to get back to a release
  kernel, and generate a diff of the ipipe changes.  It has never worked
  when I tried.
 
 Lennart,
 
 It is not so hard (using git) to remove the Denx patches from the
 ipipe tree. I did this myself for 2.6.30 in about a half an hour. If
 you don't know how to use git, then you would have to consider the
 additional time you need to get to understand it. (For me, it was only
 a year or so ;)
 
 In the ipipe tree, the Denx commits have been squashed together into
 one or two really large commits. So, you can just cherry pick the
 adeos commits into a new branch, with a few minor fixups.
 
 Philippe,
 
 I actually agree with Lennart that the Denx stuff is an
 annoyance. When considering my no-denx branch that I made, I could
 not see any significant Denx change that adeos builds upon. There were
 a few Denx fixes for one specific board that were close to the adeos
 changes, but these were only a few, and easy to fix. So, I could not
 understand why Denx is a prerequisite for adeos.
 

As I explained earlier in my reply to Lennart, the DENX tree is not a
pre-requisite for having the pipeline run on each and every hw platform,
but this is still the case for some, because they are not
stable/complete/good enough in mainline yet. The reason to stick with it
stems from this fact.

What has to be reassessed, is the number of platforms Xenomai supports
that still need DENX bits today; if only a few of them remain in this
category, then it's probably sound to start maintaining the pipeline
support for them in a separate tree, rebasing I-pipe mainline over Linux
mainline for ppc as well. I have no issue with that.

 I understand that Denx sponsored the original PowerPC Xenomai port. Is
 the reason that ipipe is based on Denx simply to honor that fact? If
 so, I would not think it a bad reason at all.
 

No, it's not, because if I had chosen to base the pipeline code for ppc
over mainline at that time, I would have maintained a DENX-based version
for the very reason you mentioned, until it proves useless.

 However, I would still prefer the following ordering for the changes:
 
 1. stable linux (2.6.xx.y)
 2. adeos arch indepedendent
 3. adeos powerpc
 4. denx
 5. adeos for denx (minimal changes, I expect)
 

What we may be aiming at, if workable, is something like:

ipipe-*-mainline
ipipe-*-amcc
ipipe-*-512x

Maybe one for the PA6T as well, if we want to keep supporting the old A2
board rev. I'm unsure right now, since B0 is fine in mainline already.

A mainline pipeline branch for everything that directly works over
mainline, and platform-specific branches for those that do not. Those
special branches would then disappear as soon as mainline is fine for
the platforms they host as well.

 Richard
 
 ___
 Adeos-main mailing list
 adeos-m...@gna.org
 https://mail.gna.org/listinfo/adeos-main


-- 
Philippe.






___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


[Xenomai-core] debugging stuff, take 2

2010-01-17 Thread Gilles Chanteperdrix
Hi,

here is a second attempt of debugging stuff, taking into account the previous
remarks.

-- 
Gilles Chanteperdrix



___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


[Xenomai-core] [PATCH 2/3] skins: fault the main thread stack when shadowing it.

2010-01-17 Thread Gilles Chanteperdrix
---
 include/asm-generic/bits/bind.h |2 ++
 src/skins/common/bind.c |   14 ++
 src/skins/native/task.c |2 ++
 src/skins/posix/thread.c|2 ++
 src/skins/psos+/task.c  |2 ++
 src/skins/uitron/task.c |9 +++--
 6 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/bits/bind.h b/include/asm-generic/bits/bind.h
index 7267e0d..f43e096 100644
--- a/include/asm-generic/bits/bind.h
+++ b/include/asm-generic/bits/bind.h
@@ -37,4 +37,6 @@ xeno_bind_skin(unsigned skin_magic, const char *skin,
return muxid;
 }
 
+void xeno_fault_stack(void);
+
 #endif /* _XENO_ASM_GENERIC_BITS_BIND_H */
diff --git a/src/skins/common/bind.c b/src/skins/common/bind.c
index 44017e8..0717ac1 100644
--- a/src/skins/common/bind.c
+++ b/src/skins/common/bind.c
@@ -7,8 +7,10 @@
 #include asm/xenomai/syscall.h
 #include asm-generic/xenomai/bits/bind.h
 #include asm-generic/xenomai/bits/current.h
+#include asm-generic/xenomai/stacksize.h
 #include sem_heap.h
 
+static pthread_t xeno_main_tid;
 static xnsighandler *xnsig_handlers[32];
 
 void __attribute__((weak)) xeno_sigill_handler(int sig)
@@ -133,5 +135,17 @@ xeno_bind_skin_opt(unsigned skin_magic, const char *skin,
 
xeno_featinfo = finfo;
 
+   xeno_main_tid = pthread_self();
+   
return muxid;
 }
+
+void xeno_fault_stack(void)
+{
+   char stk[xeno_stacksize(1)];
+
+   if (pthread_self() != xeno_main_tid)
+   return;
+
+   stk[0] = stk[sizeof(stk) - 1] = 0xA5;
+}
diff --git a/src/skins/native/task.c b/src/skins/native/task.c
index 341e4d8..e0b3bbd 100644
--- a/src/skins/native/task.c
+++ b/src/skins/native/task.c
@@ -187,6 +187,8 @@ int rt_task_shadow(RT_TASK *task, const char *name, int 
prio, int mode)
RT_TASK *self;
int err;
 
+   xeno_fault_stack();
+
 #ifdef HAVE___THREAD
self = __native_self;
 #else /* !HAVE___THREAD */
diff --git a/src/skins/posix/thread.c b/src/skins/posix/thread.c
index 9115a58..dcc9373 100644
--- a/src/skins/posix/thread.c
+++ b/src/skins/posix/thread.c
@@ -43,6 +43,8 @@ int __wrap_pthread_setschedparam(pthread_t thread,
int err, promoted;
 
if (thread == myself) {
+   xeno_fault_stack();
+
 #ifdef HAVE___THREAD
mode_buf = xeno_init_current_mode();
 #else /* !HAVE___THREAD */
diff --git a/src/skins/psos+/task.c b/src/skins/psos+/task.c
index b5f36d2..4325a97 100644
--- a/src/skins/psos+/task.c
+++ b/src/skins/psos+/task.c
@@ -172,6 +172,8 @@ u_long t_shadow(const char *name, /* Xenomai extension. */
struct psos_arg_bulk bulk;
int ret;
 
+   xeno_fault_stack();
+
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
sigshadow_install_once();
 
diff --git a/src/skins/uitron/task.c b/src/skins/uitron/task.c
index 69022c2..ed91a09 100644
--- a/src/skins/uitron/task.c
+++ b/src/skins/uitron/task.c
@@ -23,11 +23,14 @@
 #include signal.h
 #include errno.h
 #include limits.h
+
 #include asm/xenomai/system.h
 #include asm-generic/bits/sigshadow.h
+#include asm-generic/bits/current.h
+#include asm-generic/stacksize.h
+#include asm-generic/bits/bind.h
 #include nucleus/sched.h
 #include uitron/uitron.h
-#include asm-generic/bits/current.h
 
 extern int __uitron_muxid;
 
@@ -149,7 +152,9 @@ ER shd_tsk(ID tskid, T_CTSK *pk_ctsk) /* Xenomai extension. 
*/
 {
struct sched_param param;
int policy, err;
-   
+
+   xeno_fault_stack();
+
/* Make sure the POSIX library caches the right priority. */
policy = uitron_task_set_posix_priority(pk_ctsk-itskpri, param);
pthread_setschedparam(pthread_self(), policy, param);
-- 
1.5.6.5


___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


[Xenomai-core] [PATCH 3/3] latency: account for and signal involuntary mode switches.

2010-01-17 Thread Gilles Chanteperdrix
---
 src/testsuite/latency/latency.c |  109 ---
 1 files changed, 78 insertions(+), 31 deletions(-)

diff --git a/src/testsuite/latency/latency.c b/src/testsuite/latency/latency.c
index f82a072..ca5f1bf 100644
--- a/src/testsuite/latency/latency.c
+++ b/src/testsuite/latency/latency.c
@@ -1,13 +1,16 @@
-#include sys/mman.h
-#include sys/time.h
-#include unistd.h
 #include stdlib.h
 #include math.h
 #include stdio.h
 #include string.h
 #include signal.h
-#include getopt.h
 #include time.h
+
+#include sys/mman.h
+#include sys/time.h
+#include unistd.h
+
+#include execinfo.h
+
 #include native/task.h
 #include native/timer.h
 #include native/sem.h
@@ -20,6 +23,7 @@ RT_SEM display_sem;
 #define ONE_BILLION  10
 #define TEN_MILLION1000
 
+unsigned max_relaxed;
 long minjitter, maxjitter, avgjitter;
 long gminjitter = TEN_MILLION, gmaxjitter = -TEN_MILLION, goverrun = 0;
 long long gavgjitter = 0;
@@ -32,6 +36,8 @@ int benchdev_no = 0;
 int benchdev = -1;
 int freeze_max = 0;
 int priority = T_HIPRIO;
+int stop_upon_switch = 0;
+sig_atomic_t sampling_relaxed = 0;
 
 #define USER_TASK   0
 #define KERNEL_TASK 1
@@ -70,8 +76,9 @@ static inline void add_histogram(long *histogram, long addval)
 void latency(void *cookie)
 {
int err, count, nsamples, warmup = 1;
-   RTIME expected_tsc, period_tsc, start_ticks;
+   RTIME expected_tsc, period_tsc, start_ticks, fault_threshold;
RT_TIMER_INFO timer_info;
+   unsigned old_relaxed = 0;
 
err = rt_timer_inquire(timer_info);
 
@@ -80,6 +87,7 @@ void latency(void *cookie)
return;
}
 
+   fault_threshold = rt_timer_ns2tsc(CONFIG_XENO_DEFAULT_PERIOD);
nsamples = ONE_BILLION / period_ns;
period_tsc = rt_timer_ns2tsc(period_ns);
/* start time: one millisecond from now. */
@@ -103,14 +111,22 @@ void latency(void *cookie)
test_loops++;
 
for (count = sumj = 0; count  nsamples; count++) {
+   unsigned new_relaxed;
unsigned long ov;
 
expected_tsc += period_tsc;
err = rt_task_wait_period(ov);
 
dt = (long)(rt_timer_tsc() - expected_tsc);
-   if (dt  maxj)
+   new_relaxed = sampling_relaxed;
+   if (dt  maxj) {
+   if (new_relaxed != old_relaxed 
+dt  fault_threshold)
+   max_relaxed += 
+   new_relaxed - old_relaxed;
maxj = dt;
+   }
+   old_relaxed = new_relaxed;
if (dt  minj)
minj = dt;
sumj += dt;
@@ -274,17 +290,17 @@ void display(void *cookie)
 (dt / 60) % 60, dt % 60,
 test_mode_names[test_mode],
 period_ns / 1000, priority);
-   printf(RTH|%12s|%12s|%12s|%8s|%12s|%12s\n,
-  -lat min, -lat avg,
-  -lat max, -overrun,
-  lat best, ---lat worst);
+   printf(RTH|%11s|%11s|%11s|%8s|%6s|%11s|%11s\n,
+  lat min, lat avg,
+  lat max, -overrun, ---msw,
+  ---lat best, --lat worst);
}
-
-   printf(RTD|%12.3f|%12.3f|%12.3f|%8ld|%12.3f|%12.3f\n,
+   
printf(RTD|%11.3f|%11.3f|%11.3f|%8ld|%6u|%11.3f|%11.3f\n,
   (double)minj / 1000,
   (double)avgj / 1000,
   (double)maxj / 1000,
   goverrun,
+  max_relaxed,
   (double)gminj / 1000, (double)gmaxj / 1000);
}
}
@@ -396,12 +412,16 @@ void cleanup(void)
test_duration = actual_duration;
 
printf
-   
(---|||||-\n
-RTS|%12.3f|%12.3f|%12.3f|%8ld|
%.2ld:%.2ld:%.2ld/%.2d:%.2d:%.2d\n,
+   
(---|---|---|---||--|-\n
+RTS|%11.3f|%11.3f|%11.3f|%8ld|%6u|
%.2ld:%.2ld:%.2ld/%.2d:%.2d:%.2d\n,
 (double)gminj / 1000, (double)gavgj / 1000, (double)gmaxj / 1000,
-goverrun, actual_duration / 3600, (actual_duration / 60) % 60,
+goverrun, max_relaxed, actual_duration / 3600, (actual_duration / 
60) % 60,
 actual_duration % 60, 

[Xenomai-core] [PATCH 1/3] nucleus: allow xnlock debugging even on UP kernels

2010-01-17 Thread Gilles Chanteperdrix
---
 include/asm-generic/bits/pod.h |2 +-
 include/asm-generic/system.h   |   27 +--
 include/nucleus/queue.h|   16 
 ksrc/nucleus/Kconfig   |   12 
 ksrc/nucleus/intr.c|4 ++--
 ksrc/nucleus/pod.c |   16 
 ksrc/skins/posix/signal.c  |4 +---
 7 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/include/asm-generic/bits/pod.h b/include/asm-generic/bits/pod.h
index 6cf2f6e..bd8db49 100644
--- a/include/asm-generic/bits/pod.h
+++ b/include/asm-generic/bits/pod.h
@@ -278,7 +278,7 @@ unsigned long long xnarch_get_cpu_time(void)
 
 EXPORT_SYMBOL(xnarch_get_cpu_time);
 
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) || XENO_DEBUG(XNLOCK)
 void __xnlock_spin(xnlock_t *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS)
 {
unsigned int spin_limit;
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index e872711..176de1b 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -43,8 +43,8 @@
 /* debug support */
 #include nucleus/assert.h
 
-#ifndef CONFIG_XENO_OPT_DEBUG_NUCLEUS
-#define CONFIG_XENO_OPT_DEBUG_NUCLEUS 0
+#ifndef CONFIG_XENO_OPT_DEBUG_XNLOCK
+#define CONFIG_XENO_OPT_DEBUG_XNLOCK 0
 #endif
 
 #ifdef __cplusplus
@@ -91,7 +91,7 @@ static inline unsigned xnarch_current_cpu(void)
return rthal_processor_id();
 }
 
-#if defined(CONFIG_SMP)  XENO_DEBUG(NUCLEUS)
+#if XENO_DEBUG(XNLOCK)
 
 typedef struct {
 
@@ -148,11 +148,14 @@ xnlock_dbg_spinning(xnlock_t *lock, int cpu, unsigned int 
*spin_limit,
if (--*spin_limit == 0) {
rthal_emergency_console();
printk(KERN_ERR Xenomai: stuck on nucleus lock %p\n
-waiter = %s:%u (%s(), CPU #%d)\n
-owner  = %s:%u (%s(), CPU #%d)\n,
+waiter = %s:%u (%s(), CPU #%d)\n
+owner  = %s:%u (%s(), CPU #%d)\n,
   lock, file, line, function, cpu,
   lock-file, lock-line, lock-function, lock-cpu);
show_stack(NULL, NULL);
+#ifndef CONFIG_SMP
+   BUG();
+#endif
}
 }
 
@@ -198,7 +201,7 @@ static inline int xnlock_dbg_release(xnlock_t *lock)
return 0;
 }
 
-#else /* !(CONFIG_SMP  XENO_DEBUG(NUCLEUS)) */
+#else /* !XENO_DEBUG(XNLOCK) */
 
 typedef struct { atomic_t owner; } xnlock_t;
 
@@ -222,7 +225,7 @@ static inline int xnlock_dbg_release(xnlock_t *lock)
return 0;
 }
 
-#endif /* !(CONFIG_SMP  XENO_DEBUG(NUCLEUS)) */
+#endif /* !XENO_DEBUG(XNLOCK) */
 
 #define XNARCH_NR_CPUS RTHAL_NR_CPUS
 
@@ -319,7 +322,7 @@ static inline int xnarch_root_domain_p(void)
return rthal_current_domain == rthal_root_domain;
 }
 
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) || XENO_DEBUG(XNLOCK)
 
 #define xnlock_get(lock)   __xnlock_get(lock  XNLOCK_DBG_CONTEXT)
 #define xnlock_get_irqsave(lock,x) \
@@ -395,7 +398,11 @@ static inline void xnlock_put_irqrestore(xnlock_t *lock, 
spl_t flags)
 
 static inline int xnarch_send_ipi(xnarch_cpumask_t cpumask)
 {
+#ifdef CONFIG_SMP
return rthal_send_ipi(RTHAL_SERVICE_IPI0, cpumask);
+#else /* !CONFIG_SMP */
+   return 0;
+#endif /* !CONFIG_SMP */
 }
 
 static inline int xnlock_is_owner(xnlock_t *lock)
@@ -403,7 +410,7 @@ static inline int xnlock_is_owner(xnlock_t *lock)
return atomic_read(lock-owner) == xnarch_current_cpu();
 }
 
-#else /* !CONFIG_SMP */
+#else /* !(CONFIG_SMP || XENO_DEBUG(XNLOCK) */
 
 #define xnlock_init(lock)  do { } while(0)
 #define xnlock_get(lock)   do { } while(0)
@@ -424,7 +431,7 @@ static inline int xnarch_send_ipi (xnarch_cpumask_t cpumask)
return 0;
 }
 
-#endif /* !CONFIG_SMP */
+#endif /* !(CONFIG_SMP || XENO_DEBUG(XNLOCK)) */
 
 #define xnlock_sync_irq(lock, x)   \
do {\
diff --git a/include/nucleus/queue.h b/include/nucleus/queue.h
index b84fa3c..13cde9f 100644
--- a/include/nucleus/queue.h
+++ b/include/nucleus/queue.h
@@ -65,17 +65,17 @@ typedef struct xnqueue {
 
xnholder_t head;
int elems;
-#if defined(__KERNEL__)  XENO_DEBUG(QUEUES)  defined(CONFIG_SMP)
-   xnlock_t lock;
-#endif /* __KERNEL__  XENO_DEBUG(QUEUES)  
CONFIG_SMP */
+#if defined(__KERNEL__)  XENO_DEBUG(QUEUES)
+   DECLARE_XNLOCK(lock);
+#endif /* __KERNEL__  XENO_DEBUG(QUEUES) */
 
 } xnqueue_t;
 
-#if XENO_DEBUG(QUEUES)  defined(CONFIG_SMP)
+#if XENO_DEBUG(QUEUES)
 #define XNQUEUE_INITIALIZER(q) { { (q).head, (q).head }, 0, 
XNARCH_LOCK_UNLOCKED }
-#else /* !(XENO_DEBUG(QUEUES)  CONFIG_SMP) */
+#else /* !(XENO_DEBUG(QUEUES) */
 #define XNQUEUE_INITIALIZER(q) { { (q).head, (q).head }, 0 }
-#endif /* XENO_DEBUG(QUEUES)  CONFIG_SMP */
+#endif /* XENO_DEBUG(QUEUES) */
 
 #define DEFINE_XNQUEUE(q) 

Re: [Xenomai-core] [Adeos-main] I-pipe for 2.6.32 PPC

2010-01-17 Thread Wolfgang Denk
Dear Philippe,

in message 1263765606.2428.908.ca...@redshift.xenomai.org you wrote:

 What we may be aiming at, if workable, is something like:
 
 ipipe-*-mainline
 ipipe-*-amcc
 ipipe-*-512x

This sounds fine to me.

I guess we don't even need a 'ipipe-*-amcc' branch - the only things
that should be in our tree but not in mainline are the Synopsis USB
and S-ATA drivers (which are in such a state that they have no chance
of being accepted for mainline), and these additional features are
probably not of relevance for use with Xenomai.

ACK for 'ipipe-*-512x', but this is a work-in-progress tree, with the
clear intention to push this stuff into mainline ASAP.

 Maybe one for the PA6T as well, if we want to keep supporting the old A2
 board rev. I'm unsure right now, since B0 is fine in mainline already.

Are there any significant differences between A2 and Bx as far as
Xenomai in concerned? I mean, would a mainline patch (for Bx) be
missing anything so it doesn't run on A2?

 A mainline pipeline branch for everything that directly works over
 mainline, and platform-specific branches for those that do not. Those
 special branches would then disappear as soon as mainline is fine for
 the platforms they host as well.

I like this approach :-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
We don't care.  We don't have to.  We're the Phone Company.

___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core