]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Add tracepoints, remove SLAB_RECLAIM
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 7 Aug 2020 00:17:30 +0000 (20:17 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:30:13 +0000 (12:30 -0500)
Also reorder setting of slot in mas_Descend_adopt and fix comment for smp_wmb

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/trace/events/maple_tree.h [new file with mode: 0644]
lib/maple_tree.c

diff --git a/include/trace/events/maple_tree.h b/include/trace/events/maple_tree.h
new file mode 100644 (file)
index 0000000..4280351
--- /dev/null
@@ -0,0 +1,117 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM mm_mt
+
+#if !defined(_TRACE_MM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_MM_H
+
+
+#include <linux/tracepoint.h>
+
+struct ma_state;
+struct maple_subree_state;
+struct maple_big_node;
+
+TRACE_EVENT(mas_split,
+
+       TP_PROTO(struct ma_state *mas),
+
+       TP_ARGS(mas),
+
+       TP_STRUCT__entry(
+                       __field(struct ma_state *, mas)
+                       __field(unsigned long, index)
+                       __field(unsigned long, last)
+       ),
+
+       TP_fast_assign(
+                       __entry->mas            = mas;
+                       __entry->index          = mas->index;
+                       __entry->last           = mas->last;
+       ),
+
+       TP_printk("mas_split:\t%lu-%lu",
+                 (unsigned long) __entry->index,
+                 (unsigned long) __entry->last
+       )
+);
+
+TRACE_EVENT(mas_spanning_store,
+
+       TP_PROTO(struct ma_state *mas, void *entry),
+
+       TP_ARGS(mas, entry),
+
+       TP_STRUCT__entry(
+                       __field(struct ma_state *, mas)
+                       __field(unsigned long, index)
+                       __field(unsigned long, last)
+       ),
+
+       TP_fast_assign(
+                       __entry->mas            = mas;
+                       __entry->index          = mas->index;
+                       __entry->last           = mas->last;
+       ),
+
+       TP_printk("mas_spanning_store:\t%lu-%lu",
+                 (unsigned long) __entry->index,
+                 (unsigned long) __entry->last
+       )
+);
+
+TRACE_EVENT(mas_rebalance,
+
+       TP_PROTO(struct ma_state *mas, struct maple_big_node *b_node),
+
+       TP_ARGS(mas, entry),
+
+       TP_STRUCT__entry(
+                       __field(struct ma_state *, mas)
+                       __field(unsigned long, index)
+                       __field(unsigned long, last)
+       ),
+
+       TP_fast_assign(
+                       __entry->mas            = mas;
+                       __entry->index          = mas->index;
+                       __entry->last           = mas->last;
+       ),
+
+       TP_printk("mas_rebalance:\t%lu-%lu",
+                 (unsigned long) __entry->index,
+                 (unsigned long) __entry->last
+       )
+);
+
+TRACE_EVENT(mas_spanning_rebalance,
+
+       TP_PROTO(struct ma_state *mas,
+                struct maple_subtree_state *mast,
+                void *entry),
+
+       TP_ARGS(mas, entry),
+
+       TP_STRUCT__entry(
+                       __field(struct ma_state *, mas)
+                       __field(unsigned long, index)
+                       __field(unsigned long, last)
+       ),
+
+       TP_fast_assign(
+                       __entry->mas            = mas;
+                       __entry->index          = mas->index;
+                       __entry->last           = mas->last;
+       ),
+
+       TP_printk("mas_spanning_rebalance:\t%lu-%lu",
+                 (unsigned long) __entry->index,
+                 (unsigned long) __entry->last
+       )
+);
+
+
+#endif /* _TRACE_MM_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
index 46864639a091b5ce964e2246e87decb413f74876..99b5b9b8724aeb49351c2617b253af52f3bc0a90 100644 (file)
@@ -15,6 +15,9 @@
 #include <asm/barrier.h>
 //#include <linux/mm.h> // for task_size
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/maple_tree.h>
+
 #define MA_ROOT_PARENT 1
 #define ma_parent_ptr(x) ((struct maple_pnode *)(x))
 #define ma_mnode_ptr(x) ((struct maple_node *)(x))
@@ -1640,8 +1643,8 @@ static inline void mas_descend_adopt(struct ma_state *mas)
                        next[n++].node = MAS_NONE;
 
                for (i = 0; i < 3; i++) { // descend.
+                       mas_set_slot(&next[i], 0);
                        mas_dup_state(&list[i], &next[i]);
-                       mas_set_slot(&list[i], 0);
                }
        }
 }
@@ -2102,9 +2105,7 @@ static inline void mas_wmb_replace(struct ma_state *mas,
                                   struct ma_topiary *free,
                                   struct ma_topiary *destroy)
 {
-       /* Before replacing the tree items, be sure the old data is marked dead
-        * across all CPUs
-        */
+        /* All nodes must see old data as dead prior to replacing that data.  */
        smp_wmb();
 
        // Insert the new data in the tree
@@ -2362,6 +2363,8 @@ static inline int mas_rebalance(struct ma_state *mas,
        MA_STATE(l_mas, mas->tree, mas->index, mas->last);
        MA_STATE(r_mas, mas->tree, mas->index, mas->last);
 
+       trace_mas_rebalance(mas, b_node);
+
        mas_node_cnt(mas, 1 + empty_cnt * 2);
        if (mas_is_err(mas))
                return 0;
@@ -2462,6 +2465,7 @@ static inline int mas_split(struct ma_state *mas,
        int height = 0;
        unsigned char mid_split;
 
+       trace_mas_split(mas);
        MA_STATE(l_mas, mas->tree, mas->index, mas->last);
        MA_STATE(r_mas, mas->tree, mas->index, mas->last);
        MA_STATE(prev_l_mas, mas->tree, mas->index, mas->last);
@@ -2879,6 +2883,7 @@ static inline int mas_spanning_store(struct ma_state *mas, void *entry)
        struct maple_subtree_state mast;
        int node_cnt = 0;
 
+       trace_mas_spanning_store(mas, entry);
        // Holds new left and right sub-tree
        MA_STATE(l_mas, mas->tree, mas->index, mas->index);
        MA_STATE(r_mas, mas->tree, mas->index, mas->index);
@@ -4200,7 +4205,7 @@ void __init maple_tree_init(void)
 {
        maple_node_cache = kmem_cache_create("maple_node",
                        sizeof(struct maple_node), sizeof(struct maple_node),
-                       SLAB_PANIC | SLAB_RECLAIM_ACCOUNT, NULL);
+                       SLAB_PANIC, NULL);
 }
 void mtree_init(struct maple_tree *mt, unsigned int ma_flags)
 {