blk-mq: bitmap tag: use clear_bit_unlock in bt_clear_tag()
[linux-2.6/btrfs-unstable.git] / include / linux / torture.h
blobb2e2b468e511d43949c5cee31b5e23a06ab433e7
1 /*
2 * Common functions for in-kernel torture tests.
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.
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.
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.
18 * Copyright IBM Corporation, 2014
20 * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
23 #ifndef __LINUX_TORTURE_H
24 #define __LINUX_TORTURE_H
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>
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);
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) \
48 do { if (verbose) pr_alert("%s" TORTURE_FLAG " %s\n", torture_type, s); } while (0)
49 #define VERBOSE_TOROUT_ERRSTRING(s) \
50 do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0)
52 /* Definitions for a non-string torture-test module parameter. */
53 #define torture_parm(type, name, init, msg) \
54 static type name = init; \
55 module_param(name, type, 0444); \
56 MODULE_PARM_DESC(name, msg);
58 /* Definitions for online/offline exerciser. */
59 int torture_onoff_init(long ooholdoff, long oointerval);
60 char *torture_onoff_stats(char *page);
61 bool torture_onoff_failures(void);
63 /* Low-rider random number generator. */
64 struct torture_random_state {
65 unsigned long trs_state;
66 long trs_count;
68 #define DEFINE_TORTURE_RANDOM(name) struct torture_random_state name = { 0, 0 }
69 unsigned long torture_random(struct torture_random_state *trsp);
71 /* Task shuffler, which causes CPUs to occasionally go idle. */
72 void torture_shuffle_task_register(struct task_struct *tp);
73 int torture_shuffle_init(long shuffint);
75 /* Test auto-shutdown handling. */
76 void torture_shutdown_absorb(const char *title);
77 int torture_shutdown_init(int ssecs, void (*cleanup)(void));
79 /* Task stuttering, which forces load/no-load transitions. */
80 void stutter_wait(const char *title);
81 int torture_stutter_init(int s);
83 /* Initialization and cleanup. */
84 void torture_init_begin(char *ttype, bool v, int *runnable);
85 void torture_init_end(void);
86 bool torture_cleanup(void);
87 bool torture_must_stop(void);
88 bool torture_must_stop_irq(void);
89 void torture_kthread_stopping(char *title);
90 int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
91 char *f, struct task_struct **tp);
92 void _torture_stop_kthread(char *m, struct task_struct **tp);
94 #define torture_create_kthread(n, arg, tp) \
95 _torture_create_kthread(n, (arg), #n, "Creating " #n " task", \
96 "Failed to create " #n, &(tp))
97 #define torture_stop_kthread(n, tp) \
98 _torture_stop_kthread("Stopping " #n " task", &(tp))
100 #endif /* __LINUX_TORTURE_H */