rcuja: Increase granularity
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Mar 2012 03:23:33 +0000 (22:23 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 14 May 2013 14:19:11 +0000 (16:19 +0200)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rcuja/design.txt
rcuja/rcuja.c

index 775ec970827e5d138f8a3010b3b11b3d7b33ac27..947f61abc383da89abbd9cb2c4bb7a75bcc8d7eb 100644 (file)
@@ -223,16 +223,16 @@ least-significant bits.
 Types of children:
 
 enum child_type {
-       LINEAR = 0,     /* Type A */
-                       /* 32-bit: 1 to 12 children, 32 to 64 bytes */
-                       /* 64-bit: 1 to 14 children, 32 to 128 bytes */
-       BITMAP = 1,     /* Type B */
+       RCU_JA_LINEAR = 0,      /* Type A */
+                       /* 32-bit: 1 to 12 children, 8 to 64 bytes */
+                       /* 64-bit: 1 to 14 children, 16 to 128 bytes */
+       RCU_JA_BITMAP = 1,      /* Type B */
                        /* 32-bit: 13 to 120 children, 128 to 512 bytes */
                        /* 64-bit: 15 to 124 children, 256 to 1024 bytes */
-       PIGEON = 2,     /* Type C */
+       RCU_JA_PIGEON = 2,      /* Type C */
                        /* 32-bit: 121 to 256 children, 1024 bytes */
                        /* 64-bit: 125 to 256 children, 2048 bytes */
-       LEAF   = 3,     /* Leaf node */
+       /* Leaf nodes are implicit from their height in the tree */
 };
 
 If entire pointer is NULL, children is empty.
index 6dcd9c63d5f87b154ff96e03787364b5badf8612..012b8747747909801087ef24cff5cdc257a19ab0 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdint.h>
 #include <urcu/rcuja.h>
 #include "rcuja-internal.h"
 
+enum rcu_ja_child_type {
+       RCU_JA_LINEAR = 0,      /* Type A */
+                       /* 32-bit: 1 to 12 children, 8 to 64 bytes */
+                       /* 64-bit: 1 to 14 children, 16 to 128 bytes */
+       RCU_JA_BITMAP = 1,      /* Type B */
+                       /* 32-bit: 13 to 120 children, 128 to 512 bytes */
+                       /* 64-bit: 15 to 124 children, 256 to 1024 bytes */
+       RCU_JA_PIGEON = 2,      /* Type C */
+                       /* 32-bit: 121 to 256 children, 1024 bytes */
+                       /* 64-bit: 125 to 256 children, 2048 bytes */
+       /* Leaf nodes are implicit from their height in the tree */
+};
+
+struct rcu_ja_type_select {
+       enum rcu_ja_child_type type;
+       uint16_t max_nr_child;  /* 1 to 256 */
+       uint16_t node_order;    /* node size is (1 << node_order), in bytes */
+};
+
+/*
+ * Iteration on the array to find the right node size for the number of
+ * children stops when it reaches max_nr_child == 0 (this is the largest
+ * possible node size, which contains 256 children).
+ */
+const struct rcu_ja_type_select ja_select_u32[] = {
+       { .type = RCU_JA_LINEAR, .max_nr_child = 1, .node_order = 3, },
+       { .type = RCU_JA_LINEAR, .max_nr_child = 3, .node_order = 4, },
+       { .type = RCU_JA_LINEAR, .max_nr_child = 6, .node_order = 5, },
+       { .type = RCU_JA_LINEAR, .max_nr_child = 12, .node_order = 6, },
+
+       { .type = RCU_JA_BITMAP, .max_nr_child = 24, .node_order = 7, },
+       { .type = RCU_JA_BITMAP, .max_nr_child = 56, .node_order = 8, },
+       { .type = RCU_JA_BITMAP, .max_nr_child = 120, .node_order = 9, },
+
+       { .type = RCU_JA_PIGEON, .max_nr_child = 256, .node_order = 10, },
+};
+
+const struct rcu_ja_type_select ja_select_u64[] = {
+       { .type = RCU_JA_LINEAR, .max_nr_child = 1, .node_order = 4, },
+       { .type = RCU_JA_LINEAR, .max_nr_child = 3, .node_order = 5, },
+       { .type = RCU_JA_LINEAR, .max_nr_child = 7, .node_order = 6, },
+       { .type = RCU_JA_LINEAR, .max_nr_child = 14, .node_order = 7, },
+
+       { .type = RCU_JA_BITMAP, .max_nr_child = 28, .node_order = 8, },
+       { .type = RCU_JA_BITMAP, .max_nr_child = 60, .node_order = 9, },
+       { .type = RCU_JA_BITMAP, .max_nr_child = 124, .node_order = 10, },
+
+       { .type = RCU_JA_PIGEON, .max_nr_child = 256, .node_order = 11, },
+};
+
+/*
+ * The rcu_ja_node starts with a byte counting the number of children in
+ * the node. Then, the node-specific data is placed.
+ * TODO: where should we put the mutex for the node ?
+ *  -> mutex could be a 0-value node count.
+ * TODO: where do we keep nr children for pigeon ?
+ */
+struct rcu_ja_node {
+       char data[];
+};
+
+struct rcu_ja_node *create_rcu_ja_node(struct rcu_ja_type_select *sel)
+{
+       return zmalloc(1 << sel->node_order);
+}
+
+void free_rcu_ja_node(struct rcu_ja_node *node)
+{
+       free(node);
+}
+
+
+
This page took 0.027935 seconds and 4 git commands to generate.