From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] Spinlock question.
Date: Mon, 26 Mar 2007 17:59:46 +0200 [thread overview]
Message-ID: <4607EDF2.2020600@domain.hid> (raw)
In-Reply-To: <4607EA58.1070004@domain.hid>
Jan Kiszka wrote:
> Gilles Chanteperdrix wrote:
>
>>Hi,
>>
>>I am porting a network driver from Linux to RTnet, and I have a sudden
>>doubt about what I am doing: is it safe to call a function like
>>wake_up_interruptible, from a non real-time context, with CONFIG_PREEMPT
>>enabled, while holding an rthal spinlock ? Do not I risk a rescheduling
>>with the spinlock locked ?
>
>
> Mmh, doesn't stalling the primary domain (what rthal_spin_lock_irqsave
> surely does) also make the root domain think it is running in interrupt
> context, thus will prevent any Linux reschedule?
Is not it sufficient to add a call to preempt_disable/preempt_enable
around the spinlock functions ?
> However, there is one big fat issue with this approach:
> wake_up_interruptible takes some Linux spin lock. So you must never call
> it from primary context on UP to avoid corruption. And an SMP, you
> create a nice source for priority inversion: CPU2 holds wait_queue lock,
> gets preempted by Xenomai and runs some longer low-prio RT job.
> Meanwhile CPU1 tries to acquire wait_queue as well with IRQs disabled,
> blocking any RT task on that CPU.
>
> Better defer the Linux wake-up via a rtdm_nrtsig. Alternatively, make
> the Linux waiter also a Xenomai task and use a rtdm_event e.g. (mmh,
> maybe we should discuss the auto-shadow-any-Linux-task-on-demand feature
> for Xenomai once again...).
I have other cases where the function that does the wakeup do it from
real-time context, so I will probably have to use the nrtsig approach
anyway, thanks.
--
Gilles Chanteperdrix
next prev parent reply other threads:[~2007-03-26 15:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-26 15:01 [Xenomai-core] Spinlock question Gilles Chanteperdrix
2007-03-26 15:44 ` Jan Kiszka
2007-03-26 15:53 ` Dmitry Adamushko
2007-03-26 15:59 ` Gilles Chanteperdrix [this message]
2007-03-26 16:34 ` Philippe Gerum
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=4607EDF2.2020600@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=jan.kiszka@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.