All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] Spinlock question.
Date: Mon, 26 Mar 2007 17:44:24 +0200	[thread overview]
Message-ID: <4607EA58.1070004@domain.hid> (raw)
In-Reply-To: <4607E038.8070505@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

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?

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...).

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

  reply	other threads:[~2007-03-26 15:44 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 [this message]
2007-03-26 15:53   ` Dmitry Adamushko
2007-03-26 15:59   ` Gilles Chanteperdrix
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=4607EA58.1070004@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --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.