All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] [PATCH 1/6] Remove / shorten critical sections in registry code
Date: Tue, 26 Aug 2008 13:49:30 +0200	[thread overview]
Message-ID: <48B3EDCA.9000804@domain.hid> (raw)
In-Reply-To: <48B3ED52.7080101@domain.hid>

See Changelog.

---
 ChangeLog               |    6 ++++++
 ksrc/nucleus/registry.c |   44 +++++++++++++-------------------------------
 2 files changed, 19 insertions(+), 31 deletions(-)

Index: b/ChangeLog
===================================================================
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-26  Jan Kiszka  <jan.kiszka@domain.hid>
+
+	* ksrc/nucleus/registry.c (xnregistry_fetch/get/put): Remove
+	pointless locking, move XNOBJECT_SELF lookups out of critical
+	sections.
+
 2008-08-25  Jan Kiszka  <jan.kiszka@domain.hid>
 
 	* include/asm-generic/wrappers.h: Provide atomic_long wrappings.
Index: b/ksrc/nucleus/registry.c
===================================================================
--- a/ksrc/nucleus/registry.c
+++ b/ksrc/nucleus/registry.c
@@ -1024,16 +1024,14 @@ void *xnregistry_get(xnhandle_t handle)
 	void *objaddr;
 	spl_t s;
 
-	xnlock_get_irqsave(&nklock, s);
-
 	if (handle == XNOBJECT_SELF) {
-		if (!xnpod_primary_p()) {
-			objaddr = NULL;
-			goto unlock_and_exit;
-		}
+		if (!xnpod_primary_p())
+			return NULL;
 		handle = xnpod_current_thread()->registry.handle;
 	}
 
+	xnlock_get_irqsave(&nklock, s);
+
 	object = registry_validate(handle);
 
 	if (object) {
@@ -1042,8 +1040,6 @@ void *xnregistry_get(xnhandle_t handle)
 	} else
 		objaddr = NULL;
 
-      unlock_and_exit:
-
 	xnlock_put_irqrestore(&nklock, s);
 
 	return objaddr;
@@ -1087,17 +1083,14 @@ u_long xnregistry_put(xnhandle_t handle)
 	u_long newlock;
 	spl_t s;
 
-	xnlock_get_irqsave(&nklock, s);
-
 	if (handle == XNOBJECT_SELF) {
-		if (!xnpod_primary_p()) {
-			newlock = 0;
-			goto unlock_and_exit;
-		}
-
+		if (!xnpod_primary_p())
+			return 0;
 		handle = xnpod_current_thread()->registry.handle;
 	}
 
+	xnlock_get_irqsave(&nklock, s);
+
 	object = registry_validate(handle);
 
 	if (!object) {
@@ -1150,28 +1143,17 @@ u_long xnregistry_put(xnhandle_t handle)
 void *xnregistry_fetch(xnhandle_t handle)
 {
 	xnobject_t *object;
-	void *objaddr;
-	spl_t s;
-
-	xnlock_get_irqsave(&nklock, s);
 
-	if (handle == XNOBJECT_SELF) {
-		objaddr = xnpod_primary_p()? xnpod_current_thread() : NULL;
-		goto unlock_and_exit;
-	}
+	if (handle == XNOBJECT_SELF)
+		return xnpod_primary_p()? xnpod_current_thread() : NULL;
 
 	object = registry_validate(handle);
 
-	if (object)
-		objaddr = object->objaddr;
-	else
-		objaddr = NULL;
-
-      unlock_and_exit:
+	if (!object)
+		return NULL;
 
-	xnlock_put_irqrestore(&nklock, s);
+	return object->objaddr;
 
-	return objaddr;
 }
 
 /*@}*/



  reply	other threads:[~2008-08-26 11:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26 12:08 [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Jan Kiszka
2008-08-26 11:49 ` Jan Kiszka [this message]
2008-08-26 11:51 ` [Xenomai-core] [PATCH 2/6] Allow key-less registry entries Jan Kiszka
2008-08-26 11:53 ` [Xenomai-core] [PATCH 3/6] Native skin: Use " Jan Kiszka
2008-08-26 11:55 ` [Xenomai-core] [PATCH 4/6] Eliminate xnobjhash Jan Kiszka
2008-08-26 11:56 ` [Xenomai-core] [RESEND][PATCH 5/6] Avoid add_proc_leaf duplicates Jan Kiszka
2008-08-26 11:58 ` [Xenomai-core] [RESEND][PATCH 6/6] Report registry slot usage via /proc Jan Kiszka
2008-08-26 16:08   ` Philippe Gerum
2008-08-26 16:19     ` Jan Kiszka
2008-08-26 16:22       ` Philippe Gerum
2008-08-26 17:08         ` Jan Kiszka
2008-08-26 13:40 ` [Xenomai-core] [PATCH 0/6] Registry-related cleanups and improvements Gilles Chanteperdrix
2008-08-26 16:03   ` Philippe Gerum
2008-08-27  9:35 ` 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=48B3EDCA.9000804@domain.hid \
    --to=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.