Skip to content

Commit

Permalink
random: remove unused tracepoints
Browse files Browse the repository at this point in the history
These explicit tracepoints aren't really used and show sign of aging.
It's work to keep these up to date, and before I attempted to keep them
up to date, they weren't up to date, which indicates that they're not
really used. These days there are better ways of introspecting anyway.

Cc: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
  • Loading branch information
zx2c4 committed Feb 21, 2022
1 parent 95e6060 commit 14c1746
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 241 deletions.
30 changes: 3 additions & 27 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@
#include <asm/irq_regs.h>
#include <asm/io.h>

#define CREATE_TRACE_POINTS
#include <trace/events/random.h>

enum {
POOL_BITS = BLAKE2S_HASH_SIZE * 8,
POOL_MIN_BITS = POOL_BITS /* No point in settling for less. */
Expand Down Expand Up @@ -315,7 +312,6 @@ static void mix_pool_bytes(const void *in, size_t nbytes)
{
unsigned long flags;

trace_mix_pool_bytes(nbytes, _RET_IP_);
spin_lock_irqsave(&input_pool.lock, flags);
_mix_pool_bytes(in, nbytes);
spin_unlock_irqrestore(&input_pool.lock, flags);
Expand Down Expand Up @@ -389,8 +385,6 @@ static void credit_entropy_bits(size_t nbits)
entropy_count = min_t(unsigned int, POOL_BITS, orig + add);
} while (cmpxchg(&input_pool.entropy_count, orig, entropy_count) != orig);

trace_credit_entropy_bits(nbits, entropy_count, _RET_IP_);

if (crng_init < 2 && entropy_count >= POOL_MIN_BITS)
crng_reseed();
}
Expand Down Expand Up @@ -721,7 +715,6 @@ void add_device_randomness(const void *buf, size_t size)
if (!crng_ready() && size)
crng_slow_load(buf, size);

trace_add_device_randomness(size, _RET_IP_);
spin_lock_irqsave(&input_pool.lock, flags);
_mix_pool_bytes(buf, size);
_mix_pool_bytes(&time, sizeof(time));
Expand Down Expand Up @@ -800,7 +793,6 @@ void add_input_randomness(unsigned int type, unsigned int code,
last_value = value;
add_timer_randomness(&input_timer_state,
(type << 4) ^ code ^ (code >> 4) ^ value);
trace_add_input_randomness(input_pool.entropy_count);
}
EXPORT_SYMBOL_GPL(add_input_randomness);

Expand Down Expand Up @@ -880,7 +872,6 @@ void add_disk_randomness(struct gendisk *disk)
return;
/* first major is 1, so we get >= 0x200 here */
add_timer_randomness(disk->random, 0x100 + disk_devt(disk));
trace_add_disk_randomness(disk_devt(disk), input_pool.entropy_count);
}
EXPORT_SYMBOL_GPL(add_disk_randomness);
#endif
Expand All @@ -905,8 +896,6 @@ static void extract_entropy(void *buf, size_t nbytes)
} block;
size_t i;

trace_extract_entropy(nbytes, input_pool.entropy_count);

for (i = 0; i < ARRAY_SIZE(block.rdseed); ++i) {
if (!arch_get_random_seed_long(&block.rdseed[i]) &&
!arch_get_random_long(&block.rdseed[i]))
Expand Down Expand Up @@ -978,8 +967,6 @@ static void _get_random_bytes(void *buf, size_t nbytes)
u8 tmp[CHACHA_BLOCK_SIZE];
size_t len;

trace_get_random_bytes(nbytes, _RET_IP_);

if (!nbytes)
return;

Expand Down Expand Up @@ -1176,7 +1163,6 @@ size_t __must_check get_random_bytes_arch(void *buf, size_t nbytes)
size_t left = nbytes;
u8 *p = buf;

trace_get_random_bytes_arch(left, _RET_IP_);
while (left) {
unsigned long v;
size_t chunk = min_t(size_t, left, sizeof(unsigned long));
Expand Down Expand Up @@ -1260,16 +1246,6 @@ void rand_initialize_disk(struct gendisk *disk)
}
#endif

static ssize_t urandom_read_nowarn(struct file *file, char __user *buf,
size_t nbytes, loff_t *ppos)
{
ssize_t ret;

ret = get_random_bytes_user(buf, nbytes);
trace_urandom_read(nbytes, input_pool.entropy_count);
return ret;
}

static ssize_t urandom_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{
Expand All @@ -1282,7 +1258,7 @@ static ssize_t urandom_read(struct file *file, char __user *buf, size_t nbytes,
current->comm, nbytes);
}

return urandom_read_nowarn(file, buf, nbytes, ppos);
return get_random_bytes_user(buf, nbytes);
}

static ssize_t random_read(struct file *file, char __user *buf, size_t nbytes,
Expand All @@ -1293,7 +1269,7 @@ static ssize_t random_read(struct file *file, char __user *buf, size_t nbytes,
ret = wait_for_random_bytes();
if (ret != 0)
return ret;
return urandom_read_nowarn(file, buf, nbytes, ppos);
return get_random_bytes_user(buf, nbytes);
}

static __poll_t random_poll(struct file *file, poll_table *wait)
Expand Down Expand Up @@ -1454,7 +1430,7 @@ SYSCALL_DEFINE3(getrandom, char __user *, buf, size_t, count, unsigned int,
if (unlikely(ret))
return ret;
}
return urandom_read_nowarn(NULL, buf, count, NULL);
return get_random_bytes_user(buf, count);
}

/********************************************************************
Expand Down
212 changes: 0 additions & 212 deletions include/trace/events/random.h

This file was deleted.

2 changes: 0 additions & 2 deletions lib/random32.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <linux/bitops.h>
#include <linux/slab.h>
#include <asm/unaligned.h>
#include <trace/events/random.h>

/**
* prandom_u32_state - seeded pseudo-random number generator.
Expand Down Expand Up @@ -387,7 +386,6 @@ u32 prandom_u32(void)
struct siprand_state *state = get_cpu_ptr(&net_rand_state);
u32 res = siprand_u32(state);

trace_prandom_u32(res);
put_cpu_ptr(&net_rand_state);
return res;
}
Expand Down

0 comments on commit 14c1746

Please sign in to comment.