diff options
Diffstat (limited to 'tools/testing/radix-tree/multiorder.c')
-rw-r--r-- | tools/testing/radix-tree/multiorder.c | 99 |
1 files changed, 55 insertions, 44 deletions
diff --git a/tools/testing/radix-tree/multiorder.c b/tools/testing/radix-tree/multiorder.c index c061f4bd6c05..39d9b9568fe2 100644 --- a/tools/testing/radix-tree/multiorder.c +++ b/tools/testing/radix-tree/multiorder.c | |||
@@ -202,7 +202,7 @@ void multiorder_iteration(void) | |||
202 | RADIX_TREE(tree, GFP_KERNEL); | 202 | RADIX_TREE(tree, GFP_KERNEL); |
203 | struct radix_tree_iter iter; | 203 | struct radix_tree_iter iter; |
204 | void **slot; | 204 | void **slot; |
205 | int i, err; | 205 | int i, j, err; |
206 | 206 | ||
207 | printf("Multiorder iteration test\n"); | 207 | printf("Multiorder iteration test\n"); |
208 | 208 | ||
@@ -215,29 +215,21 @@ void multiorder_iteration(void) | |||
215 | assert(!err); | 215 | assert(!err); |
216 | } | 216 | } |
217 | 217 | ||
218 | i = 0; | 218 | for (j = 0; j < 256; j++) { |
219 | /* start from index 1 to verify we find the multi-order entry at 0 */ | 219 | for (i = 0; i < NUM_ENTRIES; i++) |
220 | radix_tree_for_each_slot(slot, &tree, &iter, 1) { | 220 | if (j <= (index[i] | ((1 << order[i]) - 1))) |
221 | int height = order[i] / RADIX_TREE_MAP_SHIFT; | 221 | break; |
222 | int shift = height * RADIX_TREE_MAP_SHIFT; | 222 | |
223 | 223 | radix_tree_for_each_slot(slot, &tree, &iter, j) { | |
224 | assert(iter.index == index[i]); | 224 | int height = order[i] / RADIX_TREE_MAP_SHIFT; |
225 | assert(iter.shift == shift); | 225 | int shift = height * RADIX_TREE_MAP_SHIFT; |
226 | i++; | 226 | int mask = (1 << order[i]) - 1; |
227 | } | 227 | |
228 | 228 | assert(iter.index >= (index[i] &~ mask)); | |
229 | /* | 229 | assert(iter.index <= (index[i] | mask)); |
230 | * Now iterate through the tree starting at an elevated multi-order | 230 | assert(iter.shift == shift); |
231 | * entry, beginning at an index in the middle of the range. | 231 | i++; |
232 | */ | 232 | } |
233 | i = 8; | ||
234 | radix_tree_for_each_slot(slot, &tree, &iter, 70) { | ||
235 | int height = order[i] / RADIX_TREE_MAP_SHIFT; | ||
236 | int shift = height * RADIX_TREE_MAP_SHIFT; | ||
237 | |||
238 | assert(iter.index == index[i]); | ||
239 | assert(iter.shift == shift); | ||
240 | i++; | ||
241 | } | 233 | } |
242 | 234 | ||
243 | item_kill_tree(&tree); | 235 | item_kill_tree(&tree); |
@@ -249,7 +241,7 @@ void multiorder_tagged_iteration(void) | |||
249 | struct radix_tree_iter iter; | 241 | struct radix_tree_iter iter; |
250 | void **slot; | 242 | void **slot; |
251 | unsigned long first = 0; | 243 | unsigned long first = 0; |
252 | int i; | 244 | int i, j; |
253 | 245 | ||
254 | printf("Multiorder tagged iteration test\n"); | 246 | printf("Multiorder tagged iteration test\n"); |
255 | 247 | ||
@@ -268,30 +260,49 @@ void multiorder_tagged_iteration(void) | |||
268 | for (i = 0; i < TAG_ENTRIES; i++) | 260 | for (i = 0; i < TAG_ENTRIES; i++) |
269 | assert(radix_tree_tag_set(&tree, tag_index[i], 1)); | 261 | assert(radix_tree_tag_set(&tree, tag_index[i], 1)); |
270 | 262 | ||
271 | i = 0; | 263 | for (j = 0; j < 256; j++) { |
272 | /* start from index 1 to verify we find the multi-order entry at 0 */ | 264 | int mask, k; |
273 | radix_tree_for_each_tagged(slot, &tree, &iter, 1, 1) { | 265 | |
274 | assert(iter.index == tag_index[i]); | 266 | for (i = 0; i < TAG_ENTRIES; i++) { |
275 | i++; | 267 | for (k = i; index[k] < tag_index[i]; k++) |
276 | } | 268 | ; |
277 | 269 | if (j <= (index[k] | ((1 << order[k]) - 1))) | |
278 | /* | 270 | break; |
279 | * Now iterate through the tree starting at an elevated multi-order | 271 | } |
280 | * entry, beginning at an index in the middle of the range. | 272 | |
281 | */ | 273 | radix_tree_for_each_tagged(slot, &tree, &iter, j, 1) { |
282 | i = 4; | 274 | for (k = i; index[k] < tag_index[i]; k++) |
283 | radix_tree_for_each_slot(slot, &tree, &iter, 70) { | 275 | ; |
284 | assert(iter.index == tag_index[i]); | 276 | mask = (1 << order[k]) - 1; |
285 | i++; | 277 | |
278 | assert(iter.index >= (tag_index[i] &~ mask)); | ||
279 | assert(iter.index <= (tag_index[i] | mask)); | ||
280 | i++; | ||
281 | } | ||
286 | } | 282 | } |
287 | 283 | ||
288 | radix_tree_range_tag_if_tagged(&tree, &first, ~0UL, | 284 | radix_tree_range_tag_if_tagged(&tree, &first, ~0UL, |
289 | MT_NUM_ENTRIES, 1, 2); | 285 | MT_NUM_ENTRIES, 1, 2); |
290 | 286 | ||
291 | i = 0; | 287 | for (j = 0; j < 256; j++) { |
292 | radix_tree_for_each_tagged(slot, &tree, &iter, 1, 2) { | 288 | int mask, k; |
293 | assert(iter.index == tag_index[i]); | 289 | |
294 | i++; | 290 | for (i = 0; i < TAG_ENTRIES; i++) { |
291 | for (k = i; index[k] < tag_index[i]; k++) | ||
292 | ; | ||
293 | if (j <= (index[k] | ((1 << order[k]) - 1))) | ||
294 | break; | ||
295 | } | ||
296 | |||
297 | radix_tree_for_each_tagged(slot, &tree, &iter, j, 2) { | ||
298 | for (k = i; index[k] < tag_index[i]; k++) | ||
299 | ; | ||
300 | mask = (1 << order[k]) - 1; | ||
301 | |||
302 | assert(iter.index >= (tag_index[i] &~ mask)); | ||
303 | assert(iter.index <= (tag_index[i] | mask)); | ||
304 | i++; | ||
305 | } | ||
295 | } | 306 | } |
296 | 307 | ||
297 | first = 1; | 308 | first = 1; |