All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Xenomai <xenomai@xenomai.org>
Subject: Re: [Xenomai] Prio ceiling mutex issues
Date: Mon, 9 May 2016 21:30:08 +0200	[thread overview]
Message-ID: <5730E540.4030807@xenomai.org> (raw)
In-Reply-To: <5730DF08.8080309@siemens.com>

On 05/09/2016 09:03 PM, Jan Kiszka wrote:
> Hi Philippe,
> 
> we ran into at least one bug of the current prio ceiling support for
> synch objects: on xnsynch_release, we only reschedule if we woken up a
> new owner. But we also have to reschedule after dropping the ceiling
> prio as some higher prio thread may be waiting.
> 
> For that, I would propose to alter the return type and semantic of
> xnsynch_release from "pointer to new owner" into "bool, true if
> reschedule is needed". It seems, no caller of xnsynch_release makes a
> non-boolean use of the return value anyway. And then we can simply
> return true on "synch->status & XNSYNCH_PP".

I agree, but we need to keep the next owner check in the boolean status. Something like this would do I believe:

diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index 976261d..f84cb6e 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -913,10 +913,10 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch,
  *
  * @coretags{primary-only, might-switch}
  */
-struct xnthread *xnsynch_release(struct xnsynch *synch,
-				 struct xnthread *curr)
+static bool xnsynch_release(struct xnsynch *synch,
+			    struct xnthread *curr)
 {
-	struct xnthread *nextowner = NULL;
+	bool resched = false;
 	xnhandle_t currh, h;
 	atomic_t *lockp;
 	spl_t s;
@@ -946,16 +946,18 @@ struct xnthread *xnsynch_release(struct xnsynch *synch,
 	h = atomic_cmpxchg(lockp, currh, XN_NO_HANDLE);
 	if ((h & ~XNSYNCH_FLCEIL) != currh)
 		/* FLCLAIM set, synch is contended. */
-		nextowner = transfer_ownership(synch, curr);
+		resched = transfer_ownership(synch, curr) != NULL;
 	else if (h != currh)	/* FLCEIL set, FLCLAIM clear. */
 		atomic_set(lockp, XN_NO_HANDLE);
 
-	if (synch->status & XNSYNCH_PP)
+	if (synch->status & XNSYNCH_PP) {
 		clear_pp_boost(synch, curr);
+		resched = true;
+	}
 
 	xnlock_put_irqrestore(&nklock, s);
 
-	return nextowner;
+	return resched;
 }
 EXPORT_SYMBOL_GPL(xnsynch_release);
 

-- 
Philippe.


  parent reply	other threads:[~2016-05-09 19:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-09 19:03 [Xenomai] Prio ceiling mutex issues Jan Kiszka
2016-05-09 19:16 ` Jan Kiszka
2016-05-09 19:22   ` Philippe Gerum
2016-05-09 19:27     ` Jan Kiszka
2016-05-09 19:30 ` Philippe Gerum [this message]
2016-05-09 19:32   ` Jan Kiszka
2016-05-10 13:32     ` Jan Kiszka
2016-05-10 13:57     ` 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=5730E540.4030807@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=jan.kiszka@siemens.com \
    --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.