Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: laijs@cn.fujitsu.com (Lai Jiangshan)
Subject: [ltt-dev] [PATCH 4/7] urcu, defer_rcu: Simplify defer_rcu() encoding
Date: Wed, 28 Sep 2011 16:34:30 +0800	[thread overview]
Message-ID: <6a03f0ddce7d9e4270c8573b0ae7b94ca723a406.1317198301.git.laijs@cn.fujitsu.com> (raw)
In-Reply-To: <cover.1317198301.git.laijs@cn.fujitsu.com>

use the same code as function changed even only
just the data is not aligned.

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
 urcu-defer-impl.h |   38 ++++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/urcu-defer-impl.h b/urcu-defer-impl.h
index 49570ff..b1478ab 100644
--- a/urcu-defer-impl.h
+++ b/urcu-defer-impl.h
@@ -61,7 +61,7 @@
  * Assumes that (void *)-2L is not used often. Used to encode non-aligned
  * functions and non-aligned data using extra space.
  * We encode the (void *)-2L fct as: -2L, fct, data.
- * We encode the (void *)-2L data as: -2L, fct, data.
+ * We encode the (void *)-2L data as: fct | DQ_FCT_BIT, data or -2L, fct, data.
  * Here, DQ_FCT_MARK == ~DQ_FCT_BIT. Required for the test order.
  */
 #define DQ_FCT_BIT		(1 << 0)
@@ -318,14 +318,27 @@ void _defer_rcu(void (*fct)(void *p), void *p)
 		assert(head - CMM_LOAD_SHARED(defer_queue.tail) == 0);
 	}
 
-	if (unlikely(defer_queue.last_fct_in != fct)) {
+	/*
+	 * Encode:
+	 * if the function is not changed and the data is aligned and it is
+	 * not the marker:
+	 *	store the data
+	 * otherwise if the function is aligned and its not the marker:
+	 *	store the funciotn with DQ_FCT_BIT
+	 *	store the data
+	 * otherwise:
+	 *	store the marker (DQ_FCT_MARK)
+	 *	store the funciotn
+	 *	store the data
+	 *
+	 * Decode: see the comments before 'struct defer_queue'
+	 *         or the code in rcu_defer_barrier_queue().
+	 */
+	if (unlikely(defer_queue.last_fct_in != fct
+			|| DQ_IS_FCT_BIT(p)
+			|| p == DQ_FCT_MARK)) {
 		defer_queue.last_fct_in = fct;
 		if (unlikely(DQ_IS_FCT_BIT(fct) || fct == DQ_FCT_MARK)) {
-			/*
-			 * If the function to encode is not aligned or the
-			 * marker, write DQ_FCT_MARK followed by the function
-			 * pointer.
-			 */
 			_CMM_STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
 				      DQ_FCT_MARK);
 			_CMM_STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
@@ -335,17 +348,6 @@ void _defer_rcu(void (*fct)(void *p), void *p)
 			_CMM_STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
 				      fct);
 		}
-	} else {
-		if (unlikely(DQ_IS_FCT_BIT(p) || p == DQ_FCT_MARK)) {
-			/*
-			 * If the data to encode is not aligned or the marker,
-			 * write DQ_FCT_MARK followed by the function pointer.
-			 */
-			_CMM_STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
-				      DQ_FCT_MARK);
-			_CMM_STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
-				      fct);
-		}
 	}
 	_CMM_STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK], p);
 	cmm_smp_wmb();	/* Publish new pointer before head */
-- 
1.7.4.4





  parent reply	other threads:[~2011-09-28  8:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-28  8:34 [ltt-dev] [PATCH 0/7] urcu,call_rcu: minior fixes, round2 Lai Jiangshan
2011-09-28  8:34 ` [ltt-dev] [PATCH 1/7] urcu, call_rcu: protects call_rcu_data_list when remove node Lai Jiangshan
2011-09-29 17:00   ` Mathieu Desnoyers
2011-09-28  8:34 ` [ltt-dev] [PATCH 2/7] urcu, defer_rcu: fix missing respond to a cancellation request Lai Jiangshan
2011-09-29 17:13   ` Mathieu Desnoyers
2011-09-28  8:34 ` [ltt-dev] [PATCH 3/7] urcu, defer_rcu: Avoid thread exit unexpected Lai Jiangshan
2011-09-29 17:27   ` Mathieu Desnoyers
2011-09-28  8:34 ` Lai Jiangshan [this message]
2011-09-29 17:49   ` [ltt-dev] [PATCH 4/7] urcu, defer_rcu: Simplify defer_rcu() encoding Mathieu Desnoyers
2011-09-28  8:34 ` [ltt-dev] [PATCH 5/7] urcu, call_rcu: avoid create call_rcu_data for child when unneed Lai Jiangshan
2011-09-29 17:27   ` Paul E. McKenney
2011-09-29 17:52     ` Mathieu Desnoyers
2011-09-28  8:34 ` [ltt-dev] [PATCH 6/7] urcu, call_rcu: Cleanup call_rcu_data pointers before used in child Lai Jiangshan
2011-09-29 17:37   ` Paul E. McKenney
2011-09-29 17:59     ` Mathieu Desnoyers
2011-09-29 18:08       ` Paul E. McKenney
2011-09-29 18:19         ` Mathieu Desnoyers
2011-09-29 18:29           ` Paul E. McKenney
2011-09-29 18:28   ` Mathieu Desnoyers
2011-09-29 19:43     ` Mathieu Desnoyers
2011-09-29 19:53   ` Mathieu Desnoyers
2011-09-28  8:34 ` [ltt-dev] [PATCH 7/7] urcu, call_rcu: Array initialized before pointer is planted Lai Jiangshan
2011-09-29 17:33   ` Paul E. McKenney
2011-09-29 20:07     ` Mathieu Desnoyers
2011-09-29 21:13       ` Mathieu Desnoyers

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=6a03f0ddce7d9e4270c8573b0ae7b94ca723a406.1317198301.git.laijs@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox