vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| re by doing things like `dd if=/dev/urandom of=/dev/null bs=2048k` one can easily hog a system or even worse on smp where time stalls horribly as well (assuming dd endsup on the cpu>0). this way dd is almost unnoticable (on a fast amd64 of course and throughput drops from 900k/s to about half of it that is barely critical anyhow... this is also similar to what freebsd does... cu -- paranoic mickey (my employers have changed but, the name has remained) Index: rnd.c ================================================== ================= RCS file: /cvs/src/sys/dev/rnd.c,v retrieving revision 1.82 diff -u -r1.82 rnd.c --- rnd.c 17 Jun 2007 21:22:04 -0000 1.82 +++ rnd.c 4 Sep 2007 15:05:51 -0000 @@ -940,8 +940,7 @@ int randomread(dev_t dev, struct uio *uio, int ioflag) { - int ret = 0; - int i; + int i, cnt, ret = 0; u_int32_t *buf; if (uio->uio_resid == 0) @@ -949,8 +948,12 @@ MALLOC(buf, u_int32_t *, POOLBYTES, M_TEMP, M_WAITOK); - while (!ret && uio->uio_resid > 0) { - int n = min(POOLBYTES, uio->uio_resid); + cnt = uio->uio_resid; + if (cnt > PAGE_SIZE) + cnt = PAGE_SIZE; + + while (!ret && cnt > 0) { + int n = min(POOLBYTES, cnt); switch(minor(dev)) { case RND_RND: @@ -1009,8 +1012,9 @@ default: ret = ENXIO; } - if (n != 0 && ret == 0) - ret = uiomove((caddr_t)buf, n, uio); + if (n != 0 && ret == 0 && + !(ret = uiomove((caddr_t)buf, n, uio))) + cnt -= n; } FREE(buf, M_TEMP); |