Skip to contentSkip to conversation

Stack usage in random.c

PATCH Matthew Wilcox 1 participant 1 message Mar 3, 2003 Random number driver

lore
Share & tools
lore
#0 lore 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.

drivers/char/random.c +2 -4
@@ -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" :
Signature · 3 lines
"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