aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-09-12 14:10:25 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-10-10 14:32:16 -0400
commit5910895f0e868d4f70303922ed00ccdc328b3c30 (patch)
treec51b3a58cad1a18e941f1d0ed1c56747944aa3cc
parent30e37ec516ae5a6957596de7661673c615c82ea4 (diff)
random: fix the tracepoint for get_random_bytes(_arch)
Fix a problem where get_random_bytes_arch() was calling the tracepoint get_random_bytes(). So add a new tracepoint for get_random_bytes_arch(), and make get_random_bytes() and get_random_bytes_arch() call their correct tracepoint. Also, add a new tracepoint for add_device_randomness() Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--drivers/char/random.c4
-rw-r--r--include/trace/events/random.h33
2 files changed, 35 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 867b823e7fea..80b58774e891 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -711,6 +711,7 @@ void add_device_randomness(const void *buf, unsigned int size)
711{ 711{
712 unsigned long time = random_get_entropy() ^ jiffies; 712 unsigned long time = random_get_entropy() ^ jiffies;
713 713
714 trace_add_device_randomness(size, _RET_IP_);
714 mix_pool_bytes(&input_pool, buf, size, NULL); 715 mix_pool_bytes(&input_pool, buf, size, NULL);
715 mix_pool_bytes(&input_pool, &time, sizeof(time), NULL); 716 mix_pool_bytes(&input_pool, &time, sizeof(time), NULL);
716 mix_pool_bytes(&nonblocking_pool, buf, size, NULL); 717 mix_pool_bytes(&nonblocking_pool, buf, size, NULL);
@@ -1127,6 +1128,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
1127 */ 1128 */
1128void get_random_bytes(void *buf, int nbytes) 1129void get_random_bytes(void *buf, int nbytes)
1129{ 1130{
1131 trace_get_random_bytes(nbytes, _RET_IP_);
1130 extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); 1132 extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0);
1131} 1133}
1132EXPORT_SYMBOL(get_random_bytes); 1134EXPORT_SYMBOL(get_random_bytes);
@@ -1145,7 +1147,7 @@ void get_random_bytes_arch(void *buf, int nbytes)
1145{ 1147{
1146 char *p = buf; 1148 char *p = buf;
1147 1149
1148 trace_get_random_bytes(nbytes, _RET_IP_); 1150 trace_get_random_bytes_arch(nbytes, _RET_IP_);
1149 while (nbytes) { 1151 while (nbytes) {
1150 unsigned long v; 1152 unsigned long v;
1151 int chunk = min(nbytes, (int)sizeof(unsigned long)); 1153 int chunk = min(nbytes, (int)sizeof(unsigned long));
diff --git a/include/trace/events/random.h b/include/trace/events/random.h
index 422df19de732..2ffcaec5860a 100644
--- a/include/trace/events/random.h
+++ b/include/trace/events/random.h
@@ -7,6 +7,25 @@
7#include <linux/writeback.h> 7#include <linux/writeback.h>
8#include <linux/tracepoint.h> 8#include <linux/tracepoint.h>
9 9
10TRACE_EVENT(add_device_randomness,
11 TP_PROTO(int bytes, unsigned long IP),
12
13 TP_ARGS(bytes, IP),
14
15 TP_STRUCT__entry(
16 __field( int, bytes )
17 __field(unsigned long, IP )
18 ),
19
20 TP_fast_assign(
21 __entry->bytes = bytes;
22 __entry->IP = IP;
23 ),
24
25 TP_printk("bytes %d caller %pF",
26 __entry->bytes, (void *)__entry->IP)
27);
28
10DECLARE_EVENT_CLASS(random__mix_pool_bytes, 29DECLARE_EVENT_CLASS(random__mix_pool_bytes,
11 TP_PROTO(const char *pool_name, int bytes, unsigned long IP), 30 TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
12 31
@@ -68,7 +87,7 @@ TRACE_EVENT(credit_entropy_bits,
68 (void *)__entry->IP) 87 (void *)__entry->IP)
69); 88);
70 89
71TRACE_EVENT(get_random_bytes, 90DECLARE_EVENT_CLASS(random__get_random_bytes,
72 TP_PROTO(int nbytes, unsigned long IP), 91 TP_PROTO(int nbytes, unsigned long IP),
73 92
74 TP_ARGS(nbytes, IP), 93 TP_ARGS(nbytes, IP),
@@ -86,6 +105,18 @@ TRACE_EVENT(get_random_bytes,
86 TP_printk("nbytes %d caller %pF", __entry->nbytes, (void *)__entry->IP) 105 TP_printk("nbytes %d caller %pF", __entry->nbytes, (void *)__entry->IP)
87); 106);
88 107
108DEFINE_EVENT(random__get_random_bytes, get_random_bytes,
109 TP_PROTO(int nbytes, unsigned long IP),
110
111 TP_ARGS(nbytes, IP)
112);
113
114DEFINE_EVENT(random__get_random_bytes, get_random_bytes_arch,
115 TP_PROTO(int nbytes, unsigned long IP),
116
117 TP_ARGS(nbytes, IP)
118);
119
89DECLARE_EVENT_CLASS(random__extract_entropy, 120DECLARE_EVENT_CLASS(random__extract_entropy,
90 TP_PROTO(const char *pool_name, int nbytes, int entropy_count, 121 TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
91 unsigned long IP), 122 unsigned long IP),