All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Henri Roosen <henriroosen@domain.hid>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>,
	Jan Kiszka <jan.kiszka@domain.hid>
Subject: Re: [Xenomai-help] New scheduler class
Date: Mon, 04 Oct 2010 13:02:55 +0200	[thread overview]
Message-ID: <1286190175.1702.101.camel@domain.hid> (raw)
In-Reply-To: <AANLkTi=0WtJnPrX1GX-Hd+erzABbNPVP=o5zr4-4=p5Q@mail.gmail.com>

On Thu, 2010-09-30 at 14:52 +0200, Henri Roosen wrote:
> On Fri, Apr 23, 2010 at 12:54 PM, Philippe Gerum <rpm@xenomai.org> wrote:
> > On Tue, 2010-04-20 at 10:12 -0400, Andreas Glatz wrote:
> >> > > > >> For the time being, you can work around this by issuing a Linux syscall
> >> > > > >> before entering long processing loops - unless your task doesn't do this
> >> > > > >> anyway, e.g. to perform some Linux I/O.
> >> > > > >>
> >> > > > >
> >> > > > > I think that's need. Currently the statistics task takes a mutex and waits on a message queue for messages. That's the only time it should potentially run in primary mode. After it returns the Mutex it should continue running with a policy similar to SCHED_IDLE to give other tasks a chance to run. I see how switching back to secondary mode could be achieved by issuing a Linux syscall. Is there another way which doesn't involve changing the source code of our application? (The proper way?)
> >> > > >
> >> > > > The proper way would be to not having to change the application code.
> >> > > > But this workaround (Linux syscall or *_set_mode()) is required until we
> >> > > > improve the nucleus.
> >> > >
> >> > > I generated a patch against 2.4.10.1 to get this behaviour (see further down). Instead of having
> >> > > to review and insert a Linux syscall or *_set_mode() in the application code I just call
> >> > > rt_task_set_mode(0, T_IDLE, NULL) at the beginning of the task body of the task which
> >> > > should mostly run in secondary mode under SCHED_IDLE (see example further down). The task
> >> > > marked with T_IDLE will switch to primary mode at every Xenomai skincall and immediately
> >> > > switch back to secondary mode once the Xenomai skincall is done.
> >> > >
> >> > > We identified just one case where this task has to stay in primary mode. This is between
> >> > > rt_mutex_aquire() and rt_mutex_release() since it may undergo a priority inversion boost.
> >> > > If the task stayed in secondary mode during that time it either would potentally delay the
> >> > > execution of a high priority task or would kill the system.
> >> > >
> >> > > The patch seems to work for us. Our statistics task which blocked the system for a long
> >> > > time (and made the UI running under Linux unresponsive) is running with T_IDLE. If Linux is
> >> > > heavily loaded now the statistics will get out of sync but the UI will still be responsive.
> >> > >
> >> >
> >> > The logic of this patch looks ok for the native skin, given that 2.4.x
> >> > does not provide a centralized implementation for dealing with exclusive
> >> > resources, like 2.5.x with xnsynch_acquire/release, and always emits a
> >> > syscall to manage those resources.
> >> >
> >> > This said, you could spare the T_IDLE tag by assuming that any non-RT
> >> > shadow thread has to switch back to secondary mode after a syscall,
> >> > unless the owned resource count is non-zero. This is where we are
> >> > heading to in 2.5.x, since the preferred mode of operation for such
> >> > thread has to be fundamentally "relaxed" (otherwise, one would have
> >> > created a RT thread, right).
> >> >
> >> > I'm also unsure you should force SCHED_IDLE, instead of picking
> >> > SCHED_OTHER for a more general approach to this issue. You can't assume
> >> > that userland does want to be reniced that way, at least not from the
> >> > nucleus. But I guess this fits your problem though.
> >> >
> >> > To sum up, since we can't really provide a true SCHED_IDLE policy on
> >> > linux (i.e. not a nice-level hack), and implementing a sched class in
> >> > Xenomai having a lower priority than the existing xnsched_class_idle (in
> >> > 2.5.x) is not feasible (we could not run any userland task in it
> >> > anyway), we'd better stick with SCHED_OTHER.
> >> >
> >>
> >> Thanks a lot for the feedback. Your suggestions simplified the patch. I
> >> also changed SCHED_IDLE to SCHED_OTHER since it might be more beneficial
> >> for the broader audience. Any other suggestions?
> >
> > For an even broader audience, the POSIX skin mutexes should be tracked
> > as well.
> >
> >>
> >> After applying this patch, a thread with priority 0 will automatically
> >> switch back to secondary mode after every (native) skincall unless the
> >> task holds a mutex (simple and nested).
> >>
> >> The benefit is, that the task with priority 0 (which I called a linux
> >> domain rt thread)
> >
> > Actually, no. This is not a rt thread at all, in the sense that you have
> > zero guarantee wrt latency in that case. Such a thread is actually a non
> > real-time Xenomai shadow thread, meaning that it may invoke Xenomai
> > services that require the caller to be a Xenomai thread, without
> > real-time support though.
> >
> >>  can issue (native) skincalls and share resources with
> >> high prioritiy task. But it doesn't hold up Linux tasks unless it holds
> >> a mutex since it mostly runs in secondary mode and just switches to
> >> primary mode when needed.
> >>
> >> Just one more questions: Philippe said that you have something similar in
> >> 2.5. How do you enable it there? By setting the correct sheduling policy?
> >>
> >
> > There are plans to have it. That behavior would be enabled whenever the
> > linux policy is SCHED_OTHER, and the base priority is 0 Xenomai-wise.
> > The latter would be enough for now, but it seems more future-proof not
> > to assume that only SCHED_OTHER tasks could be assigned Xenomai priority
> > 0.
> >
> 
> Is there any update on the plans to have Xenomai base priority 0
> threads to be operating by default in relaxed mode? We are using 2.5.4
> and currently apply the patch below as a workaround. The patch is
> similar to the 2.4 patch of Andreas in that it actively switches back
> base prio 0 shadowed threads into relaxed mode, but doesn't take any
> held locks into account.
> 
> Please comment on this patch. If there is any preliminary code for
> 2.5.x available regarding this functionality I'll be happy to test it
> ;-)
> 

I have blackfin festivity to handle right now, but next in queue is this
issue.

-- 
Philippe.




  parent reply	other threads:[~2010-10-04 11:02 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01 23:08 [Xenomai-help] New scheduler class Andreas Glatz
2010-04-02  0:08 ` Jan Kiszka
2010-04-02  0:11   ` Gilles Chanteperdrix
2010-04-02  7:58     ` Henri Roosen
2010-04-02  8:06       ` Gilles Chanteperdrix
2010-04-02  8:27         ` Gilles Chanteperdrix
2010-04-02  9:18       ` Jan Kiszka
2010-04-02  9:24         ` Jan Kiszka
2010-04-02  9:27           ` Gilles Chanteperdrix
2010-04-02  9:32             ` Henri Roosen
2010-04-02  9:34               ` Gilles Chanteperdrix
2010-04-02  9:43                 ` Henri Roosen
2010-04-02 10:07                   ` Jan Kiszka
2010-04-04 23:04                     ` Andreas Glatz
2010-04-06  6:45                       ` Jan Kiszka
2010-04-15  0:19                         ` Andreas Glatz
2010-04-15  9:02                           ` Philippe Gerum
2010-04-20 14:12                             ` Andreas Glatz
2010-04-23 10:54                               ` Philippe Gerum
2010-09-30 12:52                                 ` Henri Roosen
2010-09-30 13:29                                   ` Gilles Chanteperdrix
2010-10-04 11:02                                   ` Philippe Gerum [this message]
2010-10-04 13:14                                     ` Henri Roosen
2010-10-10 21:17                                   ` Philippe Gerum
2010-04-15 10:46                           ` Philippe Gerum
2010-04-15 12:36                             ` Andreas Glatz
2010-04-15 12:40                               ` Gilles Chanteperdrix
2010-04-15 12:59                                 ` Andreas Glatz
2010-04-15 13:15                                   ` Gilles Chanteperdrix
2010-04-16 15:29                                     ` Andreas Glatz
2010-04-16 15:57                                       ` Gilles Chanteperdrix
2010-04-02 10:00                 ` Jan Kiszka
2010-04-02 10:02                   ` Gilles Chanteperdrix
2010-04-02  8:26     ` Jan Kiszka
2010-04-02  8:29       ` Gilles Chanteperdrix
2010-04-02  8:58         ` Jan Kiszka
2010-04-02  9:03           ` Jan Kiszka
2010-04-02  9:24             ` Gilles Chanteperdrix
2010-04-02 10:02               ` Jan Kiszka
2010-04-02 10:05                 ` Gilles Chanteperdrix
2010-04-02 10:12                   ` Jan Kiszka
     [not found] <mailman.6356.1286778008.12503.xenomai@xenomai.org>
2010-10-11  9:31 ` Andreas Glatz
2010-10-11 15:35   ` Henri Roosen
2010-10-12  7:16     ` Henri Roosen
2011-03-28 10:56       ` Henri Roosen
2011-03-28 11:44         ` Philippe Gerum
2011-05-01 15:01         ` Philippe Gerum
2011-05-02  8:58           ` Henri Roosen
2011-05-05 13:55             ` Philippe Gerum
2011-05-05 14:40               ` Henri Roosen
2011-06-28  9:26                 ` Henri Roosen
2011-06-28  9:33                   ` 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=1286190175.1702.101.camel@domain.hid \
    --to=rpm@xenomai.org \
    --cc=henriroosen@domain.hid \
    --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.