Prefix all printk/pr_<level> messages with "random: " to make the
logging a bit more consistent.

Miscellanea:

o Convert a printks to pr_notice
o Whitespace to align to open parentheses
o Remove embedded "random: " from pr_* as pr_fmt adds it

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Link: https://lore.kernel.org/r/20190607182517.28266-3-tiny.windzz@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Yangtao Li 2019-06-07 14:25:15 -04:00 коммит произвёл Theodore Ts'o
Родитель 12faac30d1
Коммит 12cd53aff5
1 изменённых файлов: 11 добавлений и 12 удалений

Просмотреть файл

@ -307,6 +307,8 @@
* Eastlake, Steve Crocker, and Jeff Schiller. * Eastlake, Steve Crocker, and Jeff Schiller.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/utsname.h> #include <linux/utsname.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
@ -737,7 +739,7 @@ retry:
} }
if (WARN_ON(entropy_count < 0)) { if (WARN_ON(entropy_count < 0)) {
pr_warn("random: negative entropy/overflow: pool %s count %d\n", pr_warn("negative entropy/overflow: pool %s count %d\n",
r->name, entropy_count); r->name, entropy_count);
entropy_count = 0; entropy_count = 0;
} else if (entropy_count > pool_size) } else if (entropy_count > pool_size)
@ -833,7 +835,7 @@ static void crng_initialize(struct crng_state *crng)
invalidate_batched_entropy(); invalidate_batched_entropy();
numa_crng_init(); numa_crng_init();
crng_init = 2; crng_init = 2;
pr_notice("random: crng done (trusting CPU's manufacturer)\n"); pr_notice("crng done (trusting CPU's manufacturer)\n");
} }
crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
} }
@ -895,7 +897,7 @@ static int crng_fast_load(const char *cp, size_t len)
if (crng_init_cnt >= CRNG_INIT_CNT_THRESH) { if (crng_init_cnt >= CRNG_INIT_CNT_THRESH) {
invalidate_batched_entropy(); invalidate_batched_entropy();
crng_init = 1; crng_init = 1;
pr_notice("random: fast init done\n"); pr_notice("fast init done\n");
} }
return 1; return 1;
} }
@ -981,16 +983,14 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
process_random_ready_list(); process_random_ready_list();
wake_up_interruptible(&crng_init_wait); wake_up_interruptible(&crng_init_wait);
kill_fasync(&fasync, SIGIO, POLL_IN); kill_fasync(&fasync, SIGIO, POLL_IN);
pr_notice("random: crng init done\n"); pr_notice("crng init done\n");
if (unseeded_warning.missed) { if (unseeded_warning.missed) {
pr_notice("random: %d get_random_xx warning(s) missed " pr_notice("%d get_random_xx warning(s) missed due to ratelimiting\n",
"due to ratelimiting\n",
unseeded_warning.missed); unseeded_warning.missed);
unseeded_warning.missed = 0; unseeded_warning.missed = 0;
} }
if (urandom_warning.missed) { if (urandom_warning.missed) {
pr_notice("random: %d urandom warning(s) missed " pr_notice("%d urandom warning(s) missed due to ratelimiting\n",
"due to ratelimiting\n",
urandom_warning.missed); urandom_warning.missed);
urandom_warning.missed = 0; urandom_warning.missed = 0;
} }
@ -1364,7 +1364,7 @@ retry:
ibytes = 0; ibytes = 0;
if (WARN_ON(entropy_count < 0)) { if (WARN_ON(entropy_count < 0)) {
pr_warn("random: negative entropy count: pool %s count %d\n", pr_warn("negative entropy count: pool %s count %d\n",
r->name, entropy_count); r->name, entropy_count);
entropy_count = 0; entropy_count = 0;
} }
@ -1848,9 +1848,8 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
if (!crng_ready() && maxwarn > 0) { if (!crng_ready() && maxwarn > 0) {
maxwarn--; maxwarn--;
if (__ratelimit(&urandom_warning)) if (__ratelimit(&urandom_warning))
printk(KERN_NOTICE "random: %s: uninitialized " pr_notice("%s: uninitialized urandom read (%zd bytes read)\n",
"urandom read (%zd bytes read)\n", current->comm, nbytes);
current->comm, nbytes);
spin_lock_irqsave(&primary_crng.lock, flags); spin_lock_irqsave(&primary_crng.lock, flags);
crng_init_cnt = 0; crng_init_cnt = 0;
spin_unlock_irqrestore(&primary_crng.lock, flags); spin_unlock_irqrestore(&primary_crng.lock, flags);