]> git.neil.brown.name Git - history.git/commitdiff
Remove performance barrier in i810_rng char driver.
authorJeff Garzik <jgarzik@redhat.com>
Tue, 5 Nov 2002 16:02:34 +0000 (11:02 -0500)
committerJeff Garzik <jgarzik@redhat.com>
Tue, 5 Nov 2002 16:02:34 +0000 (11:02 -0500)
In order to conserve CPU, the read(2) syscall would schedule_timeout
unconditionally.  This also crippled speed, and was a bad design
decision.  This cset merges the updated read(2) logic of the sister
driver amd768_rng from Alan, which schedules only when it needs to.

On my test system, by one microbenmark, read(2) output jumped
from 0.08 kbit/s to "what Intel expects" of 20 kbit/s.

End users may notice a significant decrease in idle time after
this change (and a correspondingly large increase in /dev/hwrng user
speed), if /dev/hwrng is used to its maximum capacity.

drivers/char/i810_rng.c

index 8bc0fe1ff8d39a3c824ffdf33bf2b17edf6c8bda..3dfd9a456cf9544a987791585a18a12c21ede6cc 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/miscdevice.h>
 #include <linux/smp_lock.h>
 #include <linux/mm.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -243,8 +244,13 @@ static ssize_t rng_dev_read (struct file *filp, char *buf, size_t size,
                if (filp->f_flags & O_NONBLOCK)
                        return ret ? : -EAGAIN;
 
-               current->state = TASK_INTERRUPTIBLE;
-               schedule_timeout(1);
+               if (need_resched())
+               {
+                       current->state = TASK_INTERRUPTIBLE;
+                       schedule_timeout(1);
+               }
+               else
+                       udelay(200);
 
                if (signal_pending (current))
                        return ret ? : -ERESTARTSYS;