tech-kern archive

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

cloning device close race?



I wrote the attached test program as a benchmark for the new
/dev/random implementation.

If you run 10 or so copies at once on a multiprocessor system
with DIAGNOSTIC, you'll see a lot of this message emitted:

vrelel: missing VOP_CLOSE(): vnode @ 0xfffffe801e73cb28, flags 
(0x800030<MPSAFE,LOCKSWORK,INACTNOW>)
        tag VT_UFS(1), type VCHR(4), usecount 2, writecount 0, holdcount 0
        freelisthd 0x0, mount 0xffff800024235000, data 0xfffffe801de01f00 lock 
0xfffffe801e73cc38
        tag VT_UFS, ino 46213, on dev 4, 0 flags 0x0, nlink 1
        mode 020644, owner 0, group 0, size 0

I am guessing the problem also exists with other cloning
pseudodevices, not just the new /dev/random implementation.

-- 
Thor Lancelot Simon                                    tls%panix.com@localhost
  "All of my opinions are consistent, but I cannot present them all
   at once."    -Jean-Jacques Rousseau, On The Social Contract
#include <fcntl.h>
#include <errno.h>
#include <err.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>

int reads;

void getout(int sig)
{
        printf("%d reads in 10 seconds, %d reads/second", reads, reads / 10);
        exit(0);
}

int main(int argc, char **argv)
{
        int fd, done;
        char buf[32];

        (void)signal(SIGALRM, getout);
        alarm(10);
        while(1) {
            fd = open("/dev/urandom", O_RDONLY|O_NONBLOCK, (mode_t)0);
            if (fd < 0) exit(EX_OSERR);
            done = read(fd, &buf, sizeof buf);
            if (done != sizeof buf) {
                err(EX_SOFTWARE, "bad read, %d bytes with errno = %d");
            }
            reads++;
            close(fd);
        }
}



Home | Main Index | Thread Index | Old Index