mtree_destroy(mt);
}
-static inline int zeroed(struct maple_node *node)
+static inline int not_empty(struct maple_node *node)
{
int i;
static noinline void check_new_node(struct maple_tree *mt)
{
- struct maple_node *mn;
+ struct maple_node *mn, *mn2, *mn3;
struct maple_alloc *smn;
struct maple_node *nodes[100];
int i, j, total;
MT_BUG_ON(mt, mas_allocated(&mas) != 3);
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
MT_BUG_ON(mt, mn == NULL);
MT_BUG_ON(mt, mas.alloc == NULL);
MT_BUG_ON(mt, mas.alloc->slot[0] == NULL);
MT_BUG_ON(mt, !mas_nomem(&mas, GFP_KERNEL));
// Eat the requested node.
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
MT_BUG_ON(mt, mn == NULL);
MT_BUG_ON(mt, mn->slot[0] != NULL);
MT_BUG_ON(mt, mn->slot[1] != NULL);
MT_BUG_ON(mt, mas_allocated(&mas) != 1);
// Check the node is only one node.
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
MT_BUG_ON(mt, mas_allocated(&mas) != 0);
MT_BUG_ON(mt, mn == NULL);
MT_BUG_ON(mt, mn->slot[0] != NULL);
mn = mas_pop_node(&mas);
MT_BUG_ON(mt, mas_allocated(&mas) != i);
MT_BUG_ON(mt, !mn);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
ma_free_rcu(mn);
}
e = i - 2;
MT_BUG_ON(mt, mas.alloc->node_count != e);
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
MT_BUG_ON(mt, mas_allocated(&mas) != i - 1);
MT_BUG_ON(mt, !mn);
ma_free_rcu(mn);
mn = mas_pop_node(&mas);
MT_BUG_ON(mt, mas_allocated(&mas) != j - 1);
MT_BUG_ON(mt, !mn);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
mas_push_node(&mas, (struct maple_enode *)mn);
MT_BUG_ON(mt, mas_allocated(&mas) != j);
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
MT_BUG_ON(mt, mas_allocated(&mas) != j - 1);
ma_free_rcu(mn);
}
for (j = 0; j <= i/2; j++) {
MT_BUG_ON(mt, mas_allocated(&mas) != i - j);
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
ma_free_rcu(mn);
MT_BUG_ON(mt, mas_allocated(&mas) != i - j - 1);
}
for (j = i; j > 0; j--) { //Free the requests
mn = mas_pop_node(&mas); // get the next node.
MT_BUG_ON(mt, mn == NULL);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
ma_free_rcu(mn);
}
MT_BUG_ON(mt, mas_allocated(&mas) != 0);
for (j = 1; j <= i; j++) { // Move the allocations to mas2
mn = mas_pop_node(&mas); // get the next node.
MT_BUG_ON(mt, mn == NULL);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
mas_push_node(&mas2, (struct maple_enode *)mn);
MT_BUG_ON(mt, mas_allocated(&mas2) != j);
}
MT_BUG_ON(mt, mas_allocated(&mas2) != j);
mn = mas_pop_node(&mas2); // get the next node.
MT_BUG_ON(mt, mn == NULL);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
ma_free_rcu(mn);
}
MT_BUG_ON(mt, mas_allocated(&mas2) != 0);
mn = mas_pop_node(&mas); // get the next node.
MT_BUG_ON(mt, mn == NULL);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
MT_BUG_ON(mt, mas_allocated(&mas) != MAPLE_ALLOC_SLOTS);
MT_BUG_ON(mt, mas.alloc->node_count != MAPLE_ALLOC_SLOTS - 2);
MT_BUG_ON(mt, mas.alloc->node_count);
MT_BUG_ON(mt, mas_allocated(&mas) != MAPLE_ALLOC_SLOTS + 2);
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
MT_BUG_ON(mt, mas_allocated(&mas) != MAPLE_ALLOC_SLOTS + 1);
MT_BUG_ON(mt, mas.alloc->node_count != MAPLE_ALLOC_SLOTS - 1);
mas_push_node(&mas, (struct maple_enode *)mn);
MT_BUG_ON(mt, mas.alloc->node_count);
MT_BUG_ON(mt, mas_allocated(&mas) != MAPLE_ALLOC_SLOTS + 2);
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
ma_free_rcu(mn);
for (i = 1; i <= MAPLE_ALLOC_SLOTS + 1; i++) {
mn = mas_pop_node(&mas);
- MT_BUG_ON(mt, zeroed(mn));
+ MT_BUG_ON(mt, not_empty(mn));
ma_free_rcu(mn);
}
MT_BUG_ON(mt, mas_allocated(&mas) != 0);
+
+
+ for (i = 3; i < MAPLE_NODE_MASK * 3; i++) {
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, i); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ mn = mas_pop_node(&mas); // get the next node.
+ mas_push_node(&mas, (struct maple_enode *)mn); // put it back
+ mas_destroy(&mas);
+
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, i); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ mn = mas_pop_node(&mas); // get the next node.
+ mn2 = mas_pop_node(&mas); // get the next node.
+ mas_push_node(&mas, (struct maple_enode *)mn); // put them back
+ mas_push_node(&mas, (struct maple_enode *)mn2);
+ mas_destroy(&mas);
+
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, i); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ mn = mas_pop_node(&mas); // get the next node.
+ mn2 = mas_pop_node(&mas); // get the next node.
+ mn3 = mas_pop_node(&mas); // get the next node.
+ mas_push_node(&mas, (struct maple_enode *)mn); // put them back
+ mas_push_node(&mas, (struct maple_enode *)mn2);
+ mas_push_node(&mas, (struct maple_enode *)mn3);
+ mas_destroy(&mas);
+
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, i); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ mn = mas_pop_node(&mas); // get the next node.
+ ma_free_rcu(mn);
+ mas_destroy(&mas);
+
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, i); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ mn = mas_pop_node(&mas); // get the next node.
+ ma_free_rcu(mn);
+ mn = mas_pop_node(&mas); // get the next node.
+ ma_free_rcu(mn);
+ mn = mas_pop_node(&mas); // get the next node.
+ ma_free_rcu(mn);
+ mas_destroy(&mas);
+ }
+
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, 5); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ MT_BUG_ON(mt, mas_allocated(&mas) != 5);
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, 10); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ mas.node = MAS_START;
+ MT_BUG_ON(mt, mas_allocated(&mas) != 10);
+ mas_destroy(&mas);
+
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, MAPLE_ALLOC_SLOTS - 1); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ MT_BUG_ON(mt, mas_allocated(&mas) != MAPLE_ALLOC_SLOTS - 1);
+ mas.node = MA_ERROR(-ENOMEM);
+ mas_node_count(&mas, 10 + MAPLE_ALLOC_SLOTS - 1); // Request
+ mas_nomem(&mas, GFP_KERNEL); // Fill request
+ mas.node = MAS_START;
+ MT_BUG_ON(mt, mas_allocated(&mas) != 10 + MAPLE_ALLOC_SLOTS - 1);
+ mas_destroy(&mas);
+
mtree_unlock(mt);
mtree_destroy(mt);
}
}
val = 0;
- mas_reset(&mas);
- mas.index = val;
-
+ mas_set(&mas, val);
+ mas_lock(&mas);
while ((entry = mas_find(&mas, 268435456)) != NULL) {
if (val != 64)
MT_BUG_ON(mt, xa_mk_value(val) != entry);
if (!val)
val = 1;
}
+ mas_unlock(&mas);
val = 0;
- mas_reset(&mas);
- mas.index = val;
+ mas_set(&mas, val);
+ mas_lock(&mas);
mas_for_each(&mas, entry, ULONG_MAX) {
if (val != 64)
MT_BUG_ON(mt, xa_mk_value(val) != entry);
if (!val)
val = 1;
}
+ mas_unlock(&mas);
/* Test mas_pause */
val = 0;
val = 0;
mas_set(&mas, 0);
- mas_reset(&mas);
mas_lock(&mas);
mas_for_each(&mas, entry, ULONG_MAX) {
if (val == 64)
entry2 = mas_prev(&mas, 0);
MT_BUG_ON(mt, entry != entry2);
- mas_reset(&mas);
- mas.index = 0;
- mas.last = 0;
+ mas_set(&mas, 0);
MT_BUG_ON(mt, !!mas_prev(&mas, 0));
mas_unlock(&mas);
newmas.last = mas.last;
mas_store_gfp(&newmas, val, GFP_KERNEL);
}
- printk("alloc is %px\n", newmas.alloc);
+
mt_validate(&newmt);
mt_set_non_kernel(0);
mtree_destroy(&newmt);