aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-07-04 16:19:30 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-07-14 20:17:48 -0400
commit00ce1db1a634746040ace24c09a4e3a7949a3145 (patch)
treea9c97eab912d149ebaaab3dc3393d75416b5c6b4 /drivers
parentc2557a303ab6712bb6e09447df828c557c710ac9 (diff)
random: add tracepoints for easier debugging and verification
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/random.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index eacd61479112..e3180852ec85 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -266,6 +266,9 @@
266#include <asm/irq_regs.h> 266#include <asm/irq_regs.h>
267#include <asm/io.h> 267#include <asm/io.h>
268 268
269#define CREATE_TRACE_POINTS
270#include <trace/events/random.h>
271
269/* 272/*
270 * Configuration information 273 * Configuration information
271 */ 274 */
@@ -478,8 +481,8 @@ static __u32 const twist_table[8] = {
478 * it's cheap to do so and helps slightly in the expected case where 481 * it's cheap to do so and helps slightly in the expected case where
479 * the entropy is concentrated in the low-order bits. 482 * the entropy is concentrated in the low-order bits.
480 */ 483 */
481static void __mix_pool_bytes(struct entropy_store *r, const void *in, 484static void _mix_pool_bytes(struct entropy_store *r, const void *in,
482 int nbytes, __u8 out[64]) 485 int nbytes, __u8 out[64])
483{ 486{
484 unsigned long i, j, tap1, tap2, tap3, tap4, tap5; 487 unsigned long i, j, tap1, tap2, tap3, tap4, tap5;
485 int input_rotate; 488 int input_rotate;
@@ -531,13 +534,21 @@ static void __mix_pool_bytes(struct entropy_store *r, const void *in,
531 ((__u32 *)out)[j] = r->pool[(i - j) & wordmask]; 534 ((__u32 *)out)[j] = r->pool[(i - j) & wordmask];
532} 535}
533 536
534static void mix_pool_bytes(struct entropy_store *r, const void *in, 537static void __mix_pool_bytes(struct entropy_store *r, const void *in,
535 int nbytes, __u8 out[64]) 538 int nbytes, __u8 out[64])
536{ 539{
540 trace_mix_pool_bytes_nolock(r->name, nbytes, _RET_IP_);
541 _mix_pool_bytes(r, in, nbytes, out);
542}
543
544static void mix_pool_bytes(struct entropy_store *r, const void *in,
545 int nbytes, __u8 out[64])
546{
537 unsigned long flags; 547 unsigned long flags;
538 548
549 trace_mix_pool_bytes(r->name, nbytes, _RET_IP_);
539 spin_lock_irqsave(&r->lock, flags); 550 spin_lock_irqsave(&r->lock, flags);
540 __mix_pool_bytes(r, in, nbytes, out); 551 _mix_pool_bytes(r, in, nbytes, out);
541 spin_unlock_irqrestore(&r->lock, flags); 552 spin_unlock_irqrestore(&r->lock, flags);
542} 553}
543 554
@@ -585,6 +596,7 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
585retry: 596retry:
586 entropy_count = orig = ACCESS_ONCE(r->entropy_count); 597 entropy_count = orig = ACCESS_ONCE(r->entropy_count);
587 entropy_count += nbits; 598 entropy_count += nbits;
599
588 if (entropy_count < 0) { 600 if (entropy_count < 0) {
589 DEBUG_ENT("negative entropy/overflow\n"); 601 DEBUG_ENT("negative entropy/overflow\n");
590 entropy_count = 0; 602 entropy_count = 0;
@@ -599,6 +611,9 @@ retry:
599 r->initialized = 1; 611 r->initialized = 1;
600 } 612 }
601 613
614 trace_credit_entropy_bits(r->name, nbits, entropy_count,
615 r->entropy_total, _RET_IP_);
616
602 /* should we wake readers? */ 617 /* should we wake readers? */
603 if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) { 618 if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) {
604 wake_up_interruptible(&random_read_wait); 619 wake_up_interruptible(&random_read_wait);
@@ -971,6 +986,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
971 ssize_t ret = 0, i; 986 ssize_t ret = 0, i;
972 __u8 tmp[EXTRACT_SIZE]; 987 __u8 tmp[EXTRACT_SIZE];
973 988
989 trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_);
974 xfer_secondary_pool(r, nbytes); 990 xfer_secondary_pool(r, nbytes);
975 nbytes = account(r, nbytes, min, reserved); 991 nbytes = account(r, nbytes, min, reserved);
976 992
@@ -1005,6 +1021,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
1005 ssize_t ret = 0, i; 1021 ssize_t ret = 0, i;
1006 __u8 tmp[EXTRACT_SIZE]; 1022 __u8 tmp[EXTRACT_SIZE];
1007 1023
1024 trace_extract_entropy_user(r->name, nbytes, r->entropy_count, _RET_IP_);
1008 xfer_secondary_pool(r, nbytes); 1025 xfer_secondary_pool(r, nbytes);
1009 nbytes = account(r, nbytes, 0, 0); 1026 nbytes = account(r, nbytes, 0, 0);
1010 1027
@@ -1062,6 +1079,7 @@ void get_random_bytes_arch(void *buf, int nbytes)
1062{ 1079{
1063 char *p = buf; 1080 char *p = buf;
1064 1081
1082 trace_get_random_bytes(nbytes, _RET_IP_);
1065 while (nbytes) { 1083 while (nbytes) {
1066 unsigned long v; 1084 unsigned long v;
1067 int chunk = min(nbytes, (int)sizeof(unsigned long)); 1085 int chunk = min(nbytes, (int)sizeof(unsigned long));