blob: 428d2712be04eb5c394babc486f09f40c2090207 [file] [log] [blame]
Paul E. McKenney51b11302014-01-27 11:49:39 -08001/*
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
Paul E. McKenney9e250222014-01-27 16:27:00 -080038/* 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
Paul E. McKenneyf67a3352014-01-29 07:40:27 -080044/* Mediate rmmod and system shutdown. Concurrent rmmod & shutdown illegal! */
45#define FULLSTOP_DONTSTOP 0 /* Normal operation. */
46#define FULLSTOP_SHUTDOWN 1 /* System shutdown with rcutorture running. */
47#define FULLSTOP_RMMOD 2 /* Normal rmmod of rcutorture. */
48extern int fullstop;
49/* Protect fullstop transitions and spawning of kthreads. */
50extern struct mutex fullstop_mutex;
51
Paul E. McKenneyc2884de2014-01-29 07:30:50 -080052#define TORTURE_FLAG "-torture:"
53#define TOROUT_STRING(s) \
54 pr_alert("%s" TORTURE_FLAG s "\n", torture_type)
55#define VERBOSE_TOROUT_STRING(s) \
56 do { if (verbose) pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0)
57#define VERBOSE_TOROUT_ERRSTRING(s) \
58 do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
59
Paul E. McKenney2e9e8082014-01-28 15:58:22 -080060/* Definitions for a non-string torture-test module parameter. */
61#define torture_parm(type, name, init, msg) \
62 static type name = init; \
63 module_param(name, type, 0444); \
64 MODULE_PARM_DESC(name, msg);
65
66/* Definitions for online/offline exerciser. */
67int torture_onoff_init(long ooholdoff, long oointerval);
68void torture_onoff_cleanup(void);
69char *torture_onoff_stats(char *page);
70bool torture_onoff_failures(void);
71
Paul E. McKenney9e250222014-01-27 16:27:00 -080072/* Low-rider random number generator. */
Paul E. McKenney51b11302014-01-27 11:49:39 -080073struct torture_random_state {
74 unsigned long trs_state;
75 long trs_count;
76};
Paul E. McKenney51b11302014-01-27 11:49:39 -080077#define DEFINE_TORTURE_RANDOM(name) struct torture_random_state name = { 0, 0 }
Paul E. McKenney51b11302014-01-27 11:49:39 -080078unsigned long torture_random(struct torture_random_state *trsp);
79
Paul E. McKenney3808dc92014-01-28 15:29:21 -080080/* Task shuffler, which causes CPUs to occasionally go idle. */
81void torture_shuffle_task_register(struct task_struct *tp);
82int torture_shuffle_init(long shuffint);
83void torture_shuffle_cleanup(void);
84
Paul E. McKenneyf67a3352014-01-29 07:40:27 -080085/* Shutdown task absorption, for when the tasks cannot safely be killed. */
86void torture_shutdown_absorb(const char *title);
87
Paul E. McKenneyb5daa8f2014-01-30 13:38:09 -080088/* Initialization and cleanup. */
89
90void torture_init_begin(char *ttype, bool v);
91void torture_init_end(void);
92
Paul E. McKenney51b11302014-01-27 11:49:39 -080093#endif /* __LINUX_TORTURE_H */