Commit | Line | Data |
---|---|---|
51b1130e PM |
1 | /* |
2 | * Common functions for in-kernel torture tests. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, you can access it online at | |
16 | * http://www.gnu.org/licenses/gpl-2.0.html. | |
17 | * | |
18 | * Copyright IBM Corporation, 2014 | |
19 | * | |
20 | * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com> | |
21 | */ | |
22 | ||
23 | #ifndef __LINUX_TORTURE_H | |
24 | #define __LINUX_TORTURE_H | |
25 | ||
26 | #include <linux/types.h> | |
27 | #include <linux/cache.h> | |
28 | #include <linux/spinlock.h> | |
29 | #include <linux/threads.h> | |
30 | #include <linux/cpumask.h> | |
31 | #include <linux/seqlock.h> | |
32 | #include <linux/lockdep.h> | |
33 | #include <linux/completion.h> | |
34 | #include <linux/debugobjects.h> | |
35 | #include <linux/bug.h> | |
36 | #include <linux/compiler.h> | |
37 | ||
9e250225 PM |
38 | /* Definitions for a non-string torture-test module parameter. */ |
39 | #define torture_param(type, name, init, msg) \ | |
40 | static type name = init; \ | |
41 | module_param(name, type, 0444); \ | |
42 | MODULE_PARM_DESC(name, msg); | |
43 | ||
c2884de3 PM |
44 | #define TORTURE_FLAG "-torture:" |
45 | #define TOROUT_STRING(s) \ | |
46 | pr_alert("%s" TORTURE_FLAG s "\n", torture_type) | |
47 | #define VERBOSE_TOROUT_STRING(s) \ | |
7fafaac5 | 48 | do { if (verbose) pr_alert("%s" TORTURE_FLAG " %s\n", torture_type, s); } while (0) |
c2884de3 | 49 | #define VERBOSE_TOROUT_ERRSTRING(s) \ |
47cf29b9 | 50 | do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0) |
c2884de3 | 51 | |
2e9e8081 | 52 | /* Definitions for online/offline exerciser. */ |
d95f5ba9 PM |
53 | bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes, |
54 | unsigned long *sum_offl, int *min_onl, int *max_onl); | |
55 | bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, | |
56 | unsigned long *sum_onl, int *min_onl, int *max_onl); | |
2e9e8081 | 57 | int torture_onoff_init(long ooholdoff, long oointerval); |
eea203fe | 58 | void torture_onoff_stats(void); |
2e9e8081 PM |
59 | bool torture_onoff_failures(void); |
60 | ||
9e250225 | 61 | /* Low-rider random number generator. */ |
51b1130e PM |
62 | struct torture_random_state { |
63 | unsigned long trs_state; | |
64 | long trs_count; | |
65 | }; | |
51b1130e | 66 | #define DEFINE_TORTURE_RANDOM(name) struct torture_random_state name = { 0, 0 } |
51b1130e PM |
67 | unsigned long torture_random(struct torture_random_state *trsp); |
68 | ||
3808dc9f PM |
69 | /* Task shuffler, which causes CPUs to occasionally go idle. */ |
70 | void torture_shuffle_task_register(struct task_struct *tp); | |
71 | int torture_shuffle_init(long shuffint); | |
3808dc9f | 72 | |
e991dbc0 | 73 | /* Test auto-shutdown handling. */ |
f67a3356 | 74 | void torture_shutdown_absorb(const char *title); |
e991dbc0 | 75 | int torture_shutdown_init(int ssecs, void (*cleanup)(void)); |
f67a3356 | 76 | |
628edaa5 PM |
77 | /* Task stuttering, which forces load/no-load transitions. */ |
78 | void stutter_wait(const char *title); | |
79 | int torture_stutter_init(int s); | |
628edaa5 | 80 | |
b5daa8f3 | 81 | /* Initialization and cleanup. */ |
5228084e | 82 | bool torture_init_begin(char *ttype, bool v, int *runnable); |
b5daa8f3 | 83 | void torture_init_end(void); |
d36a7a0d DB |
84 | bool torture_cleanup_begin(void); |
85 | void torture_cleanup_end(void); | |
36970bb9 PM |
86 | bool torture_must_stop(void); |
87 | bool torture_must_stop_irq(void); | |
7fafaac5 | 88 | void torture_kthread_stopping(char *title); |
47cf29b9 PM |
89 | int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m, |
90 | char *f, struct task_struct **tp); | |
9c029b86 | 91 | void _torture_stop_kthread(char *m, struct task_struct **tp); |
47cf29b9 PM |
92 | |
93 | #define torture_create_kthread(n, arg, tp) \ | |
94 | _torture_create_kthread(n, (arg), #n, "Creating " #n " task", \ | |
95 | "Failed to create " #n, &(tp)) | |
9c029b86 PM |
96 | #define torture_stop_kthread(n, tp) \ |
97 | _torture_stop_kthread("Stopping " #n " task", &(tp)) | |
b5daa8f3 | 98 | |
51b1130e | 99 | #endif /* __LINUX_TORTURE_H */ |