always inlined and such
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 29 Nov 2024 23:26:03 +0000 (18:26 -0500)
committerLiam R. Howlett <howlett@gmail.com>
Mon, 27 Jan 2025 20:41:19 +0000 (15:41 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c
lib/test_maple_tree.c

index 96b58ce48570e22e9c8dea8ad82d0d04b6899f3c..ab0f8123e4850b4204cac2173c2c7eed8bf59eb6 100644 (file)
@@ -3193,7 +3193,7 @@ struct ma_node_state {
        bool alloc;
 };
 
-static inline
+static __always_inline
 void mns_node_part_leaf_init(struct ma_node_part *ma_part,
                struct ma_wr_state *wr_mas, struct ma_node_state *src)
 {
@@ -3242,7 +3242,7 @@ void mns_node_part_init(struct ma_node_part *ma_part,
        ma_part->skip = 1;
 }
 
-static inline
+static __always_inline
 void mns_insert_part(struct ma_node_part *part,
                struct ma_node_state *dst)
 {
@@ -3329,7 +3329,8 @@ void mns_mas_init(struct ma_node_state *mns, struct ma_state *mas)
  * @len: The number of offsets to copy
  *
  */
-static inline void mns_cp(struct ma_node_state *src, struct ma_node_state *dst,
+static __always_inline
+void mns_cp(struct ma_node_state *src, struct ma_node_state *dst,
                unsigned char len)
 {
        unsigned long max;
@@ -3345,7 +3346,6 @@ static inline void mns_cp(struct ma_node_state *src, struct ma_node_state *dst,
        if (src->gaps)
                memcpy(dst->gaps + dst->offset, src->gaps + src->offset, size);
 
-       BUG_ON(src->offset + len > mt_slots[src->type]);
        if (src->offset + len > mt_pivots[src->type]) {
                size = mt_pivots[src->type] - src->offset;
                max = src->max;
@@ -3376,7 +3376,8 @@ static inline void mns_cp(struct ma_node_state *src, struct ma_node_state *dst,
  * Zero any area that needs to be zeroed and set the metadata.
  * metadata needs the largest gap for non-leaves.
  */
-static inline void mns_finalise(struct ma_node_state *p)
+static __always_inline
+void mns_finalise(struct ma_node_state *p)
 {
        unsigned long max_gap;
        unsigned char len;
@@ -3402,6 +3403,8 @@ static inline void mns_finalise(struct ma_node_state *p)
                unsigned char offset;
                unsigned char i;
                unsigned long gap, pstart;
+               unsigned long *pivs;
+               void **slots;
 
                if (!p->alloc)
                        goto finalise_leaf;
@@ -3423,11 +3426,13 @@ static inline void mns_finalise(struct ma_node_state *p)
                                goto finalise_leaf;
                }
 
+               slots = p->slots;
+               pivs = p->pivots;
                /* Special case the first slot before the loop */
-               if (likely(!p->slots[0])) {
+               if (likely(!slots[0])) {
                        //printk("slot 0 is %p\n", p->slots[0]);
                        //printk("first slot check (%lu - %lu + 1\n", p->pivots[0], p->min);
-                       gap = p->pivots[0] - p->min + 1;
+                       gap = pivs[0] - p->min + 1;
                        if (gap > max_gap)
                                max_gap = gap;
                        //printk("gap is now %lu\n", max_gap);
@@ -3439,12 +3444,12 @@ static inline void mns_finalise(struct ma_node_state *p)
 
                for (; i <= offset; i++) {
                        /* data == no gap. */
-                       if (likely(p->slots[i]))
+                       if (slots[i])
                                continue;
 
                        //printk("empty slot at %u\n", i);
-                       pstart = p->pivots[i - 1];
-                       gap = p->pivots[i] - pstart;
+                       pstart = pivs[i - 1];
+                       gap = pivs[i] - pstart;
                        //printk("gap is %lu vs %lu\n", gap, max_gap);
                        if (gap > max_gap)
                                max_gap = gap;
@@ -4472,6 +4477,7 @@ done:
        trace_ma_write(__func__, mas, 0, wr_mas->entry);
        mas_update_gap(mas);
        mas->end = new_end;
+       //mt_dump(mas->tree, mt_dump_hex);
        return;
 }
 
index 8428802909c5cab8815c1028974f7af6f33228b4..034966e3d8eeac6b1eed62b0f313d544d568038a 100644 (file)
@@ -40,7 +40,7 @@ atomic_t maple_tree_tests_passed;
 #endif
 
 /* #define BENCH_SLOT_STORE */
-/* #define BENCH_NODE_STORE */
+#define BENCH_NODE_STORE
 /* #define BENCH_AWALK */
 /* #define BENCH_WALK */
 /* #define BENCH_LOAD */
@@ -1855,7 +1855,7 @@ static noinline void __init bench_slot_store(struct maple_tree *mt)
 #if defined(BENCH_NODE_STORE)
 static noinline void __init bench_node_store(struct maple_tree *mt)
 {
-       int i, overwrite = 76, max = 240, count = 20000000;
+       int i, overwrite = 76, max = 240, count = 50000000;
 
        for (i = 0; i < max; i += 10)
                mtree_store_range(mt, i, i + 5, xa_mk_value(i), GFP_KERNEL);