Lines Matching refs:test_parman
77 struct test_parman { struct
94 struct test_parman *test_parman = priv; in test_parman_resize() argument
98 prio_array = krealloc(test_parman->prio_array, in test_parman_resize()
104 old_count = test_parman->prio_array_limit; in test_parman_resize()
108 test_parman->prio_array = prio_array; in test_parman_resize()
109 test_parman->prio_array_limit = new_count; in test_parman_resize()
116 struct test_parman *test_parman = priv; in test_parman_move() local
117 struct test_parman_item **prio_array = test_parman->prio_array; in test_parman_move()
132 static void test_parman_rnd_init(struct test_parman *test_parman) in test_parman_rnd_init() argument
134 prandom_seed_state(&test_parman->rnd, 3141592653589793238ULL); in test_parman_rnd_init()
137 static u32 test_parman_rnd_get(struct test_parman *test_parman) in test_parman_rnd_get() argument
139 return prandom_u32_state(&test_parman->rnd); in test_parman_rnd_get()
142 static unsigned long test_parman_priority_gen(struct test_parman *test_parman) in test_parman_priority_gen() argument
148 priority = test_parman_rnd_get(test_parman); in test_parman_priority_gen()
153 struct test_parman_prio *prio = &test_parman->prios[i]; in test_parman_priority_gen()
163 static void test_parman_prios_init(struct test_parman *test_parman) in test_parman_prios_init() argument
168 struct test_parman_prio *prio = &test_parman->prios[i]; in test_parman_prios_init()
171 prio->priority = test_parman_priority_gen(test_parman); in test_parman_prios_init()
172 parman_prio_init(test_parman->parman, &prio->parman_prio, in test_parman_prios_init()
177 static void test_parman_prios_fini(struct test_parman *test_parman) in test_parman_prios_fini() argument
182 struct test_parman_prio *prio = &test_parman->prios[i]; in test_parman_prios_fini()
188 static void test_parman_items_init(struct test_parman *test_parman) in test_parman_items_init() argument
193 struct test_parman_item *item = &test_parman->items[i]; in test_parman_items_init()
194 unsigned int prio_index = test_parman_rnd_get(test_parman) & in test_parman_items_init()
198 item->prio = &test_parman->prios[prio_index]; in test_parman_items_init()
202 static void test_parman_items_fini(struct test_parman *test_parman) in test_parman_items_fini() argument
207 struct test_parman_item *item = &test_parman->items[i]; in test_parman_items_fini()
211 parman_item_remove(test_parman->parman, in test_parman_items_fini()
217 static struct test_parman *test_parman_create(const struct parman_ops *ops) in test_parman_create()
219 struct test_parman *test_parman; in test_parman_create() local
222 test_parman = kzalloc(sizeof(*test_parman), GFP_KERNEL); in test_parman_create()
223 if (!test_parman) in test_parman_create()
225 err = test_parman_resize(test_parman, TEST_PARMAN_BASE_COUNT); in test_parman_create()
228 test_parman->parman = parman_create(ops, test_parman); in test_parman_create()
229 if (!test_parman->parman) { in test_parman_create()
233 test_parman_rnd_init(test_parman); in test_parman_create()
234 test_parman_prios_init(test_parman); in test_parman_create()
235 test_parman_items_init(test_parman); in test_parman_create()
236 test_parman->run_budget = TEST_PARMAN_RUN_BUDGET; in test_parman_create()
237 return test_parman; in test_parman_create()
240 test_parman_resize(test_parman, 0); in test_parman_create()
242 kfree(test_parman); in test_parman_create()
246 static void test_parman_destroy(struct test_parman *test_parman) in test_parman_destroy() argument
248 test_parman_items_fini(test_parman); in test_parman_destroy()
249 test_parman_prios_fini(test_parman); in test_parman_destroy()
250 parman_destroy(test_parman->parman); in test_parman_destroy()
251 test_parman_resize(test_parman, 0); in test_parman_destroy()
252 kfree(test_parman); in test_parman_destroy()
255 static bool test_parman_run_check_budgets(struct test_parman *test_parman) in test_parman_run_check_budgets() argument
257 if (test_parman->run_budget-- == 0) in test_parman_run_check_budgets()
259 if (test_parman->bulk_budget-- != 0) in test_parman_run_check_budgets()
262 test_parman->bulk_budget = test_parman_rnd_get(test_parman) & in test_parman_run_check_budgets()
264 test_parman->bulk_noop = test_parman_rnd_get(test_parman) & 1; in test_parman_run_check_budgets()
268 static int test_parman_run(struct test_parman *test_parman) in test_parman_run() argument
270 unsigned int i = test_parman_rnd_get(test_parman); in test_parman_run()
273 while (test_parman_run_check_budgets(test_parman)) { in test_parman_run()
275 struct test_parman_item *item = &test_parman->items[item_index]; in test_parman_run()
277 if (test_parman->bulk_noop) in test_parman_run()
281 err = parman_item_add(test_parman->parman, in test_parman_run()
286 test_parman->prio_array[item->parman_item.index] = item; in test_parman_run()
287 test_parman->used_items++; in test_parman_run()
289 test_parman->prio_array[item->parman_item.index] = NULL; in test_parman_run()
290 parman_item_remove(test_parman->parman, in test_parman_run()
293 test_parman->used_items--; in test_parman_run()
300 static int test_parman_check_array(struct test_parman *test_parman, in test_parman_check_array() argument
308 if (test_parman->prio_array_limit < TEST_PARMAN_BASE_COUNT) { in test_parman_check_array()
310 test_parman->prio_array_limit, TEST_PARMAN_BASE_COUNT); in test_parman_check_array()
314 for (i = 0; i < test_parman->prio_array_limit; i++) { in test_parman_check_array()
315 struct test_parman_item *item = test_parman->prio_array[i]; in test_parman_check_array()
343 if (used_items != test_parman->used_items) { in test_parman_check_array()
345 used_items, test_parman->used_items); in test_parman_check_array()
362 struct test_parman *test_parman; in test_parman_lsort() local
365 test_parman = test_parman_create(&test_parman_lsort_ops); in test_parman_lsort()
366 if (IS_ERR(test_parman)) in test_parman_lsort()
367 return PTR_ERR(test_parman); in test_parman_lsort()
369 err = test_parman_run(test_parman); in test_parman_lsort()
373 err = test_parman_check_array(test_parman, false); in test_parman_lsort()
377 test_parman_destroy(test_parman); in test_parman_lsort()