Re: [PATCH][RFC] random: show /dev/random statistics per interface, kernel 2.6.26.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18-08-08 19:25, Stanichenko Marat wrote:

From: Stanichenko Marat <mstanichenko@xxxxxxxxx>

Add the interface that shows the amount of entropy generated via the interfaces and also the amount consumed. This patch adds two files in proc. The first of them shows the entropy generated per interface, the second one - the amount consumed from blocking (/dev/random) and nonblocking (/dev/urandom) pools.

This patch is an attempt to realize "/dev/random statistics" project of kernel newbies community.
http://kernelnewbies.org/KernelProjects

Signed-off-by: Stanichenko Marat <mstanichenko@xxxxxxxxx>

Just two quick comments/questions as encountered while reading. I'm not familiar with the random code or anything.

First, your patch was posted Base64 encoded which doesn't make it easier to look at/comment on. Base64 encoding even text/plain attchments is a longstanding Thunderbird bug when your outgoing charset is set to UTF-8 (and the reason why my outgoing charset is ISO8859-15; you just won't remember to switch from UTF-8 to something else every time when posting a patch otherwise).

+struct ioctl_rand_stat {
+	unsigned nbits;
+	spinlock_t lock;
+};
+static struct ioctl_rand_stat  ent_ioctl_produce = {
+	.nbits = 0,
+	.lock = __SPIN_LOCK_UNLOCKED(&input_timer_state.lock),

Is that supposed to be &ent_ioctl_produce.lock?

@@ -621,8 +645,11 @@ static void add_timer_randomness(struct * Round down by 1 bit on general principles,
 		 * and limit entropy entimate to 12 bits.
 		 */
-		credit_entropy_bits(&input_pool,
-				    min_t(int, fls(delta>>1), 11));
+		nbits = min_t(int, fls(delta>>1), 11);
+		spin_lock_irqsave(&state->lock, flags);
+		state->nbits += nbits;
+		spin_unlock_irqrestore(&state->lock, flags);
+		credit_entropy_bits(&input_pool,nbits);


Couldn't state->nbits be an atomic_t? The locking looks like it might be a little expensive. Maybe they should be per-cpu? I have no idea about the frequencies here...

Rene.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux