hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/torture.h
....@@ -1,23 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * Common functions for in-kernel torture tests.
34 *
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
- *
185 * Copyright IBM Corporation, 2014
196 *
20
- * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7
+ * Author: Paul E. McKenney <paulmck@linux.ibm.com>
218 */
229
2310 #ifndef __LINUX_TORTURE_H
....@@ -50,11 +37,12 @@
5037 do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0)
5138
5239 /* Definitions for online/offline exerciser. */
40
+typedef void torture_ofl_func(void);
5341 bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes,
5442 unsigned long *sum_offl, int *min_onl, int *max_onl);
5543 bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes,
5644 unsigned long *sum_onl, int *min_onl, int *max_onl);
57
-int torture_onoff_init(long ooholdoff, long oointerval);
45
+int torture_onoff_init(long ooholdoff, long oointerval, torture_ofl_func *f);
5846 void torture_onoff_stats(void);
5947 bool torture_onoff_failures(void);
6048
....@@ -67,6 +55,11 @@
6755 #define DEFINE_TORTURE_RANDOM_PERCPU(name) \
6856 DEFINE_PER_CPU(struct torture_random_state, name)
6957 unsigned long torture_random(struct torture_random_state *trsp);
58
+static inline void torture_random_init(struct torture_random_state *trsp)
59
+{
60
+ trsp->trs_state = 0;
61
+ trsp->trs_count = 0;
62
+}
7063
7164 /* Task shuffler, which causes CPUs to occasionally go idle. */
7265 void torture_shuffle_task_register(struct task_struct *tp);
....@@ -77,8 +70,8 @@
7770 int torture_shutdown_init(int ssecs, void (*cleanup)(void));
7871
7972 /* Task stuttering, which forces load/no-load transitions. */
80
-void stutter_wait(const char *title);
81
-int torture_stutter_init(int s);
73
+bool stutter_wait(const char *title);
74
+int torture_stutter_init(int s, int sgap);
8275
8376 /* Initialization and cleanup. */
8477 bool torture_init_begin(char *ttype, int v);
....@@ -98,10 +91,10 @@
9891 #define torture_stop_kthread(n, tp) \
9992 _torture_stop_kthread("Stopping " #n " task", &(tp))
10093
101
-#ifdef CONFIG_PREEMPT
94
+#ifdef CONFIG_PREEMPTION
10295 #define torture_preempt_schedule() preempt_schedule()
10396 #else
104
-#define torture_preempt_schedule()
97
+#define torture_preempt_schedule() do { } while (0)
10598 #endif
10699
107100 #endif /* __LINUX_TORTURE_H */