Skip to contentSkip to conversation

Kernel oops when reading /proc/xenomai/stats

Xenomai-help New Andreas Glatz 1 participant 4 messages Feb 12, 2010

lore
Share & tools
lore
#0 lore raw
Quoted 13 lines
Quoted 3 lines

Hi,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

That's the kernel oops with additional debugging info (starts with 'HUHU' - see code below

+the oops):

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

HUHU count=1 xnintr_count=-12

That's not good. What is your Xenomai version?

Hardware=MPC8360, Linux=2.6.32, Xenomai=2.4.10, ipipe=2.8-00

Quoted 2 lines

Does everything work fine if you application terminates normally and deletes the rt_intr objects explicitly?

Checking...

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

And then you may want to track this down at the site that decrements xnintr_count, ie. rt_intr_delete -> xnintr_detach.

This Email contains three patches.

Good catches! But please post them as separated patches following the well-know standards (proper subject, a short description, signed-off, inlined patch against xenomai.git).

Hope the format is ok now.

Andreas

#1 lore raw

PATCH 1/3 native: Corrected spelling mistake in macro __xeno_flush_rq()

This spelling mistake causes the preprocessor not to substitute a macro argument as it was originally intended by the author.

---
 include/native/ppd.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/native/ppd.h +1 -1
index 3dbda6a..a02cc06 100644
@@ -105,7 +105,7 @@ static inline xeno_rholder_t *xeno_get_rholder(void)
 			if (unlikely(err)) {				\
 				if ((__rq) != &__native_global_rholder.__name##q) { \
 					xnlock_get_irqsave(&nklock, s);	\
-					nholder = popq((rq), holder);	\
+					nholder = popq((__rq), holder);	\
 					appendq(&__native_global_rholder.__name##q, holder); \
 					obj->rqueue = &__native_global_rholder.__name##q; \
 				}					\
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/3 nucleus: Introduced checking of an interrupt object before attaching or detaching it.

Added code to check if an interrupt object is attached/detached right after calling xnintr_irq_attach()/xnintr_irq_detach() to avoid re-attaching/detaching and interrupt object.

Now xnintr_destroy() returns the return value of xnintr_detach() as described in the comment.

---
 ksrc/nucleus/intr.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
ksrc/nucleus/intr.c +18 -4
index 50f7945..ace75d5 100644
@@ -426,14 +426,29 @@ static inline xnintr_t *xnintr_shirq_next(xnintr_t *prev)
 
 static inline int xnintr_irq_attach(xnintr_t *intr)
 {
-	return xnarch_hook_irq(intr->irq, &xnintr_irq_handler,
+	int err;
+
+	if (__testbits(intr->flags, XN_ISR_ATTACHED))
+		return -EPERM;
+
+	err = xnarch_hook_irq(intr->irq, &xnintr_irq_handler,
 			       (rthal_irq_ackfn_t)intr->iack, intr);
+
+	if (!err)
+		__setbits(intr->flags, XN_ISR_ATTACHED);
+
+	return err;
 }
 
 static inline int xnintr_irq_detach(xnintr_t *intr)
 {
 	int irq = intr->irq, err;
 
+	if (!__testbits(intr->flags, XN_ISR_ATTACHED))
+		return -EPERM;
+
+	__clrbits(intr->flags, XN_ISR_ATTACHED);
+
 	xnlock_get(&xnirqs[irq].lock);
 	err = xnarch_release_irq(irq);
 	xnlock_put(&xnirqs[irq].lock);
@@ -659,7 +674,7 @@ EXPORT_SYMBOL_GPL(xnintr_init);
  * @param intr The descriptor address of the interrupt object to
  * destroy.
  *
- * @return 0 is returned on success. Otherwise, -EBUSY is returned if
+ * @return 0 is returned on success. Otherwise, -EINVAL is returned if
  * an error occurred while detaching the interrupt (see
  * xnintr_detach()).
  *
@@ -675,8 +690,7 @@ EXPORT_SYMBOL_GPL(xnintr_init);
 
 int xnintr_destroy(xnintr_t *intr)
 {
-	xnintr_detach(intr);
-	return 0;
+	return xnintr_detach(intr);
 }
 EXPORT_SYMBOL_GPL(xnintr_destroy);
 
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 3/3 native: Removed redundant code in rt_intr_delete() which caused xnintr_detach() to be called twice on an interrupt object.

---
 ksrc/skins/native/intr.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
ksrc/skins/native/intr.c +1 -2
index f52daff..8abcd27 100644
@@ -362,8 +362,7 @@ int rt_intr_delete(RT_INTR *intr)
 
 	xnlock_put_irqrestore(&nklock, s);
 
-	err = xnintr_detach(&intr->intr_base);
-	xnintr_destroy(&intr->intr_base);
+	err = xnintr_destroy(&intr->intr_base);
 
 	if (rc == XNSYNCH_RESCHED)
 		/* Some task has been woken up as a result of the deletion:
Signature · 1 line
1.5.6.5