Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpkern Include kern_tc and use a timecoun...



details:   https://anonhg.NetBSD.org/src/rev/d5a0e8a71bf3
branches:  trunk
changeset: 753939:d5a0e8a71bf3
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Apr 14 10:27:53 2010 +0000

description:
Include kern_tc and use a timecounter driver instead of homerolled
kern_tc implementation.

diffstat:

 sys/rump/librump/rumpkern/Makefile.rumpkern |   6 +-
 sys/rump/librump/rumpkern/emul.c            |  82 +---------------------------
 sys/rump/librump/rumpkern/intr.c            |  64 ++++++++++------------
 sys/rump/librump/rumpkern/rump.c            |  15 ++++-
 4 files changed, 49 insertions(+), 118 deletions(-)

diffs (truncated from 343 to 300 lines):

diff -r c82b6586b717 -r d5a0e8a71bf3 sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern       Wed Apr 14 10:03:18 2010 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern       Wed Apr 14 10:27:53 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpkern,v 1.75 2010/04/12 22:17:23 pooka Exp $
+#      $NetBSD: Makefile.rumpkern,v 1.76 2010/04/14 10:27:53 pooka Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -39,8 +39,8 @@
 # sys/kern
 SRCS+= init_sysctl_base.c kern_auth.c kern_descrip.c kern_event.c      \
        kern_hook.c kern_ksyms.c kern_malloc_stdtype.c kern_module.c    \
-       kern_mutex_obj.c kern_rate.c kern_stub.c kern_sysctl.c          \
-       kern_timeout.c kern_uidinfo.c param.c                           \
+       kern_mutex_obj.c kern_ntptime.c kern_rate.c kern_stub.c         \
+       kern_sysctl.c kern_tc.c kern_timeout.c kern_uidinfo.c param.c   \
        sys_descrip.c sys_generic.c sys_pipe.c sys_select.c syscalls.c
 
 # sys/kern subr (misc)
diff -r c82b6586b717 -r d5a0e8a71bf3 sys/rump/librump/rumpkern/emul.c
--- a/sys/rump/librump/rumpkern/emul.c  Wed Apr 14 10:03:18 2010 +0000
+++ b/sys/rump/librump/rumpkern/emul.c  Wed Apr 14 10:27:53 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emul.c,v 1.124 2010/03/31 14:08:33 pooka Exp $ */
+/*     $NetBSD: emul.c,v 1.125 2010/04/14 10:27:53 pooka Exp $ */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.124 2010/03/31 14:08:33 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.125 2010/04/14 10:27:53 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/null.h>
@@ -62,8 +62,6 @@
 
 #include "rump_private.h"
 
-time_t time_second = 1;
-
 kmutex_t *proc_lock;
 struct lwp lwp0;
 struct vnode *rootvp;
@@ -112,6 +110,8 @@
 kmutex_t tty_lock;
 krwlock_t exec_lock;
 
+struct lwplist alllwp = LIST_HEAD_INITIALIZER(alllwp);
+
 /* sparc doesn't sport constant page size */
 #ifdef __sparc__
 int nbpg = 4096;
@@ -124,73 +124,6 @@
        FSCALE,
 };
 
-void
-getnanouptime(struct timespec *ts)
-{
-
-       rump_getuptime(ts);
-}
-
-void
-getmicrouptime(struct timeval *tv)
-{
-       struct timespec ts;
-
-       getnanouptime(&ts);
-       TIMESPEC_TO_TIMEVAL(tv, &ts);
-}
-
-static void
-gettime(struct timespec *ts)
-{
-       uint64_t sec, nsec;
-       int error;
-
-       rumpuser_gettime(&sec, &nsec, &error);
-       ts->tv_sec = sec;
-       ts->tv_nsec = nsec;
-}
-
-void
-nanotime(struct timespec *ts)
-{
-
-       if (rump_threads) {
-               rump_gettime(ts);
-       } else {
-               gettime(ts);
-       }
-}
-
-/* hooray for mick, so what if I do */
-void
-getnanotime(struct timespec *ts)
-{
-
-       nanotime(ts);
-}
-
-void
-microtime(struct timeval *tv)
-{
-       struct timespec ts;
-
-       if (rump_threads) {
-               rump_gettime(&ts);
-               TIMESPEC_TO_TIMEVAL(tv, &ts);
-       } else {
-               gettime(&ts);
-               TIMESPEC_TO_TIMEVAL(tv, &ts);
-       }
-}
-
-void
-getmicrotime(struct timeval *tv)
-{
-
-       microtime(tv);
-}
-
 struct proc *
 p_find(pid_t pid, uint flags)
 {
@@ -317,13 +250,6 @@
        /* always sleepable, although we should improve this */
 }
 
-void
-tc_setclock(const struct timespec *ts)
-{
-
-       panic("%s: not implemented", __func__);
-}
-
 int
 proc_uidmatch(kauth_cred_t cred, kauth_cred_t target)
 {
diff -r c82b6586b717 -r d5a0e8a71bf3 sys/rump/librump/rumpkern/intr.c
--- a/sys/rump/librump/rumpkern/intr.c  Wed Apr 14 10:03:18 2010 +0000
+++ b/sys/rump/librump/rumpkern/intr.c  Wed Apr 14 10:27:53 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.23 2009/12/05 22:44:08 pooka Exp $  */
+/*     $NetBSD: intr.c,v 1.24 2010/04/14 10:27:53 pooka Exp $  */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,13 +26,15 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.23 2009/12/05 22:44:08 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.24 2010/04/14 10:27:53 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
+#include <sys/kernel.h>
 #include <sys/kmem.h>
 #include <sys/kthread.h>
 #include <sys/intr.h>
+#include <sys/timetc.h>
 
 #include <rump/rumpuser.h>
 
@@ -42,8 +44,6 @@
  * Interrupt simulator.  It executes hardclock() and softintrs.
  */
 
-time_t time_uptime = 0;
-
 #define SI_MPSAFE 0x01
 #define SI_ONLIST 0x02
 #define SI_KILLME 0x04
@@ -67,33 +67,27 @@
 static struct rumpuser_cv *clockcv;
 static struct rumpuser_mtx *clockmtx;
 static struct timespec clockbase, clockup;
-static unsigned clkgen;
 
 kcondvar_t lbolt; /* Oh Kath Ra */
 
-void
-rump_getuptime(struct timespec *ts)
-{
-       int startgen, i = 0;
+static u_int ticks;
 
-       do {
-               startgen = clkgen;
-               if (__predict_false(i++ > 10)) {
-                       yield();
-                       i = 0;
-               }
-               *ts = clockup;
-       } while (startgen != clkgen || clkgen % 2 != 0);
+static u_int
+rumptc_get(struct timecounter *tc)
+{
+
+       KASSERT(rump_threads);
+       return ticks;
 }
 
-void
-rump_gettime(struct timespec *ts)
-{
-       struct timespec ts_up;
-
-       rump_getuptime(&ts_up);
-       timespecadd(&clockbase, &ts_up, ts);
-}
+static struct timecounter rumptc = {
+       .tc_get_timecount       = rumptc_get,
+       .tc_poll_pps            = NULL,
+       .tc_counter_mask        = ~0,
+       .tc_frequency           = 0,
+       .tc_name                = "rumpclk",
+       .tc_quality             = 0,
+};
 
 /*
  * clock "interrupt"
@@ -101,17 +95,17 @@
 static void
 doclock(void *noarg)
 {
-       struct timespec tick, curtime;
+       struct timespec thetick, curtime;
        uint64_t sec, nsec;
-       int ticks = 0, error;
+       int error;
        extern int hz;
 
        rumpuser_gettime(&sec, &nsec, &error);
        clockbase.tv_sec = sec;
        clockbase.tv_nsec = nsec;
        curtime = clockbase;
-       tick.tv_sec = 0;
-       tick.tv_nsec = 1000000000/hz;
+       thetick.tv_sec = 0;
+       thetick.tv_nsec = 1000000000/hz;
 
        rumpuser_mutex_enter(clockmtx);
        rumpuser_cv_signal(clockcv);
@@ -126,15 +120,12 @@
                
                /* if !maincpu: continue */
 
-               if (++ticks == hz) {
-                       time_uptime++;
-                       ticks = 0;
+               if ((++ticks % hz) == 0) {
                        cv_broadcast(&lbolt);
                }
+               tc_ticktock();
 
-               clkgen++;
-               timespecadd(&clockup, &tick, &clockup);
-               clkgen++;
+               timespecadd(&clockup, &thetick, &clockup);
                timespecadd(&clockup, &clockbase, &curtime);
        }
 }
@@ -246,6 +237,9 @@
                        panic("clock thread creation failed: %d", rv);
        }
 
+       rumptc.tc_frequency = hz;
+       tc_init(&rumptc);
+
        /*
         * Make sure we have a clocktime before returning.
         * XXX: mp
diff -r c82b6586b717 -r d5a0e8a71bf3 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Wed Apr 14 10:03:18 2010 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Wed Apr 14 10:27:53 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.159 2010/04/12 22:17:23 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.160 2010/04/14 10:27:53 pooka Exp $ */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.159 2010/04/12 22:17:23 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.160 2010/04/14 10:27:53 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -58,6 +58,7 @@
 #include <sys/select.h>
 #include <sys/sysctl.h>



Home | Main Index | Thread Index | Old Index