| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Common functions for in-kernel torture tests. |
|---|
| 3 | 4 | * |
|---|
| 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 | 5 | * Copyright IBM Corporation, 2014 |
|---|
| 19 | 6 | * |
|---|
| 20 | | - * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com> |
|---|
| 7 | + * Author: Paul E. McKenney <paulmck@linux.ibm.com> |
|---|
| 21 | 8 | */ |
|---|
| 22 | 9 | |
|---|
| 23 | 10 | #ifndef __LINUX_TORTURE_H |
|---|
| .. | .. |
|---|
| 50 | 37 | do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! %s\n", torture_type, s); } while (0) |
|---|
| 51 | 38 | |
|---|
| 52 | 39 | /* Definitions for online/offline exerciser. */ |
|---|
| 40 | +typedef void torture_ofl_func(void); |
|---|
| 53 | 41 | bool torture_offline(int cpu, long *n_onl_attempts, long *n_onl_successes, |
|---|
| 54 | 42 | unsigned long *sum_offl, int *min_onl, int *max_onl); |
|---|
| 55 | 43 | bool torture_online(int cpu, long *n_onl_attempts, long *n_onl_successes, |
|---|
| 56 | 44 | 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); |
|---|
| 58 | 46 | void torture_onoff_stats(void); |
|---|
| 59 | 47 | bool torture_onoff_failures(void); |
|---|
| 60 | 48 | |
|---|
| .. | .. |
|---|
| 67 | 55 | #define DEFINE_TORTURE_RANDOM_PERCPU(name) \ |
|---|
| 68 | 56 | DEFINE_PER_CPU(struct torture_random_state, name) |
|---|
| 69 | 57 | 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 | +} |
|---|
| 70 | 63 | |
|---|
| 71 | 64 | /* Task shuffler, which causes CPUs to occasionally go idle. */ |
|---|
| 72 | 65 | void torture_shuffle_task_register(struct task_struct *tp); |
|---|
| .. | .. |
|---|
| 77 | 70 | int torture_shutdown_init(int ssecs, void (*cleanup)(void)); |
|---|
| 78 | 71 | |
|---|
| 79 | 72 | /* 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); |
|---|
| 82 | 75 | |
|---|
| 83 | 76 | /* Initialization and cleanup. */ |
|---|
| 84 | 77 | bool torture_init_begin(char *ttype, int v); |
|---|
| .. | .. |
|---|
| 98 | 91 | #define torture_stop_kthread(n, tp) \ |
|---|
| 99 | 92 | _torture_stop_kthread("Stopping " #n " task", &(tp)) |
|---|
| 100 | 93 | |
|---|
| 101 | | -#ifdef CONFIG_PREEMPT |
|---|
| 94 | +#ifdef CONFIG_PREEMPTION |
|---|
| 102 | 95 | #define torture_preempt_schedule() preempt_schedule() |
|---|
| 103 | 96 | #else |
|---|
| 104 | | -#define torture_preempt_schedule() |
|---|
| 97 | +#define torture_preempt_schedule() do { } while (0) |
|---|
| 105 | 98 | #endif |
|---|
| 106 | 99 | |
|---|
| 107 | 100 | #endif /* __LINUX_TORTURE_H */ |
|---|