torture.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. RCU Torture Test Operation
  2. CONFIG_RCU_TORTURE_TEST
  3. The CONFIG_RCU_TORTURE_TEST config option is available for all RCU
  4. implementations. It creates an rcutorture kernel module that can
  5. be loaded to run a torture test. The test periodically outputs
  6. status messages via printk(), which can be examined via the dmesg
  7. command (perhaps grepping for "rcutorture"). The test is started
  8. when the module is loaded, and stops when the module is unloaded.
  9. However, actually setting this config option to "y" results in the system
  10. running the test immediately upon boot, and ending only when the system
  11. is taken down. Normally, one will instead want to build the system
  12. with CONFIG_RCU_TORTURE_TEST=m and to use modprobe and rmmod to control
  13. the test, perhaps using a script similar to the one shown at the end of
  14. this document. Note that you will need CONFIG_MODULE_UNLOAD in order
  15. to be able to end the test.
  16. MODULE PARAMETERS
  17. This module has the following parameters:
  18. nreaders This is the number of RCU reading threads supported.
  19. The default is twice the number of CPUs. Why twice?
  20. To properly exercise RCU implementations with preemptible
  21. read-side critical sections.
  22. stat_interval The number of seconds between output of torture
  23. statistics (via printk()). Regardless of the interval,
  24. statistics are printed when the module is unloaded.
  25. Setting the interval to zero causes the statistics to
  26. be printed -only- when the module is unloaded, and this
  27. is the default.
  28. verbose Enable debug printk()s. Default is disabled.
  29. OUTPUT
  30. The statistics output is as follows:
  31. rcutorture: --- Start of test: nreaders=16 stat_interval=0 verbose=0
  32. rcutorture: rtc: 0000000000000000 ver: 1916 tfle: 0 rta: 1916 rtaf: 0 rtf: 1915
  33. rcutorture: Reader Pipe: 1466408 9747 0 0 0 0 0 0 0 0 0
  34. rcutorture: Reader Batch: 1464477 11678 0 0 0 0 0 0 0 0
  35. rcutorture: Free-Block Circulation: 1915 1915 1915 1915 1915 1915 1915 1915 1915 1915 0
  36. rcutorture: --- End of test
  37. The command "dmesg | grep rcutorture:" will extract this information on
  38. most systems. On more esoteric configurations, it may be necessary to
  39. use other commands to access the output of the printk()s used by
  40. the RCU torture test. The printk()s use KERN_ALERT, so they should
  41. be evident. ;-)
  42. The entries are as follows:
  43. o "ggp": The number of counter flips (or batches) since boot.
  44. o "rtc": The hexadecimal address of the structure currently visible
  45. to readers.
  46. o "ver": The number of times since boot that the rcutw writer task
  47. has changed the structure visible to readers.
  48. o "tfle": If non-zero, indicates that the "torture freelist"
  49. containing structure to be placed into the "rtc" area is empty.
  50. This condition is important, since it can fool you into thinking
  51. that RCU is working when it is not. :-/
  52. o "rta": Number of structures allocated from the torture freelist.
  53. o "rtaf": Number of allocations from the torture freelist that have
  54. failed due to the list being empty.
  55. o "rtf": Number of frees into the torture freelist.
  56. o "Reader Pipe": Histogram of "ages" of structures seen by readers.
  57. If any entries past the first two are non-zero, RCU is broken.
  58. And rcutorture prints the error flag string "!!!" to make sure
  59. you notice. The age of a newly allocated structure is zero,
  60. it becomes one when removed from reader visibility, and is
  61. incremented once per grace period subsequently -- and is freed
  62. after passing through (RCU_TORTURE_PIPE_LEN-2) grace periods.
  63. The output displayed above was taken from a correctly working
  64. RCU. If you want to see what it looks like when broken, break
  65. it yourself. ;-)
  66. o "Reader Batch": Another histogram of "ages" of structures seen
  67. by readers, but in terms of counter flips (or batches) rather
  68. than in terms of grace periods. The legal number of non-zero
  69. entries is again two. The reason for this separate view is
  70. that it is easier to get the third entry to show up in the
  71. "Reader Batch" list than in the "Reader Pipe" list.
  72. o "Free-Block Circulation": Shows the number of torture structures
  73. that have reached a given point in the pipeline. The first element
  74. should closely correspond to the number of structures allocated,
  75. the second to the number that have been removed from reader view,
  76. and all but the last remaining to the corresponding number of
  77. passes through a grace period. The last entry should be zero,
  78. as it is only incremented if a torture structure's counter
  79. somehow gets incremented farther than it should.
  80. USAGE
  81. The following script may be used to torture RCU:
  82. #!/bin/sh
  83. modprobe rcutorture
  84. sleep 100
  85. rmmod rcutorture
  86. dmesg | grep rcutorture:
  87. The output can be manually inspected for the error flag of "!!!".
  88. One could of course create a more elaborate script that automatically
  89. checked for such errors.