mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: George Spelvin <lkml@sdf.org>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andy Lutomirski <luto@kernel.org>,
	Yangtao Li <tiny.windzz@gmail.com>,
	linux-kernel@vger.kernel.org, lkml@sdf.org
Subject: [PATCH 1/3] random: Further dead code elimination
Date: Tue, 31 Mar 2020 08:56:59 GMT	[thread overview]
Message-ID: <9916203ec97be0f24886fc8478437d161b56f053.1585644000.git.lkml@sdf.org> (raw)

Earlier commits left some dead code behind in credit_entropy_bits().

In particular, has_initialized was always zero.

Fixes: 90ea1c6436d2 ("random: remove the blocking pool")
Signed-off-by: George Spelvin <lkml@sdf.org>
Cc: Andy Lutomirski <luto@kernel.org>
---
Just some odds & ends I noticed.

 drivers/char/random.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index c7f9584de2c8..273dcbb4a790 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -660,7 +660,7 @@ static void process_random_ready_list(void)
  */
 static void credit_entropy_bits(struct entropy_store *r, int nbits)
 {
-	int entropy_count, orig, has_initialized = 0;
+	int entropy_count, orig;
 	const int pool_size = r->poolinfo->poolfracbits;
 	int nfrac = nbits << ENTROPY_SHIFT;
 
@@ -717,24 +717,11 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
 	if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
 		goto retry;
 
-	if (has_initialized) {
-		r->initialized = 1;
-		kill_fasync(&fasync, SIGIO, POLL_IN);
-	}
+	entropy_count >>= ENTROPY_SHIFT;	/* Convert to bits */
+	trace_credit_entropy_bits(r->name, nbits, entropy_count, _RET_IP_);
 
-	trace_credit_entropy_bits(r->name, nbits,
-				  entropy_count >> ENTROPY_SHIFT, _RET_IP_);
-
-	if (r == &input_pool) {
-		int entropy_bits = entropy_count >> ENTROPY_SHIFT;
-
-		if (crng_init < 2) {
-			if (entropy_bits < 128)
-				return;
-			crng_reseed(&primary_crng, r);
-			entropy_bits = ENTROPY_BITS(r);
-		}
-	}
+	if (r == &input_pool && crng_init < 2 && entropy_count >= 128)
+		crng_reseed(&primary_crng, r);
 }
 
 static int credit_entropy_bits_safe(struct entropy_store *r, int nbits)
-- 
2.26.0


             reply	other threads:[~2020-03-31  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31  8:56 George Spelvin [this message]
2020-03-31  8:56 ` [PATCH 2/3] random: Factor helper calc_entropy_frac() out of credit_entropy_bits() George Spelvin
2020-03-31  8:57 ` [PATCH 3/3] random: use better approximation in calc_entropy_frac() George Spelvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9916203ec97be0f24886fc8478437d161b56f053.1585644000.git.lkml@sdf.org \
    --to=lkml@sdf.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=tiny.windzz@gmail.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®