Lines Matching refs:test_dev
109 struct kmod_test_device *test_dev; member
179 static void kmod_test_done_check(struct kmod_test_device *test_dev, in kmod_test_done_check() argument
182 struct test_config *config = &test_dev->config; in kmod_test_done_check()
184 test_dev->done++; in kmod_test_done_check()
185 dev_dbg(test_dev->dev, "Done thread count: %u\n", test_dev->done); in kmod_test_done_check()
187 if (test_dev->done == config->num_threads) { in kmod_test_done_check()
188 dev_info(test_dev->dev, "Done: %u threads have all run now\n", in kmod_test_done_check()
189 test_dev->done); in kmod_test_done_check()
190 dev_info(test_dev->dev, "Last thread to run: %u\n", idx); in kmod_test_done_check()
191 complete(&test_dev->kthreads_done); in kmod_test_done_check()
197 struct kmod_test_device *test_dev = info->test_dev; in test_kmod_put_module() local
198 struct test_config *config = &test_dev->config; in test_kmod_put_module()
220 struct kmod_test_device *test_dev = info->test_dev; in run_request() local
221 struct test_config *config = &test_dev->config; in run_request()
237 dev_dbg(test_dev->dev, "Ran thread %u\n", info->thread_idx); in run_request()
241 mutex_lock(&test_dev->thread_mutex); in run_request()
243 kmod_test_done_check(test_dev, info->thread_idx); in run_request()
244 mutex_unlock(&test_dev->thread_mutex); in run_request()
251 struct kmod_test_device *test_dev = info->test_dev; in tally_work_test() local
252 struct test_config *config = &test_dev->config; in tally_work_test()
263 dev_info(test_dev->dev, in tally_work_test()
271 dev_info(test_dev->dev, "Sync thread %u fs: %s\n", in tally_work_test()
291 static void tally_up_work(struct kmod_test_device *test_dev) in tally_up_work() argument
293 struct test_config *config = &test_dev->config; in tally_up_work()
299 mutex_lock(&test_dev->thread_mutex); in tally_up_work()
301 dev_info(test_dev->dev, "Results:\n"); in tally_up_work()
304 info = &test_dev->info[idx]; in tally_up_work()
316 mutex_unlock(&test_dev->thread_mutex); in tally_up_work()
319 static int try_one_request(struct kmod_test_device *test_dev, unsigned int idx) in try_one_request() argument
321 struct kmod_test_device_info *info = &test_dev->info[idx]; in try_one_request()
324 mutex_lock(&test_dev->thread_mutex); in try_one_request()
327 info->test_dev = test_dev; in try_one_request()
332 test_dev->test_is_oom = true; in try_one_request()
333 dev_err(test_dev->dev, "Setting up thread %u failed\n", idx); in try_one_request()
337 dev_dbg(test_dev->dev, "Kicked off thread %u\n", idx); in try_one_request()
339 mutex_unlock(&test_dev->thread_mutex); in try_one_request()
345 mutex_unlock(&test_dev->thread_mutex); in try_one_request()
350 static void test_dev_kmod_stop_tests(struct kmod_test_device *test_dev) in test_dev_kmod_stop_tests() argument
352 struct test_config *config = &test_dev->config; in test_dev_kmod_stop_tests()
356 dev_info(test_dev->dev, "Ending request_module() tests\n"); in test_dev_kmod_stop_tests()
358 mutex_lock(&test_dev->thread_mutex); in test_dev_kmod_stop_tests()
361 info = &test_dev->info[i]; in test_dev_kmod_stop_tests()
363 dev_info(test_dev->dev, in test_dev_kmod_stop_tests()
379 mutex_unlock(&test_dev->thread_mutex); in test_dev_kmod_stop_tests()
388 static int try_requests(struct kmod_test_device *test_dev) in try_requests() argument
390 struct test_config *config = &test_dev->config; in try_requests()
396 if (test_dev->test_is_oom) { in try_requests()
401 ret = try_one_request(test_dev, idx); in try_requests()
409 test_dev->test_is_oom = false; in try_requests()
410 dev_info(test_dev->dev, in try_requests()
412 wait_for_completion(&test_dev->kthreads_done); in try_requests()
413 tally_up_work(test_dev); in try_requests()
415 test_dev->test_is_oom = true; in try_requests()
416 dev_info(test_dev->dev, in try_requests()
418 test_dev_kmod_stop_tests(test_dev); in try_requests()
425 static int run_test_driver(struct kmod_test_device *test_dev) in run_test_driver() argument
427 struct test_config *config = &test_dev->config; in run_test_driver()
429 dev_info(test_dev->dev, "Test case: %s (%u)\n", in run_test_driver()
432 dev_info(test_dev->dev, "Test driver to load: %s\n", in run_test_driver()
434 dev_info(test_dev->dev, "Number of threads to run: %u\n", in run_test_driver()
436 dev_info(test_dev->dev, "Thread IDs will range from 0 - %u\n", in run_test_driver()
439 return try_requests(test_dev); in run_test_driver()
442 static int run_test_fs_type(struct kmod_test_device *test_dev) in run_test_fs_type() argument
444 struct test_config *config = &test_dev->config; in run_test_fs_type()
446 dev_info(test_dev->dev, "Test case: %s (%u)\n", in run_test_fs_type()
449 dev_info(test_dev->dev, "Test filesystem to load: %s\n", in run_test_fs_type()
451 dev_info(test_dev->dev, "Number of threads to run: %u\n", in run_test_fs_type()
453 dev_info(test_dev->dev, "Thread IDs will range from 0 - %u\n", in run_test_fs_type()
456 return try_requests(test_dev); in run_test_fs_type()
463 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_show() local
464 struct test_config *config = &test_dev->config; in config_show()
467 mutex_lock(&test_dev->config_mutex); in config_show()
498 mutex_unlock(&test_dev->config_mutex); in config_show()
508 static int __trigger_config_run(struct kmod_test_device *test_dev) in __trigger_config_run() argument
510 struct test_config *config = &test_dev->config; in __trigger_config_run()
512 test_dev->done = 0; in __trigger_config_run()
516 return run_test_driver(test_dev); in __trigger_config_run()
518 return run_test_fs_type(test_dev); in __trigger_config_run()
520 dev_warn(test_dev->dev, in __trigger_config_run()
527 static int trigger_config_run(struct kmod_test_device *test_dev) in trigger_config_run() argument
529 struct test_config *config = &test_dev->config; in trigger_config_run()
532 mutex_lock(&test_dev->trigger_mutex); in trigger_config_run()
533 mutex_lock(&test_dev->config_mutex); in trigger_config_run()
535 ret = __trigger_config_run(test_dev); in trigger_config_run()
538 dev_info(test_dev->dev, "General test result: %d\n", in trigger_config_run()
557 mutex_unlock(&test_dev->config_mutex); in trigger_config_run()
558 mutex_unlock(&test_dev->trigger_mutex); in trigger_config_run()
568 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in trigger_config_store() local
571 if (test_dev->test_is_oom) in trigger_config_store()
580 ret = trigger_config_run(test_dev); in trigger_config_store()
638 static void kmod_config_free(struct kmod_test_device *test_dev) in kmod_config_free() argument
642 if (!test_dev) in kmod_config_free()
645 config = &test_dev->config; in kmod_config_free()
647 mutex_lock(&test_dev->config_mutex); in kmod_config_free()
649 mutex_unlock(&test_dev->config_mutex); in kmod_config_free()
656 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_test_driver_store() local
657 struct test_config *config = &test_dev->config; in config_test_driver_store()
660 mutex_lock(&test_dev->config_mutex); in config_test_driver_store()
666 mutex_unlock(&test_dev->config_mutex); in config_test_driver_store()
691 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_test_driver_show() local
692 struct test_config *config = &test_dev->config; in config_test_driver_show()
694 return config_test_show_str(&test_dev->config_mutex, buf, in config_test_driver_show()
703 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_test_fs_store() local
704 struct test_config *config = &test_dev->config; in config_test_fs_store()
707 mutex_lock(&test_dev->config_mutex); in config_test_fs_store()
713 mutex_unlock(&test_dev->config_mutex); in config_test_fs_store()
722 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_test_fs_show() local
723 struct test_config *config = &test_dev->config; in config_test_fs_show()
725 return config_test_show_str(&test_dev->config_mutex, buf, in config_test_fs_show()
730 static int trigger_config_run_type(struct kmod_test_device *test_dev, in trigger_config_run_type() argument
735 struct test_config *config = &test_dev->config; in trigger_config_run_type()
737 mutex_lock(&test_dev->config_mutex); in trigger_config_run_type()
753 mutex_unlock(&test_dev->config_mutex); in trigger_config_run_type()
759 mutex_unlock(&test_dev->config_mutex); in trigger_config_run_type()
762 test_dev->test_is_oom = true; in trigger_config_run_type()
766 test_dev->test_is_oom = false; in trigger_config_run_type()
768 return trigger_config_run(test_dev); in trigger_config_run_type()
771 static void free_test_dev_info(struct kmod_test_device *test_dev) in free_test_dev_info() argument
773 vfree(test_dev->info); in free_test_dev_info()
774 test_dev->info = NULL; in free_test_dev_info()
777 static int kmod_config_sync_info(struct kmod_test_device *test_dev) in kmod_config_sync_info() argument
779 struct test_config *config = &test_dev->config; in kmod_config_sync_info()
781 free_test_dev_info(test_dev); in kmod_config_sync_info()
782 test_dev->info = in kmod_config_sync_info()
785 if (!test_dev->info) in kmod_config_sync_info()
807 static int __kmod_config_init(struct kmod_test_device *test_dev) in __kmod_config_init() argument
809 struct test_config *config = &test_dev->config; in __kmod_config_init()
828 ret = kmod_config_sync_info(test_dev); in __kmod_config_init()
832 test_dev->test_is_oom = false; in __kmod_config_init()
837 test_dev->test_is_oom = true; in __kmod_config_init()
838 WARN_ON(test_dev->test_is_oom); in __kmod_config_init()
849 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in reset_store() local
852 mutex_lock(&test_dev->trigger_mutex); in reset_store()
853 mutex_lock(&test_dev->config_mutex); in reset_store()
855 ret = __kmod_config_init(test_dev); in reset_store()
867 mutex_unlock(&test_dev->config_mutex); in reset_store()
868 mutex_unlock(&test_dev->trigger_mutex); in reset_store()
874 static int test_dev_config_update_uint_sync(struct kmod_test_device *test_dev, in test_dev_config_update_uint_sync() argument
877 int (*test_sync)(struct kmod_test_device *test_dev)) in test_dev_config_update_uint_sync() argument
887 mutex_lock(&test_dev->config_mutex); in test_dev_config_update_uint_sync()
892 ret = test_sync(test_dev); in test_dev_config_update_uint_sync()
896 ret = test_sync(test_dev); in test_dev_config_update_uint_sync()
899 mutex_unlock(&test_dev->config_mutex); in test_dev_config_update_uint_sync()
903 mutex_unlock(&test_dev->config_mutex); in test_dev_config_update_uint_sync()
908 static int test_dev_config_update_uint_range(struct kmod_test_device *test_dev, in test_dev_config_update_uint_range() argument
924 mutex_lock(&test_dev->config_mutex); in test_dev_config_update_uint_range()
926 mutex_unlock(&test_dev->config_mutex); in test_dev_config_update_uint_range()
932 static int test_dev_config_update_int(struct kmod_test_device *test_dev, in test_dev_config_update_int() argument
943 mutex_lock(&test_dev->config_mutex); in test_dev_config_update_int()
945 mutex_unlock(&test_dev->config_mutex); in test_dev_config_update_int()
950 static ssize_t test_dev_config_show_int(struct kmod_test_device *test_dev, in test_dev_config_show_int() argument
956 mutex_lock(&test_dev->config_mutex); in test_dev_config_show_int()
958 mutex_unlock(&test_dev->config_mutex); in test_dev_config_show_int()
963 static ssize_t test_dev_config_show_uint(struct kmod_test_device *test_dev, in test_dev_config_show_uint() argument
969 mutex_lock(&test_dev->config_mutex); in test_dev_config_show_uint()
971 mutex_unlock(&test_dev->config_mutex); in test_dev_config_show_uint()
980 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in test_result_store() local
981 struct test_config *config = &test_dev->config; in test_result_store()
983 return test_dev_config_update_int(test_dev, buf, count, in test_result_store()
991 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_num_threads_store() local
992 struct test_config *config = &test_dev->config; in config_num_threads_store()
994 return test_dev_config_update_uint_sync(test_dev, buf, count, in config_num_threads_store()
1003 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_num_threads_show() local
1004 struct test_config *config = &test_dev->config; in config_num_threads_show()
1006 return test_dev_config_show_int(test_dev, buf, config->num_threads); in config_num_threads_show()
1014 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_test_case_store() local
1015 struct test_config *config = &test_dev->config; in config_test_case_store()
1017 return test_dev_config_update_uint_range(test_dev, buf, count, in config_test_case_store()
1027 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in config_test_case_show() local
1028 struct test_config *config = &test_dev->config; in config_test_case_show()
1030 return test_dev_config_show_uint(test_dev, buf, config->test_case); in config_test_case_show()
1038 struct kmod_test_device *test_dev = dev_to_test_dev(dev); in test_result_show() local
1039 struct test_config *config = &test_dev->config; in test_result_show()
1041 return test_dev_config_show_int(test_dev, buf, config->test_result); in test_result_show()
1061 ATTRIBUTE_GROUPS(test_dev);
1063 static int kmod_config_init(struct kmod_test_device *test_dev) in kmod_config_init() argument
1067 mutex_lock(&test_dev->config_mutex); in kmod_config_init()
1068 ret = __kmod_config_init(test_dev); in kmod_config_init()
1069 mutex_unlock(&test_dev->config_mutex); in kmod_config_init()
1077 struct kmod_test_device *test_dev; in alloc_test_dev_kmod() local
1080 test_dev = vzalloc(sizeof(struct kmod_test_device)); in alloc_test_dev_kmod()
1081 if (!test_dev) in alloc_test_dev_kmod()
1084 mutex_init(&test_dev->config_mutex); in alloc_test_dev_kmod()
1085 mutex_init(&test_dev->trigger_mutex); in alloc_test_dev_kmod()
1086 mutex_init(&test_dev->thread_mutex); in alloc_test_dev_kmod()
1088 init_completion(&test_dev->kthreads_done); in alloc_test_dev_kmod()
1090 ret = kmod_config_init(test_dev); in alloc_test_dev_kmod()
1096 test_dev->dev_idx = idx; in alloc_test_dev_kmod()
1097 misc_dev = &test_dev->misc_dev; in alloc_test_dev_kmod()
1107 return test_dev; in alloc_test_dev_kmod()
1110 free_test_dev_info(test_dev); in alloc_test_dev_kmod()
1111 kmod_config_free(test_dev); in alloc_test_dev_kmod()
1113 vfree(test_dev); in alloc_test_dev_kmod()
1114 test_dev = NULL; in alloc_test_dev_kmod()
1119 static void free_test_dev_kmod(struct kmod_test_device *test_dev) in free_test_dev_kmod() argument
1121 if (test_dev) { in free_test_dev_kmod()
1122 kfree_const(test_dev->misc_dev.name); in free_test_dev_kmod()
1123 test_dev->misc_dev.name = NULL; in free_test_dev_kmod()
1124 free_test_dev_info(test_dev); in free_test_dev_kmod()
1125 kmod_config_free(test_dev); in free_test_dev_kmod()
1126 vfree(test_dev); in free_test_dev_kmod()
1127 test_dev = NULL; in free_test_dev_kmod()
1133 struct kmod_test_device *test_dev = NULL; in register_test_dev_kmod() local
1144 test_dev = alloc_test_dev_kmod(num_test_devs); in register_test_dev_kmod()
1145 if (!test_dev) in register_test_dev_kmod()
1148 ret = misc_register(&test_dev->misc_dev); in register_test_dev_kmod()
1151 free_test_dev_kmod(test_dev); in register_test_dev_kmod()
1152 test_dev = NULL; in register_test_dev_kmod()
1156 test_dev->dev = test_dev->misc_dev.this_device; in register_test_dev_kmod()
1157 list_add_tail(&test_dev->list, ®_test_devs); in register_test_dev_kmod()
1158 dev_info(test_dev->dev, "interface ready\n"); in register_test_dev_kmod()
1165 return test_dev; in register_test_dev_kmod()
1171 struct kmod_test_device *test_dev; in test_kmod_init() local
1174 test_dev = register_test_dev_kmod(); in test_kmod_init()
1175 if (!test_dev) { in test_kmod_init()
1188 ret = trigger_config_run_type(test_dev, in test_kmod_init()
1192 ret = trigger_config_run_type(test_dev, in test_kmod_init()
1203 void unregister_test_dev_kmod(struct kmod_test_device *test_dev) in unregister_test_dev_kmod() argument
1205 mutex_lock(&test_dev->trigger_mutex); in unregister_test_dev_kmod()
1206 mutex_lock(&test_dev->config_mutex); in unregister_test_dev_kmod()
1208 test_dev_kmod_stop_tests(test_dev); in unregister_test_dev_kmod()
1210 dev_info(test_dev->dev, "removing interface\n"); in unregister_test_dev_kmod()
1211 misc_deregister(&test_dev->misc_dev); in unregister_test_dev_kmod()
1213 mutex_unlock(&test_dev->config_mutex); in unregister_test_dev_kmod()
1214 mutex_unlock(&test_dev->trigger_mutex); in unregister_test_dev_kmod()
1216 free_test_dev_kmod(test_dev); in unregister_test_dev_kmod()
1221 struct kmod_test_device *test_dev, *tmp; in test_kmod_exit() local
1224 list_for_each_entry_safe(test_dev, tmp, ®_test_devs, list) { in test_kmod_exit()
1225 list_del(&test_dev->list); in test_kmod_exit()
1226 unregister_test_dev_kmod(test_dev); in test_kmod_exit()