All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: "Jorge Ramirez Ortiz, HCL Europe" <Jorge.Ramirez-Ortiz@hcl.com>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] BUG: Unhandled exception over domain Xenomai - switching to ROOT
Date: Fri, 13 Jul 2012 11:34:16 +0200	[thread overview]
Message-ID: <4FFFEB98.7060106@xenomai.org> (raw)
In-Reply-To: <4F534D1A615F544D95E57BFD8460658301CBE3C2@GEO-HCLT-UKEVS1.GEO.CORP.HCL.IN>

On 07/12/2012 11:29 PM, Jorge Ramirez Ortiz, HCL Europe wrote:
> Hi Gilles
>
> Information and context below.
>
> kernel: 2.6.35.9
> xenomai:2.6.0
> ipipe:2.8-04
> cpu atom z530 1.6HH
>
> Error
>>>> [  242.962195] BUG: Unhandled exception over domain Xenomai at 0x892160 - switching to ROOT
>>>> [  242.990052] Pid: 972, comm: InterruptTest Not tainted 2.6.35.9-prot-xeno-atom #4
>>>> [  243.015979] Call Trace:
>>>> [  243.025121]  [<c041b0b3>] __ipipe_handle_exception+0x203/0x210
>>>> [  243.048691]  [<c07ef4fb>] error_code+0x63/0x70
>
> System:
> 1. Xenomai thread calling ~9000 PCI writes in a loop. Each of these 9000 IOCTLs is processed in the realtime path of the RTDM driver.
> 2. A library has an interrupt notifier on the same RTDM device.
>     The interrupt notifier is a wait queue in the non-realtime path of the RTDM driver. Events are raised from the RTDM interrupt handler to notify the sleeping threads.
>     The interrupt notifier is a timed wait every 100ms. When it times out, the linux application reads (msgrcv) from a queue in a shared memory segment (shmget created).
>
> The problem with the design is obvious and the issue above solved by modifying the library.
> The interrupt notifier should be sleeping in an rtdm_event_t in the realtime path of the device instead of a linux wait queue.
>
> However, the other design, even if wrong, shouldnt have caused exceptions.

Your assumption is wrong: you cannot parry a real-time context 
reentering the regular linux kernel from an unsafe place through a plain 
function call, absolutely none. We can only detect this situation after 
the facts to give some debug hints, hopefully before the complete crash, 
by instrumenting code paths which may be spuriously called that way, e.g:

diff --git a/kernel/sched.c b/kernel/sched.c
index 2d1e23a..2e0ba74 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3819,6 +3819,8 @@ static void __wake_up_common(wait_queue_head_t *q, 
unsigned int mode,
  {
  	wait_queue_t *curr, *next;

+	ipipe_check_context(ipipe_root_domain);
+
  	list_for_each_entry_safe(curr, next, &q->task_list, task_list) {
  		unsigned flags = curr->flags;

At any rate, you should not expect the system to help you getting away 
with violations of basic dual kernel programming rules from kernel 
space, this won't happen.

>
> Anyhow, I am as impressed as always with this piece of software. This is the toolkit that any embedded developer needs. And RTDM has been a great addition.
>
> thanks
> Jorge
>
> ________________________________________
> From: Gilles Chanteperdrix [gilles.chanteperdrix@xenomai.org]
> Sent: 12 July 2012 09:31
> To: Jorge Ramirez Ortiz,  HCL Europe
> Cc: xenomai@xenomai.org
> Subject: Re: [Xenomai] BUG: Unhandled exception over domain Xenomai - switching to ROOT
>
> On 07/12/2012 10:16 AM, Jorge Ramirez Ortiz, HCL Europe wrote:
>> Thanks Gilles. Yes unfortunately I cant recompile this kernel so I
>> was wondering about the system context of this fault within Xenomai.
>> BTW how come the stack frame is not printed by default.
>
> Because it may not be safe to use show_stack() from RT context (for
> instance, the print_symbol function to print symbol names need to take a
> spinlock when a symbol is defined by a kernel module, and this spinlock
> is not rt-safe). Anyway, the error message normally prints the PC of the
> error.
>
> Could you give us the exact error messsage? The version of Xenomai, the
> Linux kernel, the version of the I-pipe patch you use?
>
> --
>                                              Gilles.
>
>
> ::DISCLAIMER::
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
> The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
> E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
> lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
> (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
> Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
> views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
> distribution and / or publication of this message without the prior written consent of authorized representative of
> HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
> Before opening any email and/or attachments, please check them for viruses and other defects.
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> _______________________________________________
> Xenomai mailing list
> Xenomai@xenomai.org
> http://www.xenomai.org/mailman/listinfo/xenomai
>


-- 
Philippe.




  parent reply	other threads:[~2012-07-13  9:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 18:10 [Xenomai] BUG: Unhandled exception over domain Xenomai - switching to ROOT Jorge Ramirez Ortiz,  HCL Europe
2012-07-12  0:21 ` Gilles Chanteperdrix
2012-07-12  8:16   ` Jorge Ramirez Ortiz,  HCL Europe
2012-07-12  8:31     ` Gilles Chanteperdrix
2012-07-12 21:29       ` Jorge Ramirez Ortiz,  HCL Europe
2012-07-13  7:27         ` Gilles Chanteperdrix
2012-07-13  9:34         ` Philippe Gerum [this message]
2012-07-13 10:41           ` Jorge Ramirez Ortiz,  HCL Europe
2012-07-13 11:08             ` Philippe Gerum
2012-07-13 11:24               ` Jorge Ramirez Ortiz,  HCL Europe
2012-07-13 11:58                 ` Jan Kiszka
2012-07-13 16:27                   ` Jorge Ramirez Ortiz,  HCL Europe
2012-07-13 17:47                     ` Gilles Chanteperdrix
2012-07-16  9:10                       ` Jorge Ramirez Ortiz,  HCL Europe
2012-07-13 12:31                 ` Gilles Chanteperdrix
2012-07-13 16:39                   ` Jorge Ramirez Ortiz,  HCL Europe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FFFEB98.7060106@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=Jorge.Ramirez-Ortiz@hcl.com \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.