All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Fast mutexes vs. automatic mode switch
Date: Mon, 13 Oct 2008 13:59:07 +0200	[thread overview]
Message-ID: <48F3380B.6040503@domain.hid> (raw)
In-Reply-To: <48F33543.6070303@domain.hid>

Jan Kiszka wrote:
> Hi,
> 
> while preparing my reworked fast mutex patches for submission, reviewing
> them once again, I realized a conception problem that the fast path can
> introduce: So far every pthread_mutex_lock or rt_mutex_acquire forced
> the caller into primary mode in case it was in secondary before. Now
> this will only happen if the mutex is contended!

Yes, I had already thought about that, and even mentioned it on the
mailing list I believe.

> 
> Let's consider the fairly typical use case of a two threads
> synchronizing a critical section with the help of a mutex. One thread is
> high-prio, always in primary mode, the other is low-prio, constantly
> transiting between primary (while holding the lock) and secondary (while
> interacting with Linux). If the low-prio acquires the uncontended lock,
> it will now remain in secondary mode thanks to the new mutex fast path.
> That means if the high-prio requests the lock as well, prio-inheritance
> will no longer work as the owner is not in the right mode!
> 
> I guess what we need is mode detection for the caller in the mutex fast
> path. If the possible new owner is in secondary mode, the syscall path
> needs to be taken to trigger a migration reliably. That in turn means we
> need a syscall-less detection of the current execution mode. Any
> spontaneous ideas on this?

Is not it even simpler for the oscillating thread to switch to primary
mode when it accesses such a mutex? Otherwise we have kernel/user shared
 maps, so allocating a few bytes there should be enough.

-- 
                                                 Gilles.


  reply	other threads:[~2008-10-13 11:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-13 11:47 [Xenomai-core] Fast mutexes vs. automatic mode switch Jan Kiszka
2008-10-13 11:59 ` Gilles Chanteperdrix [this message]
2008-10-13 12:11   ` Jan Kiszka
2008-10-13 12:17     ` Gilles Chanteperdrix
2008-10-13 14:25       ` Jan Kiszka
2008-10-13 18:08         ` Gilles Chanteperdrix

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=48F3380B.6040503@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.