123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #include <linux/kernel.h>
- #include <linux/gfp.h>
- #include <linux/slab.h>
- #include <linux/radix-tree.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "regression.h"
- #define PAGECACHE_TAG_DIRTY 0
- #define PAGECACHE_TAG_WRITEBACK 1
- #define PAGECACHE_TAG_TOWRITE 2
- static RADIX_TREE(mt_tree, GFP_KERNEL);
- unsigned long page_count = 0;
- struct page {
- unsigned long index;
- };
- static struct page *page_alloc(void)
- {
- struct page *p;
- p = malloc(sizeof(struct page));
- p->index = page_count++;
- return p;
- }
- void regression2_test(void)
- {
- int i;
- struct page *p;
- int max_slots = RADIX_TREE_MAP_SIZE;
- unsigned long int start, end;
- struct page *pages[1];
- printf("running regression test 2 (should take milliseconds)\n");
-
- for (i = 0; i <= max_slots - 1; i++) {
- p = page_alloc();
- radix_tree_insert(&mt_tree, i, p);
- }
- radix_tree_tag_set(&mt_tree, max_slots - 1, PAGECACHE_TAG_DIRTY);
-
- start = 0;
- end = max_slots - 2;
- radix_tree_range_tag_if_tagged(&mt_tree, &start, end, 1,
- PAGECACHE_TAG_DIRTY, PAGECACHE_TAG_TOWRITE);
-
- p = page_alloc();
- radix_tree_insert(&mt_tree, max_slots, p);
-
- radix_tree_tag_clear(&mt_tree, max_slots - 1, PAGECACHE_TAG_DIRTY);
-
- for (i = max_slots - 1; i >= 0; i--)
- radix_tree_delete(&mt_tree, i);
-
-
-
- start = 1;
- end = max_slots - 2;
- radix_tree_gang_lookup_tag_slot(&mt_tree, (void ***)pages, start, end,
- PAGECACHE_TAG_TOWRITE);
-
- radix_tree_delete(&mt_tree, max_slots);
- printf("regression test 2, done\n");
- }
|