Current-Users archive

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

RUMP cprng_fast & arc4random [Was: Re: Tests timing out?]



On Tue, Feb 28, 2012 at 12:24:44AM +0100, Nicolas Joly wrote:
> On Mon, Feb 27, 2012 at 12:47:05PM -0800, Paul Goyette wrote:
> > I'm on my way out so can't look in any more detail, but it seems that 
> > the last couple of passes on my automated build-and-test test bed have a 
> > large number of file-system tests (tests/fs/vfs/) suddenly taking 4 
> > minutes or longer to complete.
> > 
> > See http://www.whooppee.com/amd64-results/ for details ...
> 
> Same here, when run natively, big duration increase :
> 
> t_unpriv (1/1): 24 test cases
>     ext2fs_dirperms: [12.550604s] Passed.
>     ext2fs_owner: [10.608219s] Passed.
> [...]
> 
> Reverting the following arc4random change makes the timimg back to
> previously:
>   http://mail-index.netbsd.org/source-changes/2012/02/27/msg032263.html

Further analysis show that rump kernel cprng_fast functions are using
userland arc4random ... which seem slower now.

The attached patch makes rump use kernel versions for cprng_fast
instead of stub ones. And makes rump testcases much faster.

Does it look ok ?

-- 
Nicolas Joly

Projects and Developments in Bioinformatics
Institut Pasteur, Paris.
Index: sys/rump/librump/rumpkern/cprng_stub.c
===================================================================
RCS file: /cvsroot/src/sys/rump/librump/rumpkern/cprng_stub.c,v
retrieving revision 1.4
diff -u -p -r1.4 cprng_stub.c
--- sys/rump/librump/rumpkern/cprng_stub.c      17 Dec 2011 20:05:40 -0000      
1.4
+++ sys/rump/librump/rumpkern/cprng_stub.c      28 Feb 2012 17:56:19 -0000
@@ -96,41 +96,3 @@ cprng_strong_destroy(cprng_strong_t *c)
        memset(c, 0, sizeof(*c));
        kmem_free(c, sizeof(*c));
 }
-
-size_t
-cprng_fast(void *p, size_t len)
-{
-       uint8_t *resp, *pchar = (uint8_t *)p;
-       uint32_t res;
-       size_t i;
-
-       do {
-               res = rumpuser_arc4random();
-               resp = (uint8_t *)&res;
-
-               for (i = 0; i < sizeof(res); i++) {
-                   *pchar++ = resp[i];
-                   if (pchar == (uint8_t *)p + len) {
-                       return len;
-                   }
-               }
-       } while(1);
-}
-
-uint32_t
-cprng_fast32(void)
-{
-       return rumpuser_arc4random();
-}
-
-uint64_t
-cprng_fast64(void)
-{
-       uint64_t ret;
-       uint32_t *ret32;
-
-       ret32 = (uint32_t *)&ret;
-       ret32[0] = rumpuser_arc4random();
-       ret32[1] = rumpuser_arc4random();
-       return ret;
-}
Index: sys/sys/cprng.h
===================================================================
RCS file: /cvsroot/src/sys/sys/cprng.h,v
retrieving revision 1.4
diff -u -p -r1.4 cprng.h
--- sys/sys/cprng.h     17 Dec 2011 20:05:40 -0000      1.4
+++ sys/sys/cprng.h     28 Feb 2012 17:56:19 -0000
@@ -44,7 +44,6 @@
  */
 #define CPRNG_MAX_LEN  524288
 
-#if !defined(_RUMPKERNEL) && !defined(_RUMP_NATIVE_ABI)
 /*
  * We do not want an arc4random() prototype available to anyone.
  */
@@ -71,11 +70,6 @@ cprng_fast64(void)
        _arc4randbytes(&r, sizeof(r));
        return r;
 }
-#else
-size_t cprng_fast(void *, size_t);
-uint32_t cprng_fast32(void);
-uint64_t cprng_fast64(void);
-#endif
 
 typedef struct _cprng_strong {
        kmutex_t        mtx;


Home | Main Index | Thread Index | Old Index