1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM random
5 #if !defined(_TRACE_RANDOM_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_RANDOM_H
8 #include <linux/writeback.h>
9 #include <linux/tracepoint.h>
11 TRACE_EVENT(add_device_randomness
,
12 TP_PROTO(int bytes
, unsigned long IP
),
18 __field(unsigned long, IP
)
22 __entry
->bytes
= bytes
;
26 TP_printk("bytes %d caller %pS",
27 __entry
->bytes
, (void *)__entry
->IP
)
30 DECLARE_EVENT_CLASS(random__mix_pool_bytes
,
31 TP_PROTO(const char *pool_name
, int bytes
, unsigned long IP
),
33 TP_ARGS(pool_name
, bytes
, IP
),
36 __field( const char *, pool_name
)
38 __field(unsigned long, IP
)
42 __entry
->pool_name
= pool_name
;
43 __entry
->bytes
= bytes
;
47 TP_printk("%s pool: bytes %d caller %pS",
48 __entry
->pool_name
, __entry
->bytes
, (void *)__entry
->IP
)
51 DEFINE_EVENT(random__mix_pool_bytes
, mix_pool_bytes
,
52 TP_PROTO(const char *pool_name
, int bytes
, unsigned long IP
),
54 TP_ARGS(pool_name
, bytes
, IP
)
57 DEFINE_EVENT(random__mix_pool_bytes
, mix_pool_bytes_nolock
,
58 TP_PROTO(const char *pool_name
, int bytes
, unsigned long IP
),
60 TP_ARGS(pool_name
, bytes
, IP
)
63 TRACE_EVENT(credit_entropy_bits
,
64 TP_PROTO(const char *pool_name
, int bits
, int entropy_count
,
67 TP_ARGS(pool_name
, bits
, entropy_count
, IP
),
70 __field( const char *, pool_name
)
72 __field( int, entropy_count
)
73 __field(unsigned long, IP
)
77 __entry
->pool_name
= pool_name
;
79 __entry
->entropy_count
= entropy_count
;
83 TP_printk("%s pool: bits %d entropy_count %d caller %pS",
84 __entry
->pool_name
, __entry
->bits
,
85 __entry
->entropy_count
, (void *)__entry
->IP
)
88 TRACE_EVENT(push_to_pool
,
89 TP_PROTO(const char *pool_name
, int pool_bits
, int input_bits
),
91 TP_ARGS(pool_name
, pool_bits
, input_bits
),
94 __field( const char *, pool_name
)
95 __field( int, pool_bits
)
96 __field( int, input_bits
)
100 __entry
->pool_name
= pool_name
;
101 __entry
->pool_bits
= pool_bits
;
102 __entry
->input_bits
= input_bits
;
105 TP_printk("%s: pool_bits %d input_pool_bits %d",
106 __entry
->pool_name
, __entry
->pool_bits
,
110 TRACE_EVENT(debit_entropy
,
111 TP_PROTO(const char *pool_name
, int debit_bits
),
113 TP_ARGS(pool_name
, debit_bits
),
116 __field( const char *, pool_name
)
117 __field( int, debit_bits
)
121 __entry
->pool_name
= pool_name
;
122 __entry
->debit_bits
= debit_bits
;
125 TP_printk("%s: debit_bits %d", __entry
->pool_name
,
129 TRACE_EVENT(add_input_randomness
,
130 TP_PROTO(int input_bits
),
135 __field( int, input_bits
)
139 __entry
->input_bits
= input_bits
;
142 TP_printk("input_pool_bits %d", __entry
->input_bits
)
145 TRACE_EVENT(add_disk_randomness
,
146 TP_PROTO(dev_t dev
, int input_bits
),
148 TP_ARGS(dev
, input_bits
),
151 __field( dev_t
, dev
)
152 __field( int, input_bits
)
157 __entry
->input_bits
= input_bits
;
160 TP_printk("dev %d,%d input_pool_bits %d", MAJOR(__entry
->dev
),
161 MINOR(__entry
->dev
), __entry
->input_bits
)
164 TRACE_EVENT(xfer_secondary_pool
,
165 TP_PROTO(const char *pool_name
, int xfer_bits
, int request_bits
,
166 int pool_entropy
, int input_entropy
),
168 TP_ARGS(pool_name
, xfer_bits
, request_bits
, pool_entropy
,
172 __field( const char *, pool_name
)
173 __field( int, xfer_bits
)
174 __field( int, request_bits
)
175 __field( int, pool_entropy
)
176 __field( int, input_entropy
)
180 __entry
->pool_name
= pool_name
;
181 __entry
->xfer_bits
= xfer_bits
;
182 __entry
->request_bits
= request_bits
;
183 __entry
->pool_entropy
= pool_entropy
;
184 __entry
->input_entropy
= input_entropy
;
187 TP_printk("pool %s xfer_bits %d request_bits %d pool_entropy %d "
188 "input_entropy %d", __entry
->pool_name
, __entry
->xfer_bits
,
189 __entry
->request_bits
, __entry
->pool_entropy
,
190 __entry
->input_entropy
)
193 DECLARE_EVENT_CLASS(random__get_random_bytes
,
194 TP_PROTO(int nbytes
, unsigned long IP
),
199 __field( int, nbytes
)
200 __field(unsigned long, IP
)
204 __entry
->nbytes
= nbytes
;
208 TP_printk("nbytes %d caller %pS", __entry
->nbytes
, (void *)__entry
->IP
)
211 DEFINE_EVENT(random__get_random_bytes
, get_random_bytes
,
212 TP_PROTO(int nbytes
, unsigned long IP
),
217 DEFINE_EVENT(random__get_random_bytes
, get_random_bytes_arch
,
218 TP_PROTO(int nbytes
, unsigned long IP
),
223 DECLARE_EVENT_CLASS(random__extract_entropy
,
224 TP_PROTO(const char *pool_name
, int nbytes
, int entropy_count
,
227 TP_ARGS(pool_name
, nbytes
, entropy_count
, IP
),
230 __field( const char *, pool_name
)
231 __field( int, nbytes
)
232 __field( int, entropy_count
)
233 __field(unsigned long, IP
)
237 __entry
->pool_name
= pool_name
;
238 __entry
->nbytes
= nbytes
;
239 __entry
->entropy_count
= entropy_count
;
243 TP_printk("%s pool: nbytes %d entropy_count %d caller %pS",
244 __entry
->pool_name
, __entry
->nbytes
, __entry
->entropy_count
,
249 DEFINE_EVENT(random__extract_entropy
, extract_entropy
,
250 TP_PROTO(const char *pool_name
, int nbytes
, int entropy_count
,
253 TP_ARGS(pool_name
, nbytes
, entropy_count
, IP
)
256 DEFINE_EVENT(random__extract_entropy
, extract_entropy_user
,
257 TP_PROTO(const char *pool_name
, int nbytes
, int entropy_count
,
260 TP_ARGS(pool_name
, nbytes
, entropy_count
, IP
)
263 TRACE_EVENT(random_read
,
264 TP_PROTO(int got_bits
, int need_bits
, int pool_left
, int input_left
),
266 TP_ARGS(got_bits
, need_bits
, pool_left
, input_left
),
269 __field( int, got_bits
)
270 __field( int, need_bits
)
271 __field( int, pool_left
)
272 __field( int, input_left
)
276 __entry
->got_bits
= got_bits
;
277 __entry
->need_bits
= need_bits
;
278 __entry
->pool_left
= pool_left
;
279 __entry
->input_left
= input_left
;
282 TP_printk("got_bits %d still_needed_bits %d "
283 "blocking_pool_entropy_left %d input_entropy_left %d",
284 __entry
->got_bits
, __entry
->got_bits
, __entry
->pool_left
,
288 TRACE_EVENT(urandom_read
,
289 TP_PROTO(int got_bits
, int pool_left
, int input_left
),
291 TP_ARGS(got_bits
, pool_left
, input_left
),
294 __field( int, got_bits
)
295 __field( int, pool_left
)
296 __field( int, input_left
)
300 __entry
->got_bits
= got_bits
;
301 __entry
->pool_left
= pool_left
;
302 __entry
->input_left
= input_left
;
305 TP_printk("got_bits %d nonblocking_pool_entropy_left %d "
306 "input_entropy_left %d", __entry
->got_bits
,
307 __entry
->pool_left
, __entry
->input_left
)
310 #endif /* _TRACE_RANDOM_H */
312 /* This part must be outside protection */
313 #include <trace/define_trace.h>