Source-Changes-HG archive

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

[src/trunk]: src/sys/rump Create async i/o "interrupt" thread from within the...



details:   https://anonhg.NetBSD.org/src/rev/db89aec91d71
branches:  trunk
changeset: 749155:db89aec91d71
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Nov 19 14:44:58 2009 +0000

description:
Create async i/o "interrupt" thread from within the kernel so that
it gets a kernel thread context.

diffstat:

 sys/rump/include/rump/rumpuser.h               |   4 +-
 sys/rump/librump/rumpuser/rumpuser_pth.c       |  30 +++++++++++--------------
 sys/rump/librump/rumpuser/rumpuser_pth_dummy.c |  21 ++++++++++++------
 sys/rump/librump/rumpvfs/rump_vfs.c            |  13 ++++++----
 4 files changed, 37 insertions(+), 31 deletions(-)

diffs (199 lines):

diff -r d6d68d9d56dc -r db89aec91d71 sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h  Thu Nov 19 13:46:55 2009 +0000
+++ b/sys/rump/include/rump/rumpuser.h  Thu Nov 19 14:44:58 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.h,v 1.32 2009/11/11 16:46:50 pooka Exp $      */
+/*     $NetBSD: rumpuser.h,v 1.33 2009/11/19 14:44:58 pooka Exp $      */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -108,7 +108,7 @@
 
 /* rumpuser_pth */
 void rumpuser_thrinit(kernel_lockfn, kernel_unlockfn, int);
-int  rumpuser_bioinit(rump_biodone_fn);
+void rumpuser_biothread(void *);
 
 int  rumpuser_thread_create(void *(*f)(void *), void *, const char *);
 void rumpuser_thread_exit(void);
diff -r d6d68d9d56dc -r db89aec91d71 sys/rump/librump/rumpuser/rumpuser_pth.c
--- a/sys/rump/librump/rumpuser/rumpuser_pth.c  Thu Nov 19 13:46:55 2009 +0000
+++ b/sys/rump/librump/rumpuser/rumpuser_pth.c  Thu Nov 19 14:44:58 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_pth.c,v 1.38 2009/11/11 16:46:50 pooka Exp $  */
+/*     $NetBSD: rumpuser_pth.c,v 1.39 2009/11/19 14:44:58 pooka Exp $  */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.38 2009/11/11 16:46:50 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.39 2009/11/19 14:44:58 pooka Exp $");
 #endif /* !lint */
 
 #ifdef __linux__
@@ -124,15 +124,19 @@
 kernel_unlockfn        rumpuser__kunlock;
 int            rumpuser__wantthreads;
 
-static void *
+void
 /*ARGSUSED*/
-iothread(void *arg)
+rumpuser_biothread(void *arg)
 {
        struct rumpuser_aio *rua;
        rump_biodone_fn biodone = arg;
        ssize_t rv;
        int error, dummy;
 
+       /* unschedule from CPU.  we reschedule before running the interrupt */
+       rumpuser__kunlock(0, &dummy);
+       assert(dummy == 0);
+
        NOFAIL_ERRNO(pthread_mutex_lock(&rumpuser_aio_mtx.pthmtx));
        for (;;) {
                while (rumpuser_aio_head == rumpuser_aio_tail) {
@@ -169,9 +173,8 @@
                        }
                }
                rumpuser__klock(0);
-               biodone(rua->rua_bp, rv, error);
+               biodone(rua->rua_bp, (size_t)rv, error);
                rumpuser__kunlock(0, &dummy);
-               assert(dummy == 0);
                        
                rua->rua_bp = NULL;
 
@@ -179,6 +182,10 @@
                rumpuser_aio_tail = (rumpuser_aio_tail+1) % N_AIOS;
                pthread_cond_signal(&rumpuser_aio_cv.pthcv);
        }
+
+       /*NOTREACHED*/
+       fprintf(stderr, "error: rumpuser_biothread reached unreachable\n");
+       abort();
 }
 
 void
@@ -195,17 +202,6 @@
        rumpuser__wantthreads = threads;
 }
 
-int
-rumpuser_bioinit(rump_biodone_fn biodone)
-{
-       pthread_t iothr;
-
-       if (rumpuser__wantthreads)
-               pthread_create(&iothr, NULL, iothread, biodone);
-
-       return 0;
-}
-
 #if 0
 void
 rumpuser__thrdestroy(void)
diff -r d6d68d9d56dc -r db89aec91d71 sys/rump/librump/rumpuser/rumpuser_pth_dummy.c
--- a/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c    Thu Nov 19 13:46:55 2009 +0000
+++ b/sys/rump/librump/rumpuser/rumpuser_pth_dummy.c    Thu Nov 19 14:44:58 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_pth_dummy.c,v 1.6 2009/04/29 14:58:50 pooka Exp $     */
+/*     $NetBSD: rumpuser_pth_dummy.c,v 1.7 2009/11/19 14:44:58 pooka Exp $     */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.6 2009/04/29 14:58:50 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.7 2009/11/19 14:44:58 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/time.h>
@@ -75,11 +75,12 @@
 }
 
 /*ARGSUSED*/
-int
-rumpuser_bioinit(rump_biodone_fn biodone)
+void
+rumpuser_biothread(void *arg)
 {
 
-       return 0;
+       fprintf(stderr, "rumpuser: threads not available\n");
+       abort();
 }
 
 /*ARGSUSED*/
@@ -240,10 +241,16 @@
 /*ARGSUSED*/
 int
 rumpuser_cv_timedwait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx,
-       struct timespec *ts)
+       int64_t sec, int64_t nsec)
 {
+       struct timespec ts;
 
-       nanosleep(ts, NULL);
+       /*LINTED*/
+       ts.tv_sec = sec;
+       /*LINTED*/
+       ts.tv_nsec = nsec;
+
+       nanosleep(&ts, NULL);
        return 0;
 }
 
diff -r d6d68d9d56dc -r db89aec91d71 sys/rump/librump/rumpvfs/rump_vfs.c
--- a/sys/rump/librump/rumpvfs/rump_vfs.c       Thu Nov 19 13:46:55 2009 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs.c       Thu Nov 19 14:44:58 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_vfs.c,v 1.33 2009/10/15 00:34:05 pooka Exp $      */
+/*     $NetBSD: rump_vfs.c,v 1.34 2009/11/19 14:44:58 pooka Exp $      */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.33 2009/10/15 00:34:05 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.34 2009/11/19 14:44:58 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -77,6 +77,7 @@
 {
        char buf[64];
        int error;
+       int rv;
        extern int dovfsusermount; /* XXX */
 
        dovfsusermount = 1; /* XXX */
@@ -96,7 +97,11 @@
        cwd_sys_init();
        lf_init();
 
-       rumpuser_bioinit(rump_biodone);
+       if (rump_threads) {
+               if ((rv = kthread_create(PRI_BIO, KTHREAD_MPSAFE, NULL,
+                   rumpuser_biothread, rump_biodone, NULL, "rmpabio")) != 0)
+                       panic("syncer thread create failed: %d", rv);
+       }
        rumpfs_init();
 
        rump_proc_vfs_init = pvfs_init;
@@ -110,8 +115,6 @@
        proc0.p_cwdi = cwdinit();
 
        if (rump_threads) {
-               int rv;
-
                if ((rv = kthread_create(PRI_IOFLUSH, KTHREAD_MPSAFE, NULL,
                    sched_sync, NULL, NULL, "ioflush")) != 0)
                        panic("syncer thread create failed: %d", rv);



Home | Main Index | Thread Index | Old Index