]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Add test for reverse search with mask.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 7 May 2020 20:07:17 +0000 (16:07 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:04:44 +0000 (15:04 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c
lib/test_maple_tree.c

index e2fe1d4809025b751396c586461c771a091c8fdb..031df798f6c4c34731a82bf0d4d609e85cd4aa8b 100644 (file)
@@ -4988,11 +4988,11 @@ static void _mas_empty_or_single_unmapped_area(struct ma_state *mas,
                return;
        }
 
-       mas->index = max - size + 1;
        mas->index = max;
 }
-static inline int _mas_get_unmapped_area(struct ma_state *mas, unsigned long min,
-               unsigned long max, unsigned long size, bool forward)
+static inline int _mas_get_unmapped_area(struct ma_state *mas,
+               unsigned long min, unsigned long max, unsigned long size, bool
+               forward)
 {
        mas_start(mas);
        max--; // Convert to inclusive.
index 1955e8a21e3606e6df77b0d6590124650137d87b..97c3ed5fa182b7ccbda85ee982bc8e1f0651b56d 100644 (file)
@@ -22653,6 +22653,74 @@ STORE, 140415509696512, 140415535910911,
 ERASE, 140415537422336, 140415562588159,
 STORE, 140415482433536, 140415509696511,
        };
+       unsigned long set28[] = {
+STORE, 140737488347136, 140737488351231,
+STORE, 140722475622400, 140737488351231,
+SNULL, 140722475626495, 140737488351231,
+STORE, 140722475622400, 140722475626495,
+STORE, 140722475491328, 140722475626495,
+STORE, 93865834291200, 93865836548095,
+SNULL, 93865834422271, 93865836548095,
+STORE, 93865834291200, 93865834422271,
+STORE, 93865834422272, 93865836548095,
+ERASE, 93865834422272, 93865836548095,
+STORE, 93865836519424, 93865836527615,
+STORE, 93865836527616, 93865836548095,
+STORE, 139918411104256, 139918413357055,
+SNULL, 139918411247615, 139918413357055,
+STORE, 139918411104256, 139918411247615,
+STORE, 139918411247616, 139918413357055,
+ERASE, 139918411247616, 139918413357055,
+STORE, 139918413344768, 139918413352959,
+STORE, 139918413352960, 139918413357055,
+STORE, 140722476642304, 140722476646399,
+STORE, 140722476630016, 140722476642303,
+STORE, 139918413316096, 139918413344767,
+STORE, 139918413307904, 139918413316095,
+STORE, 139918408888320, 139918411104255,
+SNULL, 139918408888320, 139918408986623,
+STORE, 139918408986624, 139918411104255,
+STORE, 139918408888320, 139918408986623,
+SNULL, 139918411079679, 139918411104255,
+STORE, 139918408986624, 139918411079679,
+STORE, 139918411079680, 139918411104255,
+SNULL, 139918411079680, 139918411087871,
+STORE, 139918411087872, 139918411104255,
+STORE, 139918411079680, 139918411087871,
+ERASE, 139918411079680, 139918411087871,
+STORE, 139918411079680, 139918411087871,
+ERASE, 139918411087872, 139918411104255,
+STORE, 139918411087872, 139918411104255,
+STORE, 139918405091328, 139918408888319,
+SNULL, 139918405091328, 139918406750207,
+STORE, 139918406750208, 139918408888319,
+STORE, 139918405091328, 139918406750207,
+SNULL, 139918408847359, 139918408888319,
+STORE, 139918406750208, 139918408847359,
+STORE, 139918408847360, 139918408888319,
+SNULL, 139918408847360, 139918408871935,
+STORE, 139918408871936, 139918408888319,
+STORE, 139918408847360, 139918408871935,
+ERASE, 139918408847360, 139918408871935,
+STORE, 139918408847360, 139918408871935,
+ERASE, 139918408871936, 139918408888319,
+STORE, 139918408871936, 139918408888319,
+STORE, 139918413299712, 139918413316095,
+SNULL, 139918408863743, 139918408871935,
+STORE, 139918408847360, 139918408863743,
+STORE, 139918408863744, 139918408871935,
+SNULL, 139918411083775, 139918411087871,
+STORE, 139918411079680, 139918411083775,
+STORE, 139918411083776, 139918411087871,
+SNULL, 93865836523519, 93865836527615,
+STORE, 93865836519424, 93865836523519,
+STORE, 93865836523520, 93865836527615,
+SNULL, 139918413348863, 139918413352959,
+STORE, 139918413344768, 139918413348863,
+STORE, 139918413348864, 139918413352959,
+ERASE, 139918413316096, 139918413344767,
+STORE, 93865848528896, 93865848664063,
+       };
 
        int cnt = 0;
        void *ptr = NULL;
@@ -22884,6 +22952,20 @@ STORE, 140415482433536, 140415509696511,
        mt_set_non_kernel(0);
        mt_validate(mt);
        mtree_destroy(mt);
+
+       mt_set_non_kernel(99);
+       mas_reset(&mas);
+       mtree_init(mt, MAPLE_ALLOC_RANGE);
+       check_erase2_testset(mt, set28, ARRAY_SIZE(set28));
+       rcu_barrier();
+       mas_get_unmapped_area_rev(&mas, 4096, 139918413357056, 4190208);
+       mas.index = (mas.index + 2093056 - 0) &(~2093056); // align_mast = 2093056 offset = 0
+       printk("mas.index %lu we want %lu\n", mas.index, 139918401601536);
+
+       MT_BUG_ON(mt, mas.index != 139918401601536);
+       mt_set_non_kernel(0);
+       mt_validate(mt);
+       mtree_destroy(mt);
 }
 
 static noinline void check_alloc_rev_range(struct maple_tree *mt)
@@ -23696,7 +23778,6 @@ static int maple_tree_seed(void)
        check_find_2(&tree);
        mtree_destroy(&tree);
 
-
        mtree_init(&tree, MAPLE_ALLOC_RANGE);
        check_prev_entry(&tree);
        mtree_init(&tree, 0);