aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_xarray.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/test_xarray.c')
-rw-r--r--lib/test_xarray.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index 38cab4ccb24e..ff94b54a926d 100644
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -199,9 +199,25 @@ static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index)
199 xa_store_order(xa, index, order, xa_mk_value(index), 199 xa_store_order(xa, index, order, xa_mk_value(index),
200 GFP_KERNEL); 200 GFP_KERNEL);
201 for (i = base; i < next; i++) { 201 for (i = base; i < next; i++) {
202 XA_STATE(xas, xa, i);
203 unsigned int seen = 0;
204 void *entry;
205
202 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0)); 206 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0));
203 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_1)); 207 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_1));
204 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_2)); 208 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_2));
209
210 /* We should see two elements in the array */
211 xas_for_each(&xas, entry, ULONG_MAX)
212 seen++;
213 XA_BUG_ON(xa, seen != 2);
214
215 /* One of which is marked */
216 xas_set(&xas, 0);
217 seen = 0;
218 xas_for_each_marked(&xas, entry, ULONG_MAX, XA_MARK_0)
219 seen++;
220 XA_BUG_ON(xa, seen != 1);
205 } 221 }
206 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_0)); 222 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_0));
207 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_1)); 223 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_1));
@@ -265,6 +281,8 @@ static noinline void check_xa_shrink(struct xarray *xa)
265{ 281{
266 XA_STATE(xas, xa, 1); 282 XA_STATE(xas, xa, 1);
267 struct xa_node *node; 283 struct xa_node *node;
284 unsigned int order;
285 unsigned int max_order = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 15 : 1;
268 286
269 XA_BUG_ON(xa, !xa_empty(xa)); 287 XA_BUG_ON(xa, !xa_empty(xa));
270 XA_BUG_ON(xa, xa_store_index(xa, 0, GFP_KERNEL) != NULL); 288 XA_BUG_ON(xa, xa_store_index(xa, 0, GFP_KERNEL) != NULL);
@@ -287,6 +305,25 @@ static noinline void check_xa_shrink(struct xarray *xa)
287 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(0)); 305 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(0));
288 xa_erase_index(xa, 0); 306 xa_erase_index(xa, 0);
289 XA_BUG_ON(xa, !xa_empty(xa)); 307 XA_BUG_ON(xa, !xa_empty(xa));
308
309 for (order = 0; order < max_order; order++) {
310 unsigned long max = (1UL << order) - 1;
311 xa_store_order(xa, 0, order, xa_mk_value(0), GFP_KERNEL);
312 XA_BUG_ON(xa, xa_load(xa, max) != xa_mk_value(0));
313 XA_BUG_ON(xa, xa_load(xa, max + 1) != NULL);
314 rcu_read_lock();
315 node = xa_head(xa);
316 rcu_read_unlock();
317 XA_BUG_ON(xa, xa_store_index(xa, ULONG_MAX, GFP_KERNEL) !=
318 NULL);
319 rcu_read_lock();
320 XA_BUG_ON(xa, xa_head(xa) == node);
321 rcu_read_unlock();
322 XA_BUG_ON(xa, xa_load(xa, max + 1) != NULL);
323 xa_erase_index(xa, ULONG_MAX);
324 XA_BUG_ON(xa, xa->xa_head != node);
325 xa_erase_index(xa, 0);
326 }
290} 327}
291 328
292static noinline void check_cmpxchg(struct xarray *xa) 329static noinline void check_cmpxchg(struct xarray *xa)