Fix: rcuja merge fixes
[userspace-rcu.git] / rcuja / rcuja.c
index a3acfbceb7dffebd2ce358a90094a1b41c962027..9398a222bcd526fc4d3dcd1f86e851a02a17ced4 100644 (file)
@@ -290,14 +290,15 @@ struct cds_ja_inode *alloc_cds_ja_node(struct cds_ja *ja,
                return NULL;
        }
        memset(p, 0, len);
-       uatomic_inc(&ja->nr_nodes_allocated);
+       if (ja_debug_counters())
+               uatomic_inc(&ja->nr_nodes_allocated);
        return p;
 }
 
 void free_cds_ja_node(struct cds_ja *ja, struct cds_ja_inode *node)
 {
        free(node);
-       if (node)
+       if (ja_debug_counters() && node)
                uatomic_inc(&ja->nr_nodes_freed);
 }
 
@@ -416,7 +417,7 @@ struct cds_ja_inode_flag *ja_linear_node_get_direction(const struct cds_ja_type
        assert(match_v >= 0 && match_v < JA_ENTRY_PER_NODE);
 
        *result_key = (uint8_t) match_v;
-       return match_ptr;
+       return rcu_dereference(match_ptr);
 }
 
 static
@@ -1605,7 +1606,8 @@ skip_copy:
                dbg_printf("Using fallback for %u children, node type index: %u, mode %s\n",
                        new_shadow_node->nr_child, old_type_index, mode == JA_RECOMPACT_ADD_NEXT ? "add_next" :
                                (mode == JA_RECOMPACT_DEL ? "del" : "add_same"));
-               uatomic_inc(&ja->node_fallback_count_distribution[new_shadow_node->nr_child]);
+               if (ja_debug_counters())
+                       uatomic_inc(&ja->node_fallback_count_distribution[new_shadow_node->nr_child]);
        }
 
        /* Return pointer to new recompacted node through old_node_flag_ptr */
@@ -1671,7 +1673,8 @@ fallback_toosmall:
                } else {
                        new_type_index++;
                        dbg_printf("Add fallback to type %d\n", new_type_index);
-                       uatomic_inc(&ja->nr_fallback);
+                       if (ja_debug_counters())
+                               uatomic_inc(&ja->nr_fallback);
                        fallback = 1;
                        goto retry;
                }
@@ -2698,6 +2701,9 @@ int ja_final_checks(struct cds_ja *ja)
        unsigned long na, nf, nr_fallback;
        int ret = 0;
 
+       if (!ja_debug_counters())
+               return 0;
+
        fallback_ratio = (double) uatomic_read(&ja->nr_fallback);
        fallback_ratio /= (double) uatomic_read(&ja->nr_nodes_allocated);
        nr_fallback = uatomic_read(&ja->nr_fallback);
This page took 0.023604 seconds and 4 git commands to generate.