torture.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef __LINUX_TORTURE_H
  23. #define __LINUX_TORTURE_H
  24. #include <linux/types.h>
  25. #include <linux/cache.h>
  26. #include <linux/spinlock.h>
  27. #include <linux/threads.h>
  28. #include <linux/cpumask.h>
  29. #include <linux/seqlock.h>
  30. #include <linux/lockdep.h>
  31. #include <linux/completion.h>
  32. #include <linux/debugobjects.h>
  33. #include <linux/bug.h>
  34. #include <linux/compiler.h>
  35. /* Definitions for a non-string torture-test module parameter. */
  36. #define torture_param(type, name, init, msg) \
  37. static type name = init; \
  38. module_param(name, type, 0444); \
  39. MODULE_PARM_DESC(name, msg);
  40. #define TORTURE_FLAG "-torture:"
  41. #define TOROUT_STRING(s) \
  42. pr_alert("%s" TORTURE_FLAG s "\n", torture_type)
  43. #define VERBOSE_TOROUT_STRING(s) \
  44. do { if (verbose) pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0)
  45. #define VERBOSE_TOROUT_ERRSTRING(s) \
  46. do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
  47. /* Definitions for a non-string torture-test module parameter. */
  48. #define torture_parm(type, name, init, msg) \
  49. static type name = init; \
  50. module_param(name, type, 0444); \
  51. MODULE_PARM_DESC(name, msg);
  52. /* Definitions for online/offline exerciser. */
  53. int torture_onoff_init(long ooholdoff, long oointerval);
  54. char *torture_onoff_stats(char *page);
  55. bool torture_onoff_failures(void);
  56. /* Low-rider random number generator. */
  57. struct torture_random_state {
  58. unsigned long trs_state;
  59. long trs_count;
  60. };
  61. #define DEFINE_TORTURE_RANDOM(name) struct torture_random_state name = { 0, 0 }
  62. unsigned long torture_random(struct torture_random_state *trsp);
  63. /* Task shuffler, which causes CPUs to occasionally go idle. */
  64. void torture_shuffle_task_register(struct task_struct *tp);
  65. int torture_shuffle_init(long shuffint);
  66. /* Shutdown task absorption, for when the tasks cannot safely be killed. */
  67. void torture_shutdown_absorb(const char *title);
  68. /* Task stuttering, which forces load/no-load transitions. */
  69. void stutter_wait(const char *title);
  70. int torture_stutter_init(int s);
  71. void torture_stutter_cleanup(void);
  72. /* Initialization and cleanup. */
  73. void torture_init_begin(char *ttype, bool v, int *runnable);
  74. void torture_init_end(void);
  75. bool torture_cleanup(void);
  76. bool torture_must_stop(void);
  77. bool torture_must_stop_irq(void);
  78. #endif /* __LINUX_TORTURE_H */