mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Trivial Kernel Patches <trivial@rustcorp.com.au>,
	linux-kernel@vger.kernel.org
Subject: Stack usage in random.c
Date: Mon, 3 Mar 2003 16:20:22 +0000	[thread overview]
Message-ID: <20030303162022.I7301@parcelfarce.linux.theplanet.co.uk> (raw)


Jeff Garzik whined about how much stack space was being used by
extract_entropy().  So I went and looked and reclaimed 352 bytes of stack.
Damn SHA ...

It's actually worse (better?) than that -- xfer_secondary_pool() can call
extract_entropy() again, so I may have saved over 700 bytes of stack
usage here.  It's safe for xfer_secondary_pool() to share its parent's
tmp because it hasn't been used at this point.

--- linux-2.5.63/drivers/char/random.c	2003-02-24 13:05:06.000000000 -0600
+++ linux-2.5.63-random/drivers/char/random.c	2003-03-03 08:05:24.000000000 -0600
@@ -1228,10 +1228,8 @@
  * at which point we do a "catastrophic reseeding".
  */
 static inline void xfer_secondary_pool(struct entropy_store *r,
-				       size_t nbytes)
+				       size_t nbytes, __u32 *tmp)
 {
-	__u32	tmp[TMP_BUF_SIZE];
-
 	if (r->entropy_count < nbytes * 8 &&
 	    r->entropy_count < r->poolinfo.POOLBITS) {
 		int nwords = min_t(int,
@@ -1284,7 +1282,7 @@
 		r->entropy_count = r->poolinfo.POOLBITS;
 
 	if (flags & EXTRACT_ENTROPY_SECONDARY)
-		xfer_secondary_pool(r, nbytes);
+		xfer_secondary_pool(r, nbytes, tmp);
 
 	DEBUG_ENT("%s has %d bits, want %d bits\n",
 		  r == sec_random_state ? "secondary" :

-- 
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

                 reply	other threads:[~2003-03-03 16:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030303162022.I7301@parcelfarce.linux.theplanet.co.uk \
    --to=willy@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@rustcorp.com.au \
    --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®