Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3279051ybb; Tue, 31 Mar 2020 01:58:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vubWPe1ska26e7LAoG4QdHG2Di1AC4cM+rtiQ1bHgESyO5sezXgH7PRKCg+51y+Muhi2px7 X-Received: by 2002:a4a:2cc6:: with SMTP id o189mr2330629ooo.20.1585645086950; Tue, 31 Mar 2020 01:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645086; cv=none; d=google.com; s=arc-20160816; b=dk8hkuco69Tre/RXU47nq/ekQhXz/9mDAGi0vBsKVEX/RQOgsjwuCt88auVkV11Z/Z rQizir/kOWUWTFaBfSUn2Tpcz1X/HPUqdn5BUsPJyJHadjpXU0vEWVEoBC10Ld53Tt+g mCABltmf1qz2q0iTPwp5GbKrGEoYZ7j/sTaY19fnkNBF8lHGuUDk/d5SNm7ZMNJZBQgl 8G9OYIVv8bDGGenMkvMF/MQTtH16zM49LiWjMFQya64/p3a1UuW+q6bXYP7HrqJcy/1o elWDlsYitxeG01U2MXLsGlRKCOXx3/ja92ZLDHqU4eQKoupLmIkhWIABH/gUCRz4uz7R c1AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:from:message-id:date; bh=ZaVAj71tv1DMXWkE4zYmImOt8YA3nm4I3HgRS2VRkg4=; b=BcEvFkqNArSxkpxmTLK86dODrfC5MwimVvUwfBwjLk1XNerOHxzZMcmHcBojkDwmgc tha0BsQ0+FhfPtx39UmoaOC/Dfo+qL5lV9l/75bCwYRIPCOsTu19rSTsJH2FtJS7JyTY GdBjA3mpysFe83l4ILWU08Y9Ah5kf/1oPN9prp85M4zJojz+GvMvYpVdy+GLuBG7a17Q e3hQfMoRYDxXmjix0r1Y76vwE5EwkVfGUEMPwA94eOqP12edKNheCV6VudiamJ5UxPe+ vowvVn+ErdYtCewdweOf8AHc+dma72Porw/5LNz3ztDSEKWssjOX9nYceBnDzpkPwCIo +rYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l21si6853904otq.144.2020.03.31.01.57.54; Tue, 31 Mar 2020 01:58:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730330AbgCaI5I (ORCPT + 99 others); Tue, 31 Mar 2020 04:57:08 -0400 Received: from mx.sdf.org ([205.166.94.20]:59171 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbgCaI5H (ORCPT ); Tue, 31 Mar 2020 04:57:07 -0400 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 02V8uxRt022439 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Tue, 31 Mar 2020 08:56:59 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02V8uxXM006430; Tue, 31 Mar 2020 08:56:59 GMT Date: Tue, 31 Mar 2020 08:56:59 GMT Message-Id: <9916203ec97be0f24886fc8478437d161b56f053.1585644000.git.lkml@sdf.org> From: George Spelvin Subject: [PATCH 1/3] random: Further dead code elimination To: "Theodore Ts'o" Cc: Andy Lutomirski , Yangtao Li , linux-kernel@vger.kernel.org, lkml@sdf.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Andy Lutomirski --- 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