]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/torture.h
rcutorture: Abstract torture_shutdown_notify()
[mirror_ubuntu-bionic-kernel.git] / include / linux / torture.h
CommitLineData
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
f67a3356
PM
44/* 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;
f67a3356 49
c2884de3
PM
50#define TORTURE_FLAG "-torture:"
51#define TOROUT_STRING(s) \
52 pr_alert("%s" TORTURE_FLAG s "\n", torture_type)
53#define VERBOSE_TOROUT_STRING(s) \
54 do { if (verbose) pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0)
55#define VERBOSE_TOROUT_ERRSTRING(s) \
56 do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
57
2e9e8081
PM
58/* Definitions for a non-string torture-test module parameter. */
59#define torture_parm(type, name, init, msg) \
60 static type name = init; \
61 module_param(name, type, 0444); \
62 MODULE_PARM_DESC(name, msg);
63
64/* Definitions for online/offline exerciser. */
65int torture_onoff_init(long ooholdoff, long oointerval);
2e9e8081
PM
66char *torture_onoff_stats(char *page);
67bool torture_onoff_failures(void);
68
9e250225 69/* Low-rider random number generator. */
51b1130e
PM
70struct torture_random_state {
71 unsigned long trs_state;
72 long trs_count;
73};
51b1130e 74#define DEFINE_TORTURE_RANDOM(name) struct torture_random_state name = { 0, 0 }
51b1130e
PM
75unsigned long torture_random(struct torture_random_state *trsp);
76
3808dc9f
PM
77/* Task shuffler, which causes CPUs to occasionally go idle. */
78void torture_shuffle_task_register(struct task_struct *tp);
79int torture_shuffle_init(long shuffint);
3808dc9f 80
f67a3356
PM
81/* Shutdown task absorption, for when the tasks cannot safely be killed. */
82void torture_shutdown_absorb(const char *title);
83
b5daa8f3 84/* Initialization and cleanup. */
b5daa8f3
PM
85void torture_init_begin(char *ttype, bool v);
86void torture_init_end(void);
cc47ae08 87bool torture_cleanup(void);
b5daa8f3 88
51b1130e 89#endif /* __LINUX_TORTURE_H */