From: Philippe Gerum <rpm@xenomai.org>
To: "Ignacio García Pérez" <iggarpe@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] printk
Date: Mon, 14 Nov 2005 12:26:08 +0100 [thread overview]
Message-ID: <43787450.1050701@domain.hid> (raw)
In-Reply-To: <43786C64.1050404@domain.hid>
Ignacio García Pérez wrote:
> Dmitry Adamushko wrote:
>
>
>>xenomai-help-bounces@domain.hid wrote on 11.11.2005 10:30:26:
>>
>>
>>>Hi,
>>>
>>>I'm porting an app from RTAI to Xenomai, and when it came to the
>>>rt_printk function, I had to replace it with plain printk (the
>>>xnarch_log* functions all use printk).
>>>
>>>What I want to know if:
>>>
>>>1- Is totally safe to call the standard kernel printk function from a
>>>real time task?
>>
>>Actually, the adeos/ipipe patches make some changes to the vanilla
>>kernel's printk() mechanism.
>>
>>There are 2 possible modes of printk() being issued from the primary
>>domain.
>>
>>1) asynchronous:
>>
>>all data is written into the protected buffer and the
>>__ipipe_printk_virq virq is risen for the secondary domain. So the
>>data will be printed out when the linux gets control next time.
>>
>>Although, here is, well, a tiny race because of the fact that the virq
>>handler doesn't lock a buffer-related data (like __ipipe_printk_fill)
>>so a loss of data may occur under some circumstances.
>>
Nope. __ipipe_printk_fill and friends are manipulated under hw irq spinlocking
in printk(), and under Linux domain stalling protection in __ipipe_flush_printk
since it's a virq handler, and finally, printk() cannot preempt
__ipipe_flush_printk under normal operation mode (i.e. async mode). AFAICS,
there's no race here.
>>2) synchronous (IPIPE_SPRINTK_FLAG)
>>
>>in this case, a normal linux vprintk() call is issued. Oops, this one,
>>in turn, calls spin_lock_irqsave(&logbuf_lock, flags); in real-time
>>context and that lock may be already held by a preempted non-rt task
>>on the same CPU.
>>
>>Houston? :o)
>>
>
> (2) is unacceptable. Losing some data would be acceptable if it is
> caused by too much printk output, but not because of a race condition.
> This should be fixed. I guess a simple FIFO with proper locking should
> be in place. printk would discard data only if there is no space left.
>
>
>>>2- Even if it's safe, can it affect the performance of a real time task?
>>>(or can it block under *any* conceivable condition?)
>>
>>It gives some overhead since data must be copied to the buffer and at
>>that time the interrupts are off.
>>Blocked? No, if not taking into account a possible "hang up" with the
>>synchronous mode (ok, as always there is still a hope that I can be
>>wrong ):)
>>
>
> If you are right, then it's unacceptable. An RT task would be blocked by
> a non-RT task.
>
Please people, keep things simple and easy: synchronous printk mode is an
_emergency_ configuration which is of no use under normal runtime conditions. It
is only there as a desperate debugging help for Adeos/Xeno core development in
order to force the printk output regardless of the current domain, so it might
work, but it it doesn't and hits any of the obvious races that the asynchronous
mode solves, well, nobody is going to complain because it's just a last resort
bypass in order to get some ultimate traces before the box jumps out of the
window anyway. IOW, if one keeps using the default and normal async printk mode
which prevents domain clashes, everything will be fine.
Regarding the overhead induced by a temporary copy of the printk data, if one
starts having problem with this, then the issue is first caused by spamming the
kernel log with such amount of information. IOW, cure the real bug, not its
consequences.
--
Philippe.
next prev parent reply other threads:[~2005-11-14 11:26 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-10 21:05 [Xenomai-help] Creation of a rt-queue from the user space ROSSIER Daniel
2005-11-11 9:30 ` [Xenomai-help] printk Ignacio García Pérez
2005-11-11 11:07 ` Dmitry Adamushko
2005-11-14 10:52 ` Ignacio García Pérez
2005-11-14 11:26 ` Philippe Gerum [this message]
2005-11-14 12:03 ` Dmitry Adamushko
2005-11-14 13:22 ` Philippe Gerum
2005-11-14 13:47 ` Philippe Gerum
2005-11-14 14:50 ` [Xenomai-core] " Dmitry Adamushko
2005-11-14 15:56 ` [Xenomai-core] rt_pipe_* usage Ignacio García Pérez
2005-11-14 16:15 ` [Xenomai-core] More on rt pipes usage Ignacio García Pérez
2005-11-15 13:24 ` Philippe Gerum
2005-11-15 16:41 ` [Xenomai-help] " Ignacio García Pérez
2005-11-14 16:23 ` [Xenomai-core] rt_pipe_* usage Dmitry Adamushko
2005-11-14 16:36 ` Ignacio García Pérez
2005-11-15 12:41 ` [Xenomai-core] Web site error (API doc search) Ignacio García Pérez
2005-11-15 13:16 ` [Xenomai-core] rt_pipe_* usage Philippe Gerum
2005-11-15 16:22 ` Ignacio García Pérez
2005-11-16 5:38 ` Philippe Gerum
2005-11-15 9:38 ` [Xenomai-core] Re: [Xenomai-help] printk Philippe Gerum
2005-11-15 10:00 ` Dmitry Adamushko
2005-11-16 12:58 ` Philippe Gerum
2005-11-16 14:44 ` Dmitry Adamushko
2005-11-17 9:44 ` [Xenomai-help] Blocking reads from pipes Ignacio García Pérez
2005-11-17 10:21 ` Romain Lenglet
2005-11-17 13:16 ` Ignacio García Pérez
2005-11-17 15:11 ` Dmitry Adamushko
2005-11-17 17:24 ` Gilles Chanteperdrix
2005-11-17 17:55 ` [Xenomai-core] " Dmitry Adamushko
2005-11-17 19:17 ` Gilles Chanteperdrix
2005-11-17 19:45 ` Dmitry Adamushko
2005-11-18 8:57 ` Ignacio García Pérez
2005-11-18 9:10 ` Dmitry Adamushko
2005-11-17 19:40 ` Dmitry Adamushko
2005-11-17 10:46 ` Dmitry Adamushko
2005-11-14 12:15 ` [Xenomai-help] xn_pipe_create [minor] Ignacio García Pérez
2005-11-14 13:53 ` Dmitry Adamushko
2005-11-14 16:28 ` Ignacio García Pérez
2005-11-14 16:29 ` Philippe Gerum
2005-11-14 16:41 ` Ignacio García Pérez
2005-11-14 16:52 ` Dmitry Adamushko
2005-11-14 17:38 ` Philippe Gerum
2005-11-14 18:33 ` Dmitry Adamushko
2005-11-15 8:04 ` Philippe Gerum
2005-11-14 18:03 ` [Xenomai-help] Strange pipe behaviour Ignacio García Pérez
2005-11-16 5:45 ` Philippe Gerum
2005-11-16 7:45 ` Ignacio García Pérez
2005-11-16 11:45 ` Philippe Gerum
2005-11-14 16:40 ` [Xenomai-help] xn_pipe_create [minor] Dmitry Adamushko
2005-11-12 19:45 ` [Xenomai-help] printk Philippe Gerum
2005-11-14 10:47 ` [Xenomai-help] Invalid characters in task's names Ignacio García Pérez
2005-11-14 11:39 ` Philippe Gerum
2005-11-11 14:08 ` [Xenomai-help] Creation of a rt-queue from the user space Jan Kiszka
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=43787450.1050701@domain.hid \
--to=rpm@xenomai.org \
--cc=iggarpe@domain.hid \
--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.