random.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM random
  3. #if !defined(_TRACE_RANDOM_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_RANDOM_H
  5. #include <linux/writeback.h>
  6. #include <linux/tracepoint.h>
  7. TRACE_EVENT(add_device_randomness,
  8. TP_PROTO(int bytes, unsigned long IP),
  9. TP_ARGS(bytes, IP),
  10. TP_STRUCT__entry(
  11. __field( int, bytes )
  12. __field(unsigned long, IP )
  13. ),
  14. TP_fast_assign(
  15. __entry->bytes = bytes;
  16. __entry->IP = IP;
  17. ),
  18. TP_printk("bytes %d caller %pS",
  19. __entry->bytes, (void *)__entry->IP)
  20. );
  21. DECLARE_EVENT_CLASS(random__mix_pool_bytes,
  22. TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
  23. TP_ARGS(pool_name, bytes, IP),
  24. TP_STRUCT__entry(
  25. __field( const char *, pool_name )
  26. __field( int, bytes )
  27. __field(unsigned long, IP )
  28. ),
  29. TP_fast_assign(
  30. __entry->pool_name = pool_name;
  31. __entry->bytes = bytes;
  32. __entry->IP = IP;
  33. ),
  34. TP_printk("%s pool: bytes %d caller %pS",
  35. __entry->pool_name, __entry->bytes, (void *)__entry->IP)
  36. );
  37. DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes,
  38. TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
  39. TP_ARGS(pool_name, bytes, IP)
  40. );
  41. DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes_nolock,
  42. TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
  43. TP_ARGS(pool_name, bytes, IP)
  44. );
  45. TRACE_EVENT(credit_entropy_bits,
  46. TP_PROTO(const char *pool_name, int bits, int entropy_count,
  47. int entropy_total, unsigned long IP),
  48. TP_ARGS(pool_name, bits, entropy_count, entropy_total, IP),
  49. TP_STRUCT__entry(
  50. __field( const char *, pool_name )
  51. __field( int, bits )
  52. __field( int, entropy_count )
  53. __field( int, entropy_total )
  54. __field(unsigned long, IP )
  55. ),
  56. TP_fast_assign(
  57. __entry->pool_name = pool_name;
  58. __entry->bits = bits;
  59. __entry->entropy_count = entropy_count;
  60. __entry->entropy_total = entropy_total;
  61. __entry->IP = IP;
  62. ),
  63. TP_printk("%s pool: bits %d entropy_count %d entropy_total %d "
  64. "caller %pS", __entry->pool_name, __entry->bits,
  65. __entry->entropy_count, __entry->entropy_total,
  66. (void *)__entry->IP)
  67. );
  68. TRACE_EVENT(push_to_pool,
  69. TP_PROTO(const char *pool_name, int pool_bits, int input_bits),
  70. TP_ARGS(pool_name, pool_bits, input_bits),
  71. TP_STRUCT__entry(
  72. __field( const char *, pool_name )
  73. __field( int, pool_bits )
  74. __field( int, input_bits )
  75. ),
  76. TP_fast_assign(
  77. __entry->pool_name = pool_name;
  78. __entry->pool_bits = pool_bits;
  79. __entry->input_bits = input_bits;
  80. ),
  81. TP_printk("%s: pool_bits %d input_pool_bits %d",
  82. __entry->pool_name, __entry->pool_bits,
  83. __entry->input_bits)
  84. );
  85. TRACE_EVENT(debit_entropy,
  86. TP_PROTO(const char *pool_name, int debit_bits),
  87. TP_ARGS(pool_name, debit_bits),
  88. TP_STRUCT__entry(
  89. __field( const char *, pool_name )
  90. __field( int, debit_bits )
  91. ),
  92. TP_fast_assign(
  93. __entry->pool_name = pool_name;
  94. __entry->debit_bits = debit_bits;
  95. ),
  96. TP_printk("%s: debit_bits %d", __entry->pool_name,
  97. __entry->debit_bits)
  98. );
  99. TRACE_EVENT(add_input_randomness,
  100. TP_PROTO(int input_bits),
  101. TP_ARGS(input_bits),
  102. TP_STRUCT__entry(
  103. __field( int, input_bits )
  104. ),
  105. TP_fast_assign(
  106. __entry->input_bits = input_bits;
  107. ),
  108. TP_printk("input_pool_bits %d", __entry->input_bits)
  109. );
  110. TRACE_EVENT(add_disk_randomness,
  111. TP_PROTO(dev_t dev, int input_bits),
  112. TP_ARGS(dev, input_bits),
  113. TP_STRUCT__entry(
  114. __field( dev_t, dev )
  115. __field( int, input_bits )
  116. ),
  117. TP_fast_assign(
  118. __entry->dev = dev;
  119. __entry->input_bits = input_bits;
  120. ),
  121. TP_printk("dev %d,%d input_pool_bits %d", MAJOR(__entry->dev),
  122. MINOR(__entry->dev), __entry->input_bits)
  123. );
  124. TRACE_EVENT(xfer_secondary_pool,
  125. TP_PROTO(const char *pool_name, int xfer_bits, int request_bits,
  126. int pool_entropy, int input_entropy),
  127. TP_ARGS(pool_name, xfer_bits, request_bits, pool_entropy,
  128. input_entropy),
  129. TP_STRUCT__entry(
  130. __field( const char *, pool_name )
  131. __field( int, xfer_bits )
  132. __field( int, request_bits )
  133. __field( int, pool_entropy )
  134. __field( int, input_entropy )
  135. ),
  136. TP_fast_assign(
  137. __entry->pool_name = pool_name;
  138. __entry->xfer_bits = xfer_bits;
  139. __entry->request_bits = request_bits;
  140. __entry->pool_entropy = pool_entropy;
  141. __entry->input_entropy = input_entropy;
  142. ),
  143. TP_printk("pool %s xfer_bits %d request_bits %d pool_entropy %d "
  144. "input_entropy %d", __entry->pool_name, __entry->xfer_bits,
  145. __entry->request_bits, __entry->pool_entropy,
  146. __entry->input_entropy)
  147. );
  148. DECLARE_EVENT_CLASS(random__get_random_bytes,
  149. TP_PROTO(int nbytes, unsigned long IP),
  150. TP_ARGS(nbytes, IP),
  151. TP_STRUCT__entry(
  152. __field( int, nbytes )
  153. __field(unsigned long, IP )
  154. ),
  155. TP_fast_assign(
  156. __entry->nbytes = nbytes;
  157. __entry->IP = IP;
  158. ),
  159. TP_printk("nbytes %d caller %pS", __entry->nbytes, (void *)__entry->IP)
  160. );
  161. DEFINE_EVENT(random__get_random_bytes, get_random_bytes,
  162. TP_PROTO(int nbytes, unsigned long IP),
  163. TP_ARGS(nbytes, IP)
  164. );
  165. DEFINE_EVENT(random__get_random_bytes, get_random_bytes_arch,
  166. TP_PROTO(int nbytes, unsigned long IP),
  167. TP_ARGS(nbytes, IP)
  168. );
  169. DECLARE_EVENT_CLASS(random__extract_entropy,
  170. TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
  171. unsigned long IP),
  172. TP_ARGS(pool_name, nbytes, entropy_count, IP),
  173. TP_STRUCT__entry(
  174. __field( const char *, pool_name )
  175. __field( int, nbytes )
  176. __field( int, entropy_count )
  177. __field(unsigned long, IP )
  178. ),
  179. TP_fast_assign(
  180. __entry->pool_name = pool_name;
  181. __entry->nbytes = nbytes;
  182. __entry->entropy_count = entropy_count;
  183. __entry->IP = IP;
  184. ),
  185. TP_printk("%s pool: nbytes %d entropy_count %d caller %pS",
  186. __entry->pool_name, __entry->nbytes, __entry->entropy_count,
  187. (void *)__entry->IP)
  188. );
  189. DEFINE_EVENT(random__extract_entropy, extract_entropy,
  190. TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
  191. unsigned long IP),
  192. TP_ARGS(pool_name, nbytes, entropy_count, IP)
  193. );
  194. DEFINE_EVENT(random__extract_entropy, extract_entropy_user,
  195. TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
  196. unsigned long IP),
  197. TP_ARGS(pool_name, nbytes, entropy_count, IP)
  198. );
  199. TRACE_EVENT(random_read,
  200. TP_PROTO(int got_bits, int need_bits, int pool_left, int input_left),
  201. TP_ARGS(got_bits, need_bits, pool_left, input_left),
  202. TP_STRUCT__entry(
  203. __field( int, got_bits )
  204. __field( int, need_bits )
  205. __field( int, pool_left )
  206. __field( int, input_left )
  207. ),
  208. TP_fast_assign(
  209. __entry->got_bits = got_bits;
  210. __entry->need_bits = need_bits;
  211. __entry->pool_left = pool_left;
  212. __entry->input_left = input_left;
  213. ),
  214. TP_printk("got_bits %d still_needed_bits %d "
  215. "blocking_pool_entropy_left %d input_entropy_left %d",
  216. __entry->got_bits, __entry->got_bits, __entry->pool_left,
  217. __entry->input_left)
  218. );
  219. TRACE_EVENT(urandom_read,
  220. TP_PROTO(int got_bits, int pool_left, int input_left),
  221. TP_ARGS(got_bits, pool_left, input_left),
  222. TP_STRUCT__entry(
  223. __field( int, got_bits )
  224. __field( int, pool_left )
  225. __field( int, input_left )
  226. ),
  227. TP_fast_assign(
  228. __entry->got_bits = got_bits;
  229. __entry->pool_left = pool_left;
  230. __entry->input_left = input_left;
  231. ),
  232. TP_printk("got_bits %d nonblocking_pool_entropy_left %d "
  233. "input_entropy_left %d", __entry->got_bits,
  234. __entry->pool_left, __entry->input_left)
  235. );
  236. #endif /* _TRACE_RANDOM_H */
  237. /* This part must be outside protection */
  238. #include <trace/define_trace.h>