From 22b6123c84029d922b4783450763648f8bb30c57 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 2 Apr 2019 10:59:15 -0400 Subject: [PATCH] maple_tree: messy test output Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 13 ++++---- lib/test_maple_tree.c | 72 ++++++++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d66cb0549566..b25a568cac2f 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1145,7 +1145,6 @@ static inline int ma_split(struct ma_state *mas, unsigned char slot) struct maple_enode *left = NULL, *right = NULL; enum maple_type ptype; // parent type. unsigned long pivot; - unsigned char slot_cnt = mt_slot_count(mas->node); if (ma_is_root(mas->node)) { old_parent = full; @@ -1161,7 +1160,7 @@ static inline int ma_split(struct ma_state *mas, unsigned char slot) old_parent = mas->node; ptype = mt_node_type(mas->node); p_end = ma_data_end(mas->node, ptype); - if (p_end >= slot_cnt - 1) { + if (p_end >= mt_slots[ptype] - 1) { /* Must split the parent */ split = ma_split(mas, p_slot); if (mas_is_err(mas)) @@ -1191,10 +1190,12 @@ static inline int ma_split(struct ma_state *mas, unsigned char slot) // Copy the parent data and leave a hole. MA_CP(cp, old_parent, new_parent, 0, p_slot); ma_copy(mas, &cp); - cp.dst_start += 1; - cp.src_start = p_slot + 1; - cp.src_end = p_end + 1; - ma_copy(mas, &cp); + if (p_slot < mt_slots[ptype] - 1) { + cp.dst_start += 1; + cp.src_start = p_slot + 1; + cp.src_end = p_end + 1; + ma_copy(mas, &cp); + } } // calculate the split location. diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index d3d2ce2f2b29..d46bdd31c04f 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -280,23 +280,48 @@ static noinline void check_mid_split(struct maple_tree *mt) static noinline void check_alloc_range(struct maple_tree *mt) { // cat /proc/self/maps|awk '{print $1}'| awk -F "-" '{printf "0x%s, 0x%s, ", $1, $2}' - unsigned long range[] = { 0x565234af2000, 0x565234af4000, - 0x565234af4000, 0x565234af9000, 0x565234af9000, - 0x565234afb000, 0x565234afc000, 0x565234afd000, - 0x565234afd000, 0x565234afe000, 0x565235def000, - 0x565235e10000, 0x7f36d4bfd000, 0x7f36d4ee2000, - 0x7f36d4ee2000, 0x7f36d4f04000, 0x7f36d4f04000, - 0x7f36d504c000, 0x7f36d504c000, 0x7f36d5098000, - 0x7f36d5098000, 0x7f36d5099000, 0x7f36d5099000, - 0x7f36d509d000, 0x7f36d509d000, 0x7f36d509f000, - 0x7f36d509f000, 0x7f36d50a5000, 0x7f36d50b9000, - 0x7f36d50db000, 0x7f36d50db000, 0x7f36d50dc000, - 0x7f36d50dc000, 0x7f36d50fa000, 0x7f36d50fa000, - 0x7f36d5102000, 0x7f36d5102000, 0x7f36d5103000, - 0x7f36d5103000, 0x7f36d5104000, 0x7f36d5104000, - 0x7f36d5105000, 0x7fff5876b000, 0x7fff5878d000, - 0x7fff5878e000, 0x7fff58791000, 0x7fff58791000, - 0x7fff58793000,}; + unsigned long range[] = { + 0x565234af2000, 0x565234af4000, + 0x565234af4000, 0x565234af9000, + 0x565234af9000, 0x565234afb000, + 0x565234afc000, 0x565234afd000, + 0x565234afd000, 0x565234afe000, + 0x565235def000, 0x565235e10000, + 0x7f36d4bfd000, 0x7f36d4ee2000, + 0x7f36d4ee2000, 0x7f36d4f04000, + 0x7f36d4f04000, 0x7f36d504c000, + 0x7f36d504c000, 0x7f36d5098000, + 0x7f36d5098000, 0x7f36d5099000, + 0x7f36d5099000, 0x7f36d509d000, + 0x7f36d509d000, 0x7f36d509f000, + 0x7f36d509f000, 0x7f36d50a5000, + 0x7f36d50b9000, 0x7f36d50db000, + 0x7f36d50db000, 0x7f36d50dc000, + 0x7f36d50dc000, 0x7f36d50fa000, + 0x7f36d50fa000, 0x7f36d5102000, + 0x7f36d5102000, 0x7f36d5103000, + 0x7f36d5103000, 0x7f36d5104000, + 0x7f36d5104000, 0x7f36d5105000, + 0x7fff5876b000, 0x7fff5878d000, + 0x7fff5878e000, 0x7fff58791000, + 0x7fff58791000, 0x7fff58793000, + 0x7fff58793000, 0x7fff58794000, // Added for ascend testing. + 0x7fff58794000, 0x7fff58796000, // Added for ascend testing. + 0x7fff58796000, 0x7fff58798000, // Added for ascend testing. + 0x7fff58798000, 0x7fff5879A000, // Added for ascend testing. + 0x7fff5879A000, 0x7fff5879C000, // Added for ascend testing. + 0x7fff5879C000, 0x7fff5879D000, // Added for ascend testing. + 0x7fff5879E000, 0x7fff5879F000, // Added for ascend testing. + 0x7fff5879F000, 0x7fff587A0000, // Added for ascend testing. + 0x7fff587A0000, 0x7fff587A3000, + 0x7fff587A3000, 0x7fff587A4000, // Added for ascend testing. + 0x7fff587A4000, 0x7fff587A6000, // Added for ascend testing. + 0x7fff587A6000, 0x7fff587A8000, // Added for ascend testing. + 0x7fff587A8000, 0x7fff587AA000, // Added for ascend testing. + 0x7fff587AA000, 0x7fff587AC000, // Added for ascend testing. + 0x7fff587AC000, 0x7fff587AD000, // Added for ascend testing. + 0x7fff587AE000, 0x7fff587AF000, // Added for ascend testing. + }; /* req_range consists of 4 values. * 1. min index @@ -314,16 +339,27 @@ static noinline void check_alloc_range(struct maple_tree *mt) 0x0, // Min 0x7fff58791000, // Max - 0x1000, // Size + 0x2000, // Size 0x0, // First hole in our data of size 1000. 0, // Return value success. + +#if 0 + 0x, // Min + 0x, // Max + 0x, // Size + 0x, // First hole in our data of size 1000. + 0, // Return value success. +#endif }; int i, range_cnt = sizeof(range)/sizeof(range[0]); int req_range_cnt = sizeof(req_range)/sizeof(req_range[0]); for (i = 0; i < range_cnt/2; i+=2) { + printk("i = %d, start = %ld\n", i, range[i] >> 12); check_insert_range(mt, range[i] >> 12, (range[i + 1] >> 12) - 1, xa_mk_value(range[i] >> 12)); + mt_dump(mt); + printk("Done\n\n"); } for (i = 0; i < req_range_cnt; i+=5) { -- 2.50.1