Lines Matching refs:xa
17 void xa_dump(const struct xarray *xa) { } in xa_dump() argument
20 #define XA_BUG_ON(xa, x) do { \ argument
24 xa_dump(xa); \
37 static void *xa_store_index(struct xarray *xa, unsigned long index, gfp_t gfp) in xa_store_index() argument
39 return xa_store(xa, index, xa_mk_index(index), gfp); in xa_store_index()
42 static void xa_insert_index(struct xarray *xa, unsigned long index) in xa_insert_index() argument
44 XA_BUG_ON(xa, xa_insert(xa, index, xa_mk_index(index), in xa_insert_index()
48 static void xa_alloc_index(struct xarray *xa, unsigned long index, gfp_t gfp) in xa_alloc_index() argument
52 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(index), xa_limit_32b, in xa_alloc_index()
54 XA_BUG_ON(xa, id != index); in xa_alloc_index()
57 static void xa_erase_index(struct xarray *xa, unsigned long index) in xa_erase_index() argument
59 XA_BUG_ON(xa, xa_erase(xa, index) != xa_mk_index(index)); in xa_erase_index()
60 XA_BUG_ON(xa, xa_load(xa, index) != NULL); in xa_erase_index()
68 static void *xa_store_order(struct xarray *xa, unsigned long index, in xa_store_order() argument
71 XA_STATE_ORDER(xas, xa, index, order); in xa_store_order()
83 static noinline void check_xa_err(struct xarray *xa) in check_xa_err() argument
85 XA_BUG_ON(xa, xa_err(xa_store_index(xa, 0, GFP_NOWAIT)) != 0); in check_xa_err()
86 XA_BUG_ON(xa, xa_err(xa_erase(xa, 0)) != 0); in check_xa_err()
89 XA_BUG_ON(xa, xa_err(xa_store_index(xa, 1, GFP_NOWAIT)) != -ENOMEM); in check_xa_err()
90 XA_BUG_ON(xa, xa_err(xa_store_index(xa, 1, GFP_NOWAIT)) != -ENOMEM); in check_xa_err()
92 XA_BUG_ON(xa, xa_err(xa_store_index(xa, 1, GFP_KERNEL)) != 0); in check_xa_err()
93 XA_BUG_ON(xa, xa_err(xa_store(xa, 1, xa_mk_value(0), GFP_KERNEL)) != 0); in check_xa_err()
94 XA_BUG_ON(xa, xa_err(xa_erase(xa, 1)) != 0); in check_xa_err()
99 static noinline void check_xas_retry(struct xarray *xa) in check_xas_retry() argument
101 XA_STATE(xas, xa, 0); in check_xas_retry()
104 xa_store_index(xa, 0, GFP_KERNEL); in check_xas_retry()
105 xa_store_index(xa, 1, GFP_KERNEL); in check_xas_retry()
108 XA_BUG_ON(xa, xas_find(&xas, ULONG_MAX) != xa_mk_value(0)); in check_xas_retry()
109 xa_erase_index(xa, 1); in check_xas_retry()
110 XA_BUG_ON(xa, !xa_is_retry(xas_reload(&xas))); in check_xas_retry()
111 XA_BUG_ON(xa, xas_retry(&xas, NULL)); in check_xas_retry()
112 XA_BUG_ON(xa, xas_retry(&xas, xa_mk_value(0))); in check_xas_retry()
114 XA_BUG_ON(xa, xas.xa_node != XAS_RESTART); in check_xas_retry()
115 XA_BUG_ON(xa, xas_next_entry(&xas, ULONG_MAX) != xa_mk_value(0)); in check_xas_retry()
116 XA_BUG_ON(xa, xas.xa_node != NULL); in check_xas_retry()
119 XA_BUG_ON(xa, xa_store_index(xa, 1, GFP_KERNEL) != NULL); in check_xas_retry()
122 XA_BUG_ON(xa, !xa_is_internal(xas_reload(&xas))); in check_xas_retry()
124 XA_BUG_ON(xa, xas_next_entry(&xas, ULONG_MAX) != xa_mk_value(0)); in check_xas_retry()
140 xa_erase_index(xa, 0); in check_xas_retry()
141 xa_erase_index(xa, 1); in check_xas_retry()
144 static noinline void check_xa_load(struct xarray *xa) in check_xa_load() argument
150 void *entry = xa_load(xa, j); in check_xa_load()
152 XA_BUG_ON(xa, xa_to_value(entry) != j); in check_xa_load()
154 XA_BUG_ON(xa, entry); in check_xa_load()
156 XA_BUG_ON(xa, xa_store_index(xa, i, GFP_KERNEL) != NULL); in check_xa_load()
161 void *entry = xa_load(xa, j); in check_xa_load()
163 XA_BUG_ON(xa, xa_to_value(entry) != j); in check_xa_load()
165 XA_BUG_ON(xa, entry); in check_xa_load()
167 xa_erase_index(xa, i); in check_xa_load()
169 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_load()
172 static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index) in check_xa_mark_1() argument
178 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0)); in check_xa_mark_1()
179 xa_set_mark(xa, index, XA_MARK_0); in check_xa_mark_1()
180 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0)); in check_xa_mark_1()
183 XA_BUG_ON(xa, xa_store_index(xa, index, GFP_KERNEL) != NULL); in check_xa_mark_1()
184 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0)); in check_xa_mark_1()
185 xa_set_mark(xa, index, XA_MARK_0); in check_xa_mark_1()
186 XA_BUG_ON(xa, !xa_get_mark(xa, index, XA_MARK_0)); in check_xa_mark_1()
189 XA_BUG_ON(xa, xa_get_mark(xa, index + 1, XA_MARK_0)); in check_xa_mark_1()
190 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_1)); in check_xa_mark_1()
193 xa_erase_index(xa, index); in check_xa_mark_1()
194 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_mark_1()
195 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0)); in check_xa_mark_1()
196 xa_set_mark(xa, index, XA_MARK_0); in check_xa_mark_1()
197 XA_BUG_ON(xa, xa_get_mark(xa, index, XA_MARK_0)); in check_xa_mark_1()
209 XA_BUG_ON(xa, xa_store_index(xa, index + 1, GFP_KERNEL)); in check_xa_mark_1()
210 xa_set_mark(xa, index + 1, XA_MARK_0); in check_xa_mark_1()
211 XA_BUG_ON(xa, xa_store_index(xa, index + 2, GFP_KERNEL)); in check_xa_mark_1()
212 xa_set_mark(xa, index + 2, XA_MARK_2); in check_xa_mark_1()
213 XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL)); in check_xa_mark_1()
214 xa_store_order(xa, index, order, xa_mk_index(index), in check_xa_mark_1()
217 XA_STATE(xas, xa, i); in check_xa_mark_1()
221 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0)); in check_xa_mark_1()
222 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_1)); in check_xa_mark_1()
223 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_2)); in check_xa_mark_1()
230 XA_BUG_ON(xa, seen != 2); in check_xa_mark_1()
239 XA_BUG_ON(xa, seen != 1); in check_xa_mark_1()
241 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_0)); in check_xa_mark_1()
242 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_1)); in check_xa_mark_1()
243 XA_BUG_ON(xa, xa_get_mark(xa, next, XA_MARK_2)); in check_xa_mark_1()
244 xa_erase_index(xa, index); in check_xa_mark_1()
245 xa_erase_index(xa, next); in check_xa_mark_1()
246 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_mark_1()
248 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_mark_1()
251 static noinline void check_xa_mark_2(struct xarray *xa) in check_xa_mark_2() argument
253 XA_STATE(xas, xa, 0); in check_xa_mark_2()
258 xa_store_index(xa, 0, GFP_KERNEL); in check_xa_mark_2()
259 xa_set_mark(xa, 0, XA_MARK_0); in check_xa_mark_2()
264 XA_BUG_ON(xa, !xa_get_mark(xa, 0, XA_MARK_0) == 0); in check_xa_mark_2()
267 xa_store_index(xa, index, GFP_KERNEL); in check_xa_mark_2()
268 xa_set_mark(xa, index, XA_MARK_0); in check_xa_mark_2()
276 XA_BUG_ON(xa, count != 1000); in check_xa_mark_2()
281 XA_BUG_ON(xa, !xa_get_mark(xa, xas.xa_index, XA_MARK_0)); in check_xa_mark_2()
282 XA_BUG_ON(xa, !xas_get_mark(&xas, XA_MARK_0)); in check_xa_mark_2()
286 xa_destroy(xa); in check_xa_mark_2()
289 static noinline void check_xa_mark(struct xarray *xa) in check_xa_mark() argument
294 check_xa_mark_1(xa, index); in check_xa_mark()
296 check_xa_mark_2(xa); in check_xa_mark()
299 static noinline void check_xa_shrink(struct xarray *xa) in check_xa_shrink() argument
301 XA_STATE(xas, xa, 1); in check_xa_shrink()
306 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_shrink()
307 XA_BUG_ON(xa, xa_store_index(xa, 0, GFP_KERNEL) != NULL); in check_xa_shrink()
308 XA_BUG_ON(xa, xa_store_index(xa, 1, GFP_KERNEL) != NULL); in check_xa_shrink()
315 XA_BUG_ON(xa, xas_load(&xas) != xa_mk_value(1)); in check_xa_shrink()
317 XA_BUG_ON(xa, xa_entry_locked(xa, node, 0) != xa_mk_value(0)); in check_xa_shrink()
318 XA_BUG_ON(xa, xas_store(&xas, NULL) != xa_mk_value(1)); in check_xa_shrink()
319 XA_BUG_ON(xa, xa_load(xa, 1) != NULL); in check_xa_shrink()
320 XA_BUG_ON(xa, xas.xa_node != XAS_BOUNDS); in check_xa_shrink()
321 XA_BUG_ON(xa, xa_entry_locked(xa, node, 0) != XA_RETRY_ENTRY); in check_xa_shrink()
322 XA_BUG_ON(xa, xas_load(&xas) != NULL); in check_xa_shrink()
324 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(0)); in check_xa_shrink()
325 xa_erase_index(xa, 0); in check_xa_shrink()
326 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_shrink()
330 xa_store_order(xa, 0, order, xa_mk_value(0), GFP_KERNEL); in check_xa_shrink()
331 XA_BUG_ON(xa, xa_load(xa, max) != xa_mk_value(0)); in check_xa_shrink()
332 XA_BUG_ON(xa, xa_load(xa, max + 1) != NULL); in check_xa_shrink()
334 node = xa_head(xa); in check_xa_shrink()
336 XA_BUG_ON(xa, xa_store_index(xa, ULONG_MAX, GFP_KERNEL) != in check_xa_shrink()
339 XA_BUG_ON(xa, xa_head(xa) == node); in check_xa_shrink()
341 XA_BUG_ON(xa, xa_load(xa, max + 1) != NULL); in check_xa_shrink()
342 xa_erase_index(xa, ULONG_MAX); in check_xa_shrink()
343 XA_BUG_ON(xa, xa->xa_head != node); in check_xa_shrink()
344 xa_erase_index(xa, 0); in check_xa_shrink()
348 static noinline void check_insert(struct xarray *xa) in check_insert() argument
353 xa_insert_index(xa, i); in check_insert()
354 XA_BUG_ON(xa, xa_load(xa, i - 1) != NULL); in check_insert()
355 XA_BUG_ON(xa, xa_load(xa, i + 1) != NULL); in check_insert()
356 xa_erase_index(xa, i); in check_insert()
360 xa_insert_index(xa, 1UL << i); in check_insert()
361 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 1) != NULL); in check_insert()
362 XA_BUG_ON(xa, xa_load(xa, (1UL << i) + 1) != NULL); in check_insert()
363 xa_erase_index(xa, 1UL << i); in check_insert()
365 xa_insert_index(xa, (1UL << i) - 1); in check_insert()
366 XA_BUG_ON(xa, xa_load(xa, (1UL << i) - 2) != NULL); in check_insert()
367 XA_BUG_ON(xa, xa_load(xa, 1UL << i) != NULL); in check_insert()
368 xa_erase_index(xa, (1UL << i) - 1); in check_insert()
371 xa_insert_index(xa, ~0UL); in check_insert()
372 XA_BUG_ON(xa, xa_load(xa, 0UL) != NULL); in check_insert()
373 XA_BUG_ON(xa, xa_load(xa, ~1UL) != NULL); in check_insert()
374 xa_erase_index(xa, ~0UL); in check_insert()
376 XA_BUG_ON(xa, !xa_empty(xa)); in check_insert()
379 static noinline void check_cmpxchg(struct xarray *xa) in check_cmpxchg() argument
385 XA_BUG_ON(xa, !xa_empty(xa)); in check_cmpxchg()
386 XA_BUG_ON(xa, xa_store_index(xa, 12345678, GFP_KERNEL) != NULL); in check_cmpxchg()
387 XA_BUG_ON(xa, xa_insert(xa, 12345678, xa, GFP_KERNEL) != -EBUSY); in check_cmpxchg()
388 XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, SIX, FIVE, GFP_KERNEL) != LOTS); in check_cmpxchg()
389 XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, LOTS, FIVE, GFP_KERNEL) != LOTS); in check_cmpxchg()
390 XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, FIVE, LOTS, GFP_KERNEL) != FIVE); in check_cmpxchg()
391 XA_BUG_ON(xa, xa_cmpxchg(xa, 5, FIVE, NULL, GFP_KERNEL) != NULL); in check_cmpxchg()
392 XA_BUG_ON(xa, xa_cmpxchg(xa, 5, NULL, FIVE, GFP_KERNEL) != NULL); in check_cmpxchg()
393 xa_erase_index(xa, 12345678); in check_cmpxchg()
394 xa_erase_index(xa, 5); in check_cmpxchg()
395 XA_BUG_ON(xa, !xa_empty(xa)); in check_cmpxchg()
398 static noinline void check_reserve(struct xarray *xa) in check_reserve() argument
405 XA_BUG_ON(xa, !xa_empty(xa)); in check_reserve()
406 XA_BUG_ON(xa, xa_reserve(xa, 12345678, GFP_KERNEL) != 0); in check_reserve()
407 XA_BUG_ON(xa, xa_empty(xa)); in check_reserve()
408 XA_BUG_ON(xa, xa_load(xa, 12345678)); in check_reserve()
409 xa_release(xa, 12345678); in check_reserve()
410 XA_BUG_ON(xa, !xa_empty(xa)); in check_reserve()
413 XA_BUG_ON(xa, xa_reserve(xa, 12345678, GFP_KERNEL) != 0); in check_reserve()
414 XA_BUG_ON(xa, xa_store_index(xa, 12345678, GFP_NOWAIT) != NULL); in check_reserve()
415 xa_release(xa, 12345678); in check_reserve()
416 xa_erase_index(xa, 12345678); in check_reserve()
417 XA_BUG_ON(xa, !xa_empty(xa)); in check_reserve()
420 XA_BUG_ON(xa, xa_reserve(xa, 12345678, GFP_KERNEL) != 0); in check_reserve()
421 XA_BUG_ON(xa, xa_cmpxchg(xa, 12345678, XA_ZERO_ENTRY, in check_reserve()
423 xa_release(xa, 12345678); in check_reserve()
424 xa_erase_index(xa, 12345678); in check_reserve()
425 XA_BUG_ON(xa, !xa_empty(xa)); in check_reserve()
428 XA_BUG_ON(xa, xa_reserve(xa, 12345678, GFP_KERNEL) != 0); in check_reserve()
429 XA_BUG_ON(xa, xa_insert(xa, 12345678, xa_mk_value(12345678), 0) != in check_reserve()
431 XA_BUG_ON(xa, xa_empty(xa)); in check_reserve()
432 XA_BUG_ON(xa, xa_erase(xa, 12345678) != NULL); in check_reserve()
433 XA_BUG_ON(xa, !xa_empty(xa)); in check_reserve()
436 xa_store_index(xa, 5, GFP_KERNEL); in check_reserve()
437 XA_BUG_ON(xa, xa_reserve(xa, 6, GFP_KERNEL) != 0); in check_reserve()
438 xa_store_index(xa, 7, GFP_KERNEL); in check_reserve()
441 xa_for_each(xa, index, entry) { in check_reserve()
442 XA_BUG_ON(xa, index != 5 && index != 7); in check_reserve()
445 XA_BUG_ON(xa, count != 2); in check_reserve()
448 if (xa->xa_flags & XA_FLAGS_ALLOC) { in check_reserve()
451 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_value(8), in check_reserve()
453 XA_BUG_ON(xa, id != 8); in check_reserve()
455 xa_release(xa, 6); in check_reserve()
456 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_value(6), in check_reserve()
458 XA_BUG_ON(xa, id != 6); in check_reserve()
461 xa_destroy(xa); in check_reserve()
464 static noinline void check_xas_erase(struct xarray *xa) in check_xas_erase() argument
466 XA_STATE(xas, xa, 0); in check_xas_erase()
493 XA_BUG_ON(xa, entry != xa_mk_index(j)); in check_xas_erase()
498 XA_BUG_ON(xa, !xa_empty(xa)); in check_xas_erase()
503 static noinline void check_multi_store_1(struct xarray *xa, unsigned long index, in check_multi_store_1() argument
506 XA_STATE(xas, xa, index); in check_multi_store_1()
510 xa_store_order(xa, index, order, xa_mk_index(index), GFP_KERNEL); in check_multi_store_1()
511 XA_BUG_ON(xa, xa_load(xa, min) != xa_mk_index(index)); in check_multi_store_1()
512 XA_BUG_ON(xa, xa_load(xa, max - 1) != xa_mk_index(index)); in check_multi_store_1()
513 XA_BUG_ON(xa, xa_load(xa, max) != NULL); in check_multi_store_1()
514 XA_BUG_ON(xa, xa_load(xa, min - 1) != NULL); in check_multi_store_1()
517 XA_BUG_ON(xa, xas_store(&xas, xa_mk_index(min)) != xa_mk_index(index)); in check_multi_store_1()
519 XA_BUG_ON(xa, xa_load(xa, min) != xa_mk_index(min)); in check_multi_store_1()
520 XA_BUG_ON(xa, xa_load(xa, max - 1) != xa_mk_index(min)); in check_multi_store_1()
521 XA_BUG_ON(xa, xa_load(xa, max) != NULL); in check_multi_store_1()
522 XA_BUG_ON(xa, xa_load(xa, min - 1) != NULL); in check_multi_store_1()
524 xa_erase_index(xa, min); in check_multi_store_1()
525 XA_BUG_ON(xa, !xa_empty(xa)); in check_multi_store_1()
528 static noinline void check_multi_store_2(struct xarray *xa, unsigned long index, in check_multi_store_2() argument
531 XA_STATE(xas, xa, index); in check_multi_store_2()
532 xa_store_order(xa, index, order, xa_mk_value(0), GFP_KERNEL); in check_multi_store_2()
535 XA_BUG_ON(xa, xas_store(&xas, xa_mk_value(1)) != xa_mk_value(0)); in check_multi_store_2()
536 XA_BUG_ON(xa, xas.xa_index != index); in check_multi_store_2()
537 XA_BUG_ON(xa, xas_store(&xas, NULL) != xa_mk_value(1)); in check_multi_store_2()
539 XA_BUG_ON(xa, !xa_empty(xa)); in check_multi_store_2()
542 static noinline void check_multi_store_3(struct xarray *xa, unsigned long index, in check_multi_store_3() argument
545 XA_STATE(xas, xa, 0); in check_multi_store_3()
549 xa_store_order(xa, index, order, xa_mk_index(index), GFP_KERNEL); in check_multi_store_3()
553 XA_BUG_ON(xa, entry != xa_mk_index(index)); in check_multi_store_3()
556 XA_BUG_ON(xa, n != 1); in check_multi_store_3()
559 XA_BUG_ON(xa, entry != xa_mk_index(index)); in check_multi_store_3()
562 XA_BUG_ON(xa, n != 2); in check_multi_store_3()
565 xa_destroy(xa); in check_multi_store_3()
569 static noinline void check_multi_store(struct xarray *xa) in check_multi_store() argument
576 xa_store_order(xa, 0, 1, xa_mk_value(0), GFP_KERNEL); in check_multi_store()
577 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(0)); in check_multi_store()
578 XA_BUG_ON(xa, xa_load(xa, 1) != xa_mk_value(0)); in check_multi_store()
579 XA_BUG_ON(xa, xa_load(xa, 2) != NULL); in check_multi_store()
581 XA_BUG_ON(xa, xa_to_node(xa_head(xa))->count != 2); in check_multi_store()
582 XA_BUG_ON(xa, xa_to_node(xa_head(xa))->nr_values != 2); in check_multi_store()
586 xa_store(xa, 3, xa, GFP_KERNEL); in check_multi_store()
587 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(0)); in check_multi_store()
588 XA_BUG_ON(xa, xa_load(xa, 1) != xa_mk_value(0)); in check_multi_store()
589 XA_BUG_ON(xa, xa_load(xa, 2) != NULL); in check_multi_store()
591 XA_BUG_ON(xa, xa_to_node(xa_head(xa))->count != 3); in check_multi_store()
592 XA_BUG_ON(xa, xa_to_node(xa_head(xa))->nr_values != 2); in check_multi_store()
596 xa_store_order(xa, 0, 2, xa_mk_value(1), GFP_KERNEL); in check_multi_store()
597 XA_BUG_ON(xa, xa_load(xa, 0) != xa_mk_value(1)); in check_multi_store()
598 XA_BUG_ON(xa, xa_load(xa, 1) != xa_mk_value(1)); in check_multi_store()
599 XA_BUG_ON(xa, xa_load(xa, 2) != xa_mk_value(1)); in check_multi_store()
600 XA_BUG_ON(xa, xa_load(xa, 3) != xa_mk_value(1)); in check_multi_store()
601 XA_BUG_ON(xa, xa_load(xa, 4) != NULL); in check_multi_store()
603 XA_BUG_ON(xa, xa_to_node(xa_head(xa))->count != 4); in check_multi_store()
604 XA_BUG_ON(xa, xa_to_node(xa_head(xa))->nr_values != 4); in check_multi_store()
608 xa_store_order(xa, 0, BITS_PER_LONG - 1, NULL, GFP_KERNEL); in check_multi_store()
609 XA_BUG_ON(xa, !xa_empty(xa)); in check_multi_store()
612 xa_store_index(xa, 1, GFP_KERNEL); in check_multi_store()
613 xa_store_index(xa, 2, GFP_KERNEL); in check_multi_store()
614 xa_store_order(xa, 0, 2, NULL, GFP_KERNEL); in check_multi_store()
615 XA_BUG_ON(xa, !xa_empty(xa)); in check_multi_store()
619 xa_store_order(xa, 0, i, xa_mk_index(i), GFP_KERNEL); in check_multi_store()
620 xa_store_order(xa, 0, j, xa_mk_index(j), GFP_KERNEL); in check_multi_store()
623 void *entry = xa_load(xa, (1UL << k) - 1); in check_multi_store()
625 XA_BUG_ON(xa, entry != NULL); in check_multi_store()
627 XA_BUG_ON(xa, entry != xa_mk_index(j)); in check_multi_store()
630 xa_erase(xa, 0); in check_multi_store()
631 XA_BUG_ON(xa, !xa_empty(xa)); in check_multi_store()
636 check_multi_store_1(xa, 200, i); in check_multi_store()
637 check_multi_store_1(xa, 0, i); in check_multi_store()
638 check_multi_store_1(xa, (1UL << i) + 1, i); in check_multi_store()
640 check_multi_store_2(xa, 4095, 9); in check_multi_store()
643 check_multi_store_3(xa, 0, i); in check_multi_store()
644 check_multi_store_3(xa, 1UL << i, i); in check_multi_store()
649 static noinline void check_xa_alloc_1(struct xarray *xa, unsigned int base) in check_xa_alloc_1() argument
654 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_1()
656 xa_alloc_index(xa, base, GFP_KERNEL); in check_xa_alloc_1()
659 xa_erase_index(xa, base); in check_xa_alloc_1()
660 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_1()
663 xa_alloc_index(xa, base, GFP_KERNEL); in check_xa_alloc_1()
667 xa_alloc_index(xa, i, GFP_KERNEL); in check_xa_alloc_1()
669 xa_erase_index(xa, i); in check_xa_alloc_1()
670 xa_alloc_index(xa, base, GFP_KERNEL); in check_xa_alloc_1()
673 xa_destroy(xa); in check_xa_alloc_1()
676 xa_alloc_index(xa, base, GFP_KERNEL); in check_xa_alloc_1()
679 xa_alloc_index(xa, base + 1, GFP_KERNEL); in check_xa_alloc_1()
680 xa_erase_index(xa, base + 1); in check_xa_alloc_1()
683 xa_store_index(xa, base + 1, GFP_KERNEL); in check_xa_alloc_1()
684 xa_alloc_index(xa, base + 2, GFP_KERNEL); in check_xa_alloc_1()
687 xa_erase_index(xa, base); in check_xa_alloc_1()
688 xa_alloc_index(xa, base, GFP_KERNEL); in check_xa_alloc_1()
690 xa_erase_index(xa, base + 1); in check_xa_alloc_1()
691 xa_erase_index(xa, base + 2); in check_xa_alloc_1()
694 xa_alloc_index(xa, base + i, GFP_KERNEL); in check_xa_alloc_1()
697 xa_destroy(xa); in check_xa_alloc_1()
700 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(UINT_MAX - 1), in check_xa_alloc_1()
703 XA_BUG_ON(xa, id != 0xfffffffeU); in check_xa_alloc_1()
704 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(UINT_MAX), in check_xa_alloc_1()
707 XA_BUG_ON(xa, id != 0xffffffffU); in check_xa_alloc_1()
709 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(0), in check_xa_alloc_1()
712 XA_BUG_ON(xa, id != 3); in check_xa_alloc_1()
713 xa_destroy(xa); in check_xa_alloc_1()
715 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5), in check_xa_alloc_1()
717 XA_BUG_ON(xa, xa_store_index(xa, 3, GFP_KERNEL) != 0); in check_xa_alloc_1()
718 XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5), in check_xa_alloc_1()
720 xa_erase_index(xa, 3); in check_xa_alloc_1()
721 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_1()
724 static noinline void check_xa_alloc_2(struct xarray *xa, unsigned int base) in check_xa_alloc_2() argument
731 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_2()
732 XA_BUG_ON(xa, xa_alloc(xa, &id, NULL, xa_limit_32b, GFP_KERNEL) != 0); in check_xa_alloc_2()
733 XA_BUG_ON(xa, id != base); in check_xa_alloc_2()
734 XA_BUG_ON(xa, xa_empty(xa)); in check_xa_alloc_2()
735 XA_BUG_ON(xa, xa_erase(xa, id) != NULL); in check_xa_alloc_2()
736 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_2()
739 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_2()
740 XA_BUG_ON(xa, xa_alloc(xa, &id, NULL, xa_limit_32b, GFP_KERNEL) != 0); in check_xa_alloc_2()
741 XA_BUG_ON(xa, id != base); in check_xa_alloc_2()
742 XA_BUG_ON(xa, xa_empty(xa)); in check_xa_alloc_2()
743 xa_destroy(xa); in check_xa_alloc_2()
744 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_2()
747 XA_BUG_ON(xa, xa_alloc(xa, &id, NULL, xa_limit_32b, in check_xa_alloc_2()
749 XA_BUG_ON(xa, id != i); in check_xa_alloc_2()
752 XA_BUG_ON(xa, xa_store(xa, 3, xa_mk_index(3), GFP_KERNEL) != NULL); in check_xa_alloc_2()
753 XA_BUG_ON(xa, xa_store(xa, 4, xa_mk_index(4), GFP_KERNEL) != NULL); in check_xa_alloc_2()
754 XA_BUG_ON(xa, xa_store(xa, 4, NULL, GFP_KERNEL) != xa_mk_index(4)); in check_xa_alloc_2()
755 XA_BUG_ON(xa, xa_erase(xa, 5) != NULL); in check_xa_alloc_2()
756 XA_BUG_ON(xa, xa_alloc(xa, &id, NULL, xa_limit_32b, GFP_KERNEL) != 0); in check_xa_alloc_2()
757 XA_BUG_ON(xa, id != 5); in check_xa_alloc_2()
759 xa_for_each(xa, index, entry) { in check_xa_alloc_2()
760 xa_erase_index(xa, index); in check_xa_alloc_2()
764 XA_BUG_ON(xa, xa_erase(xa, i) != NULL); in check_xa_alloc_2()
765 XA_BUG_ON(xa, xa_empty(xa)); in check_xa_alloc_2()
767 XA_BUG_ON(xa, xa_erase(xa, 8) != NULL); in check_xa_alloc_2()
768 XA_BUG_ON(xa, xa_empty(xa)); in check_xa_alloc_2()
769 XA_BUG_ON(xa, xa_erase(xa, base + 9) != NULL); in check_xa_alloc_2()
770 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_2()
772 xa_destroy(xa); in check_xa_alloc_2()
775 static noinline void check_xa_alloc_3(struct xarray *xa, unsigned int base) in check_xa_alloc_3() argument
783 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(1), limit, in check_xa_alloc_3()
785 XA_BUG_ON(xa, id != 1); in check_xa_alloc_3()
788 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(0x3ffd), limit, in check_xa_alloc_3()
790 XA_BUG_ON(xa, id != 0x3ffd); in check_xa_alloc_3()
791 xa_erase_index(xa, 0x3ffd); in check_xa_alloc_3()
792 xa_erase_index(xa, 1); in check_xa_alloc_3()
793 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_3()
800 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, entry, limit, in check_xa_alloc_3()
802 XA_BUG_ON(xa, xa_mk_index(id) != entry); in check_xa_alloc_3()
807 xa_erase_index(xa, base); in check_xa_alloc_3()
808 xa_erase_index(xa, base + 1); in check_xa_alloc_3()
810 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(UINT_MAX), in check_xa_alloc_3()
812 XA_BUG_ON(xa, id != UINT_MAX); in check_xa_alloc_3()
813 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(base), in check_xa_alloc_3()
815 XA_BUG_ON(xa, id != base); in check_xa_alloc_3()
816 XA_BUG_ON(xa, xa_alloc_cyclic(xa, &id, xa_mk_index(base + 1), in check_xa_alloc_3()
818 XA_BUG_ON(xa, id != base + 1); in check_xa_alloc_3()
820 xa_for_each(xa, index, entry) in check_xa_alloc_3()
821 xa_erase_index(xa, index); in check_xa_alloc_3()
823 XA_BUG_ON(xa, !xa_empty(xa)); in check_xa_alloc_3()
839 static noinline void __check_store_iter(struct xarray *xa, unsigned long start, in __check_store_iter() argument
842 XA_STATE_ORDER(xas, xa, start, order); in __check_store_iter()
849 XA_BUG_ON(xa, !xa_is_value(entry)); in __check_store_iter()
850 XA_BUG_ON(xa, entry < xa_mk_index(start)); in __check_store_iter()
851 XA_BUG_ON(xa, entry > xa_mk_index(start + (1UL << order) - 1)); in __check_store_iter()
860 XA_BUG_ON(xa, xas_error(&xas)); in __check_store_iter()
861 XA_BUG_ON(xa, count != present); in __check_store_iter()
862 XA_BUG_ON(xa, xa_load(xa, start) != xa_mk_index(start)); in __check_store_iter()
863 XA_BUG_ON(xa, xa_load(xa, start + (1UL << order) - 1) != in __check_store_iter()
865 xa_erase_index(xa, start); in __check_store_iter()
868 static noinline void check_store_iter(struct xarray *xa) in check_store_iter() argument
876 __check_store_iter(xa, 0, i, 0); in check_store_iter()
877 XA_BUG_ON(xa, !xa_empty(xa)); in check_store_iter()
878 __check_store_iter(xa, min, i, 0); in check_store_iter()
879 XA_BUG_ON(xa, !xa_empty(xa)); in check_store_iter()
881 xa_store_index(xa, min, GFP_KERNEL); in check_store_iter()
882 __check_store_iter(xa, min, i, 1); in check_store_iter()
883 XA_BUG_ON(xa, !xa_empty(xa)); in check_store_iter()
884 xa_store_index(xa, max, GFP_KERNEL); in check_store_iter()
885 __check_store_iter(xa, min, i, 1); in check_store_iter()
886 XA_BUG_ON(xa, !xa_empty(xa)); in check_store_iter()
889 xa_store_index(xa, j, GFP_KERNEL); in check_store_iter()
890 __check_store_iter(xa, 0, i, min); in check_store_iter()
891 XA_BUG_ON(xa, !xa_empty(xa)); in check_store_iter()
893 xa_store_index(xa, min + j, GFP_KERNEL); in check_store_iter()
894 __check_store_iter(xa, min, i, min); in check_store_iter()
895 XA_BUG_ON(xa, !xa_empty(xa)); in check_store_iter()
898 xa_store_index(xa, 63, GFP_KERNEL); in check_store_iter()
899 xa_store_index(xa, 65, GFP_KERNEL); in check_store_iter()
900 __check_store_iter(xa, 64, 2, 1); in check_store_iter()
901 xa_erase_index(xa, 63); in check_store_iter()
903 XA_BUG_ON(xa, !xa_empty(xa)); in check_store_iter()
906 static noinline void check_multi_find_1(struct xarray *xa, unsigned order) in check_multi_find_1() argument
913 xa_store_order(xa, multi, order, xa_mk_value(multi), GFP_KERNEL); in check_multi_find_1()
914 XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL) != NULL); in check_multi_find_1()
915 XA_BUG_ON(xa, xa_store_index(xa, next + 1, GFP_KERNEL) != NULL); in check_multi_find_1()
918 XA_BUG_ON(xa, xa_find(xa, &index, ULONG_MAX, XA_PRESENT) != in check_multi_find_1()
920 XA_BUG_ON(xa, index != multi); in check_multi_find_1()
922 XA_BUG_ON(xa, xa_find(xa, &index, ULONG_MAX, XA_PRESENT) != in check_multi_find_1()
924 XA_BUG_ON(xa, (index < multi) || (index >= next)); in check_multi_find_1()
925 XA_BUG_ON(xa, xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT) != in check_multi_find_1()
927 XA_BUG_ON(xa, index != next); in check_multi_find_1()
928 XA_BUG_ON(xa, xa_find_after(xa, &index, next, XA_PRESENT) != NULL); in check_multi_find_1()
929 XA_BUG_ON(xa, index != next); in check_multi_find_1()
931 xa_erase_index(xa, multi); in check_multi_find_1()
932 xa_erase_index(xa, next); in check_multi_find_1()
933 xa_erase_index(xa, next + 1); in check_multi_find_1()
934 XA_BUG_ON(xa, !xa_empty(xa)); in check_multi_find_1()
938 static noinline void check_multi_find_2(struct xarray *xa) in check_multi_find_2() argument
947 XA_STATE(xas, xa, j + index); in check_multi_find_2()
948 xa_store_index(xa, index - 1, GFP_KERNEL); in check_multi_find_2()
949 xa_store_order(xa, index, i, xa_mk_index(index), in check_multi_find_2()
953 xa_erase_index(xa, index); in check_multi_find_2()
956 xa_erase_index(xa, index - 1); in check_multi_find_2()
957 XA_BUG_ON(xa, !xa_empty(xa)); in check_multi_find_2()
962 static noinline void check_find_1(struct xarray *xa) in check_find_1() argument
966 XA_BUG_ON(xa, !xa_empty(xa)); in check_find_1()
973 XA_BUG_ON(xa, xa_store_index(xa, i, GFP_KERNEL) != NULL); in check_find_1()
974 xa_set_mark(xa, i, XA_MARK_0); in check_find_1()
976 XA_BUG_ON(xa, xa_store_index(xa, j, GFP_KERNEL) != in check_find_1()
978 xa_set_mark(xa, j, XA_MARK_0); in check_find_1()
981 void *entry = xa_find(xa, &index, ULONG_MAX, in check_find_1()
984 XA_BUG_ON(xa, index != j); in check_find_1()
986 XA_BUG_ON(xa, index != i); in check_find_1()
988 XA_BUG_ON(xa, entry != NULL); in check_find_1()
991 entry = xa_find(xa, &index, ULONG_MAX, in check_find_1()
994 XA_BUG_ON(xa, index != j); in check_find_1()
996 XA_BUG_ON(xa, index != i); in check_find_1()
998 XA_BUG_ON(xa, entry != NULL); in check_find_1()
1000 xa_erase_index(xa, j); in check_find_1()
1001 XA_BUG_ON(xa, xa_get_mark(xa, j, XA_MARK_0)); in check_find_1()
1002 XA_BUG_ON(xa, !xa_get_mark(xa, i, XA_MARK_0)); in check_find_1()
1004 xa_erase_index(xa, i); in check_find_1()
1005 XA_BUG_ON(xa, xa_get_mark(xa, i, XA_MARK_0)); in check_find_1()
1007 XA_BUG_ON(xa, !xa_empty(xa)); in check_find_1()
1010 static noinline void check_find_2(struct xarray *xa) in check_find_2() argument
1015 xa_for_each(xa, index, entry) { in check_find_2()
1016 XA_BUG_ON(xa, true); in check_find_2()
1020 xa_store_index(xa, index, GFP_KERNEL); in check_find_2()
1022 xa_for_each(xa, index, entry) { in check_find_2()
1023 XA_BUG_ON(xa, xa_mk_index(index) != entry); in check_find_2()
1024 XA_BUG_ON(xa, index != j++); in check_find_2()
1028 xa_destroy(xa); in check_find_2()
1031 static noinline void check_find_3(struct xarray *xa) in check_find_3() argument
1033 XA_STATE(xas, xa, 0); in check_find_3()
1045 XA_BUG_ON(xa, in check_find_3()
1050 xa_store_index(xa, i, GFP_KERNEL); in check_find_3()
1051 xa_set_mark(xa, i, XA_MARK_0); in check_find_3()
1053 xa_destroy(xa); in check_find_3()
1056 static noinline void check_find_4(struct xarray *xa) in check_find_4() argument
1061 xa_store_index(xa, ULONG_MAX, GFP_KERNEL); in check_find_4()
1063 entry = xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT); in check_find_4()
1064 XA_BUG_ON(xa, entry != xa_mk_index(ULONG_MAX)); in check_find_4()
1066 entry = xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT); in check_find_4()
1067 XA_BUG_ON(xa, entry); in check_find_4()
1069 xa_erase_index(xa, ULONG_MAX); in check_find_4()
1072 static noinline void check_find(struct xarray *xa) in check_find() argument
1076 check_find_1(xa); in check_find()
1077 check_find_2(xa); in check_find()
1078 check_find_3(xa); in check_find()
1079 check_find_4(xa); in check_find()
1082 check_multi_find_1(xa, i); in check_find()
1083 check_multi_find_2(xa); in check_find()
1087 static noinline unsigned long xa_find_entry(struct xarray *xa, void *item) in xa_find_entry() argument
1089 XA_STATE(xas, xa, 0); in xa_find_entry()
1109 static noinline void check_find_entry(struct xarray *xa) in check_find_entry() argument
1120 xa_store_order(xa, index, order, in check_find_entry()
1122 XA_BUG_ON(xa, xa_load(xa, index) != in check_find_entry()
1124 XA_BUG_ON(xa, xa_find_entry(xa, in check_find_entry()
1127 XA_BUG_ON(xa, xa_find_entry(xa, xa) != -1); in check_find_entry()
1128 xa_destroy(xa); in check_find_entry()
1133 XA_BUG_ON(xa, xa_find_entry(xa, xa) != -1); in check_find_entry()
1134 xa_store_index(xa, ULONG_MAX, GFP_KERNEL); in check_find_entry()
1135 XA_BUG_ON(xa, xa_find_entry(xa, xa) != -1); in check_find_entry()
1136 XA_BUG_ON(xa, xa_find_entry(xa, xa_mk_index(ULONG_MAX)) != -1); in check_find_entry()
1137 xa_erase_index(xa, ULONG_MAX); in check_find_entry()
1138 XA_BUG_ON(xa, !xa_empty(xa)); in check_find_entry()
1141 static noinline void check_move_tiny(struct xarray *xa) in check_move_tiny() argument
1143 XA_STATE(xas, xa, 0); in check_move_tiny()
1145 XA_BUG_ON(xa, !xa_empty(xa)); in check_move_tiny()
1147 XA_BUG_ON(xa, xas_next(&xas) != NULL); in check_move_tiny()
1148 XA_BUG_ON(xa, xas_next(&xas) != NULL); in check_move_tiny()
1150 xa_store_index(xa, 0, GFP_KERNEL); in check_move_tiny()
1153 XA_BUG_ON(xa, xas_next(&xas) != xa_mk_index(0)); in check_move_tiny()
1154 XA_BUG_ON(xa, xas_next(&xas) != NULL); in check_move_tiny()
1156 XA_BUG_ON(xa, xas_prev(&xas) != xa_mk_index(0)); in check_move_tiny()
1157 XA_BUG_ON(xa, xas_prev(&xas) != NULL); in check_move_tiny()
1159 xa_erase_index(xa, 0); in check_move_tiny()
1160 XA_BUG_ON(xa, !xa_empty(xa)); in check_move_tiny()
1163 static noinline void check_move_small(struct xarray *xa, unsigned long idx) in check_move_small() argument
1165 XA_STATE(xas, xa, 0); in check_move_small()
1168 xa_store_index(xa, 0, GFP_KERNEL); in check_move_small()
1169 xa_store_index(xa, idx, GFP_KERNEL); in check_move_small()
1175 XA_BUG_ON(xa, xas.xa_node == XAS_RESTART); in check_move_small()
1176 XA_BUG_ON(xa, xas.xa_index != i); in check_move_small()
1178 XA_BUG_ON(xa, entry != xa_mk_index(i)); in check_move_small()
1180 XA_BUG_ON(xa, entry != NULL); in check_move_small()
1183 XA_BUG_ON(xa, xas.xa_index != i); in check_move_small()
1189 XA_BUG_ON(xa, xas.xa_node == XAS_RESTART); in check_move_small()
1190 XA_BUG_ON(xa, xas.xa_index != i); in check_move_small()
1192 XA_BUG_ON(xa, entry != xa_mk_index(i)); in check_move_small()
1194 XA_BUG_ON(xa, entry != NULL); in check_move_small()
1198 XA_BUG_ON(xa, xas_next(&xas) != NULL); in check_move_small()
1199 XA_BUG_ON(xa, xas.xa_index != ULONG_MAX); in check_move_small()
1200 XA_BUG_ON(xa, xas_next(&xas) != xa_mk_value(0)); in check_move_small()
1201 XA_BUG_ON(xa, xas.xa_index != 0); in check_move_small()
1202 XA_BUG_ON(xa, xas_prev(&xas) != NULL); in check_move_small()
1203 XA_BUG_ON(xa, xas.xa_index != ULONG_MAX); in check_move_small()
1206 xa_erase_index(xa, 0); in check_move_small()
1207 xa_erase_index(xa, idx); in check_move_small()
1208 XA_BUG_ON(xa, !xa_empty(xa)); in check_move_small()
1211 static noinline void check_move(struct xarray *xa) in check_move() argument
1213 XA_STATE(xas, xa, (1 << 16) - 1); in check_move()
1217 XA_BUG_ON(xa, xa_store_index(xa, i, GFP_KERNEL) != NULL); in check_move()
1223 XA_BUG_ON(xa, entry != xa_mk_index(i)); in check_move()
1224 XA_BUG_ON(xa, i != xas.xa_index); in check_move()
1227 XA_BUG_ON(xa, xas_prev(&xas) != NULL); in check_move()
1228 XA_BUG_ON(xa, xas.xa_index != ULONG_MAX); in check_move()
1232 XA_BUG_ON(xa, entry != xa_mk_index(i)); in check_move()
1233 XA_BUG_ON(xa, i != xas.xa_index); in check_move()
1239 xa_erase_index(xa, i); in check_move()
1248 XA_BUG_ON(xa, entry != xa_mk_index(i)); in check_move()
1250 XA_BUG_ON(xa, entry != NULL); in check_move()
1251 XA_BUG_ON(xa, i != xas.xa_index); in check_move()
1254 XA_BUG_ON(xa, xas_prev(&xas) != NULL); in check_move()
1255 XA_BUG_ON(xa, xas.xa_index != ULONG_MAX); in check_move()
1260 XA_BUG_ON(xa, entry != xa_mk_index(i)); in check_move()
1262 XA_BUG_ON(xa, entry != NULL); in check_move()
1263 XA_BUG_ON(xa, i != xas.xa_index); in check_move()
1268 xa_destroy(xa); in check_move()
1270 check_move_tiny(xa); in check_move()
1273 check_move_small(xa, 1UL << i); in check_move()
1276 check_move_small(xa, (1UL << i) - 1); in check_move()
1279 static noinline void xa_store_many_order(struct xarray *xa, in xa_store_many_order() argument
1282 XA_STATE_ORDER(xas, xa, index, order); in xa_store_many_order()
1287 XA_BUG_ON(xa, xas_find_conflict(&xas)); in xa_store_many_order()
1292 XA_BUG_ON(xa, xas_store(&xas, xa_mk_index(index + i))); in xa_store_many_order()
1299 XA_BUG_ON(xa, xas_error(&xas)); in xa_store_many_order()
1302 static noinline void check_create_range_1(struct xarray *xa, in check_create_range_1() argument
1307 xa_store_many_order(xa, index, order); in check_create_range_1()
1309 xa_erase_index(xa, i); in check_create_range_1()
1310 XA_BUG_ON(xa, !xa_empty(xa)); in check_create_range_1()
1313 static noinline void check_create_range_2(struct xarray *xa, unsigned order) in check_create_range_2() argument
1319 xa_store_many_order(xa, i, order); in check_create_range_2()
1321 xa_erase_index(xa, i); in check_create_range_2()
1322 XA_BUG_ON(xa, !xa_empty(xa)); in check_create_range_2()
1333 static noinline void check_create_range_4(struct xarray *xa, in check_create_range_4() argument
1336 XA_STATE_ORDER(xas, xa, index, order); in check_create_range_4()
1340 xa_store_index(xa, index, GFP_KERNEL); in check_create_range_4()
1349 XA_BUG_ON(xa, old != xa_mk_index(base + i)); in check_create_range_4()
1351 XA_BUG_ON(xa, old != NULL); in check_create_range_4()
1358 XA_BUG_ON(xa, xas_error(&xas)); in check_create_range_4()
1361 xa_erase_index(xa, i); in check_create_range_4()
1362 XA_BUG_ON(xa, !xa_empty(xa)); in check_create_range_4()
1365 static noinline void check_create_range(struct xarray *xa) in check_create_range() argument
1371 check_create_range_1(xa, 0, order); in check_create_range()
1372 check_create_range_1(xa, 1U << order, order); in check_create_range()
1373 check_create_range_1(xa, 2U << order, order); in check_create_range()
1374 check_create_range_1(xa, 3U << order, order); in check_create_range()
1375 check_create_range_1(xa, 1U << 24, order); in check_create_range()
1377 check_create_range_2(xa, order); in check_create_range()
1379 check_create_range_4(xa, 0, order); in check_create_range()
1380 check_create_range_4(xa, 1U << order, order); in check_create_range()
1381 check_create_range_4(xa, 2U << order, order); in check_create_range()
1382 check_create_range_4(xa, 3U << order, order); in check_create_range()
1383 check_create_range_4(xa, 1U << 24, order); in check_create_range()
1385 check_create_range_4(xa, 1, order); in check_create_range()
1386 check_create_range_4(xa, (1U << order) + 1, order); in check_create_range()
1387 check_create_range_4(xa, (2U << order) + 1, order); in check_create_range()
1388 check_create_range_4(xa, (2U << order) - 1, order); in check_create_range()
1389 check_create_range_4(xa, (3U << order) + 1, order); in check_create_range()
1390 check_create_range_4(xa, (3U << order) - 1, order); in check_create_range()
1391 check_create_range_4(xa, (1U << 24) + 1, order); in check_create_range()
1397 static noinline void __check_store_range(struct xarray *xa, unsigned long first, in __check_store_range() argument
1401 xa_store_range(xa, first, last, xa_mk_index(first), GFP_KERNEL); in __check_store_range()
1403 XA_BUG_ON(xa, xa_load(xa, first) != xa_mk_index(first)); in __check_store_range()
1404 XA_BUG_ON(xa, xa_load(xa, last) != xa_mk_index(first)); in __check_store_range()
1405 XA_BUG_ON(xa, xa_load(xa, first - 1) != NULL); in __check_store_range()
1406 XA_BUG_ON(xa, xa_load(xa, last + 1) != NULL); in __check_store_range()
1408 xa_store_range(xa, first, last, NULL, GFP_KERNEL); in __check_store_range()
1411 XA_BUG_ON(xa, !xa_empty(xa)); in __check_store_range()
1414 static noinline void check_store_range(struct xarray *xa) in check_store_range() argument
1420 __check_store_range(xa, i, j); in check_store_range()
1421 __check_store_range(xa, 128 + i, 128 + j); in check_store_range()
1422 __check_store_range(xa, 4095 + i, 4095 + j); in check_store_range()
1423 __check_store_range(xa, 4096 + i, 4096 + j); in check_store_range()
1424 __check_store_range(xa, 123456 + i, 123456 + j); in check_store_range()
1425 __check_store_range(xa, (1 << 24) + i, (1 << 24) + j); in check_store_range()
1430 static void check_align_1(struct xarray *xa, char *name) in check_align_1() argument
1438 XA_BUG_ON(xa, xa_alloc(xa, &id, name + i, xa_limit_32b, in check_align_1()
1440 XA_BUG_ON(xa, id != i); in check_align_1()
1442 xa_for_each(xa, index, entry) in check_align_1()
1443 XA_BUG_ON(xa, xa_is_err(entry)); in check_align_1()
1444 xa_destroy(xa); in check_align_1()
1451 static void check_align_2(struct xarray *xa, char *name) in check_align_2() argument
1455 XA_BUG_ON(xa, !xa_empty(xa)); in check_align_2()
1458 XA_BUG_ON(xa, xa_store(xa, 0, name + i, GFP_KERNEL) != NULL); in check_align_2()
1459 xa_erase(xa, 0); in check_align_2()
1463 XA_BUG_ON(xa, xa_reserve(xa, 0, GFP_KERNEL) != 0); in check_align_2()
1464 XA_BUG_ON(xa, xa_store(xa, 0, name + i, 0) != NULL); in check_align_2()
1465 xa_erase(xa, 0); in check_align_2()
1468 XA_BUG_ON(xa, !xa_empty(xa)); in check_align_2()
1471 static noinline void check_align(struct xarray *xa) in check_align() argument
1475 check_align_1(xa, name); in check_align()
1476 check_align_1(xa, name + 1); in check_align()
1477 check_align_1(xa, name + 2); in check_align()
1478 check_align_1(xa, name + 3); in check_align()
1479 check_align_2(xa, name); in check_align()
1495 static noinline void shadow_remove(struct xarray *xa) in shadow_remove() argument
1499 xa_lock(xa); in shadow_remove()
1503 XA_BUG_ON(xa, node->array != xa); in shadow_remove()
1511 xa_unlock(xa); in shadow_remove()
1514 static noinline void check_workingset(struct xarray *xa, unsigned long index) in check_workingset() argument
1516 XA_STATE(xas, xa, index); in check_workingset()
1527 XA_BUG_ON(xa, list_empty(&shadow_nodes)); in check_workingset()
1532 XA_BUG_ON(xa, !list_empty(&shadow_nodes)); in check_workingset()
1536 XA_BUG_ON(xa, list_empty(&shadow_nodes)); in check_workingset()
1538 shadow_remove(xa); in check_workingset()
1539 XA_BUG_ON(xa, !list_empty(&shadow_nodes)); in check_workingset()
1540 XA_BUG_ON(xa, !xa_empty(xa)); in check_workingset()
1547 static noinline void check_account(struct xarray *xa) in check_account() argument
1553 XA_STATE(xas, xa, 1 << order); in check_account()
1555 xa_store_order(xa, 0, order, xa, GFP_KERNEL); in check_account()
1558 XA_BUG_ON(xa, xas.xa_node->count == 0); in check_account()
1559 XA_BUG_ON(xa, xas.xa_node->count > (1 << order)); in check_account()
1560 XA_BUG_ON(xa, xas.xa_node->nr_values != 0); in check_account()
1563 xa_store_order(xa, 1 << order, order, xa_mk_index(1UL << order), in check_account()
1565 XA_BUG_ON(xa, xas.xa_node->count != xas.xa_node->nr_values * 2); in check_account()
1567 xa_erase(xa, 1 << order); in check_account()
1568 XA_BUG_ON(xa, xas.xa_node->nr_values != 0); in check_account()
1570 xa_erase(xa, 0); in check_account()
1571 XA_BUG_ON(xa, !xa_empty(xa)); in check_account()
1576 static noinline void check_destroy(struct xarray *xa) in check_destroy() argument
1580 XA_BUG_ON(xa, !xa_empty(xa)); in check_destroy()
1583 xa_destroy(xa); in check_destroy()
1584 XA_BUG_ON(xa, !xa_empty(xa)); in check_destroy()
1588 xa_store_index(xa, index, GFP_KERNEL); in check_destroy()
1589 XA_BUG_ON(xa, xa_empty(xa)); in check_destroy()
1590 xa_destroy(xa); in check_destroy()
1591 XA_BUG_ON(xa, !xa_empty(xa)); in check_destroy()
1595 xa_store(xa, ULONG_MAX, xa, GFP_KERNEL); in check_destroy()
1596 XA_BUG_ON(xa, xa_empty(xa)); in check_destroy()
1597 xa_destroy(xa); in check_destroy()
1598 XA_BUG_ON(xa, !xa_empty(xa)); in check_destroy()
1602 xa_store_order(xa, 1 << 11, 11, xa, GFP_KERNEL); in check_destroy()
1603 XA_BUG_ON(xa, xa_empty(xa)); in check_destroy()
1604 xa_destroy(xa); in check_destroy()
1605 XA_BUG_ON(xa, !xa_empty(xa)); in check_destroy()