random.h 7.2 KB

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