Source-Changes-HG archive

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

[src/trunk]: src/external/cddl/osnet Add the FreeBSD 8-RC1 changes for DTrace.



details:   https://anonhg.NetBSD.org/src/rev/f9399d315404
branches:  trunk
changeset: 752244:f9399d315404
user:      darran <darran%NetBSD.org@localhost>
date:      Sun Feb 21 00:49:51 2010 +0000

description:
Add the FreeBSD 8-RC1 changes for DTrace.

Ok with core@.

diffstat:

 external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c        |   133 +
 external/cddl/osnet/dev/cyclic/cyclic.c                      |  1420 ++++
 external/cddl/osnet/dev/cyclic/cyclic_test.c                 |   301 +
 external/cddl/osnet/dev/cyclic/i386/cyclic_machdep.c         |   133 +
 external/cddl/osnet/dev/dtmalloc/dtmalloc.c                  |   220 +
 external/cddl/osnet/dev/dtrace/amd64/dis_tables.c            |  3193 ++++++++++
 external/cddl/osnet/dev/dtrace/amd64/dis_tables.h            |   112 +
 external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S            |   573 +
 external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c            |   610 +
 external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c           |   551 +
 external/cddl/osnet/dev/dtrace/amd64/instr_size.c            |   132 +
 external/cddl/osnet/dev/dtrace/dtrace_anon.c                 |    84 +
 external/cddl/osnet/dev/dtrace/dtrace_cddl.h                 |   134 +
 external/cddl/osnet/dev/dtrace/dtrace_clone.c                |    61 +
 external/cddl/osnet/dev/dtrace/dtrace_debug.c                |   596 +
 external/cddl/osnet/dev/dtrace/dtrace_hacks.c                |    13 +
 external/cddl/osnet/dev/dtrace/dtrace_ioctl.c                |   782 ++
 external/cddl/osnet/dev/dtrace/dtrace_load.c                 |   168 +
 external/cddl/osnet/dev/dtrace/dtrace_modevent.c             |    47 +
 external/cddl/osnet/dev/dtrace/dtrace_sysctl.c               |    82 +
 external/cddl/osnet/dev/dtrace/dtrace_test.c                 |    73 +
 external/cddl/osnet/dev/dtrace/dtrace_unload.c               |   142 +
 external/cddl/osnet/dev/dtrace/dtrace_vtime.c                |   101 +
 external/cddl/osnet/dev/dtrace/i386/dis_tables.c             |  3193 ++++++++++
 external/cddl/osnet/dev/dtrace/i386/dis_tables.h             |   112 +
 external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S             |   527 +
 external/cddl/osnet/dev/dtrace/i386/dtrace_isa.c             |   622 +
 external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c            |   548 +
 external/cddl/osnet/dev/dtrace/i386/instr_size.c             |   132 +
 external/cddl/osnet/dev/fbt/fbt.c                            |  1411 ++++
 external/cddl/osnet/dev/lockstat/lockstat.c                  |   327 +
 external/cddl/osnet/dev/profile/profile.c                    |   531 +
 external/cddl/osnet/dev/prototype.c                          |   144 +
 external/cddl/osnet/dev/sdt/sdt.c                            |   254 +
 external/cddl/osnet/dev/systrace/systrace.c                  |   341 +
 external/cddl/osnet/dist/cmd/dtrace/dtrace.c                 |    74 +-
 external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c         |    35 +-
 external/cddl/osnet/dist/lib/libctf/common/ctf_subr.c        |     5 +-
 external/cddl/osnet/dist/lib/libdtrace/common/drti.c         |    37 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c |    25 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_cc.c        |    96 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_cg.c        |    54 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c   |   382 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_dof.c       |     4 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_error.c     |    18 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_errtags.h   |     6 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_handle.c    |     4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_ident.c     |     6 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h      |    30 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_lex.l       |    26 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c      |   179 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_map.c       |    18 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c    |   105 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c      |   261 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_options.c   |    17 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_parser.c    |     2 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.c       |   120 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_pragma.c    |     2 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_printf.c    |    93 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c      |   133 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.h      |     4 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_program.c   |     9 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_provider.c  |     4 +
 external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c      |    65 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dt_work.c      |    23 +-
 external/cddl/osnet/dist/lib/libdtrace/common/dtrace.h       |    14 +-
 external/cddl/osnet/dist/lib/libdtrace/common/mkerrtags.sh   |     6 +-
 external/cddl/osnet/dist/lib/libdtrace/common/mknames.sh     |     6 +-
 external/cddl/osnet/dist/lib/libgen/common/gmatch.c          |    45 +-
 external/cddl/osnet/dist/tools/ctf/common/list.c             |     4 +-
 external/cddl/osnet/dist/tools/ctf/common/memory.c           |     1 +
 external/cddl/osnet/dist/tools/ctf/cvt/alist.c               |    38 +-
 external/cddl/osnet/dist/tools/ctf/cvt/alist.h               |     1 +
 external/cddl/osnet/dist/tools/ctf/cvt/barrier.c             |    14 +
 external/cddl/osnet/dist/tools/ctf/cvt/barrier.h             |     5 +
 external/cddl/osnet/dist/tools/ctf/cvt/ctf.c                 |   109 +-
 external/cddl/osnet/dist/tools/ctf/cvt/ctfconvert.c          |    21 +-
 external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c            |    46 +-
 external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.h            |     9 +-
 external/cddl/osnet/dist/tools/ctf/cvt/ctftools.h            |    28 +-
 external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c               |   242 +-
 external/cddl/osnet/dist/tools/ctf/cvt/fixup_tdescs.c        |    24 +-
 external/cddl/osnet/dist/tools/ctf/cvt/hash.c                |    26 +-
 external/cddl/osnet/dist/tools/ctf/cvt/iidesc.c              |    20 +-
 external/cddl/osnet/dist/tools/ctf/cvt/input.c               |     5 +-
 external/cddl/osnet/dist/tools/ctf/cvt/merge.c               |    81 +-
 external/cddl/osnet/dist/tools/ctf/cvt/output.c              |    61 +-
 external/cddl/osnet/dist/tools/ctf/cvt/st_parse.c            |    43 +-
 external/cddl/osnet/dist/tools/ctf/cvt/stabs.c               |    12 +-
 external/cddl/osnet/dist/tools/ctf/cvt/strtab.c              |     2 +-
 external/cddl/osnet/dist/tools/ctf/cvt/strtab.h              |     2 +-
 external/cddl/osnet/dist/tools/ctf/cvt/tdata.c               |    42 +-
 external/cddl/osnet/dist/tools/ctf/cvt/traverse.c            |    18 +-
 external/cddl/osnet/dist/tools/ctf/cvt/traverse.h            |     2 +-
 external/cddl/osnet/dist/tools/ctf/cvt/util.c                |    63 +-
 external/cddl/osnet/dist/tools/ctf/dump/dump.c               |    50 +-
 external/cddl/osnet/dist/uts/common/dtrace/dtrace.c          |  1411 +++-
 external/cddl/osnet/dist/uts/common/dtrace/fasttrap.c        |     4 +-
 external/cddl/osnet/dist/uts/common/dtrace/lockstat.c        |     5 +-
 external/cddl/osnet/dist/uts/common/dtrace/profile.c         |     6 +-
 external/cddl/osnet/dist/uts/common/dtrace/sdt_subr.c        |    16 -
 external/cddl/osnet/dist/uts/common/dtrace/systrace.c        |     6 +-
 external/cddl/osnet/dist/uts/common/sys/ctf.h                |     2 +
 external/cddl/osnet/dist/uts/common/sys/ctf_api.h            |     6 +-
 external/cddl/osnet/dist/uts/common/sys/dtrace.h             |   103 +-
 external/cddl/osnet/dist/uts/common/sys/dtrace_impl.h        |    37 +-
 external/cddl/osnet/dist/uts/common/sys/processor.h          |   150 +
 external/cddl/osnet/include/alloca.h                         |     4 +-
 external/cddl/osnet/include/assert.h                         |    55 +
 external/cddl/osnet/include/devid.h                          |     6 +-
 external/cddl/osnet/include/dtrace.h                         |    37 +
 external/cddl/osnet/include/fcntl.h                          |     4 +-
 external/cddl/osnet/include/fsshare.h                        |     4 +-
 external/cddl/osnet/include/libintl.h                        |    31 +-
 external/cddl/osnet/include/libproc.h                        |    46 +
 external/cddl/osnet/include/libshare.h                       |    36 +
 external/cddl/osnet/include/mnttab.h                         |    33 +-
 external/cddl/osnet/include/priv.h                           |    37 +-
 external/cddl/osnet/include/solaris.h                        |    31 +-
 external/cddl/osnet/include/stdio.h                          |     4 +-
 external/cddl/osnet/include/stdlib.h                         |     4 +-
 external/cddl/osnet/include/strings.h                        |     4 +-
 external/cddl/osnet/include/unistd.h                         |     4 +-
 external/cddl/osnet/include/zone.h                           |    31 +-
 external/cddl/osnet/lib/Makefile                             |    26 +-
 external/cddl/osnet/lib/Makefile.inc                         |     8 +-
 external/cddl/osnet/lib/drti/Makefile                        |    23 +
 external/cddl/osnet/lib/libavl/Makefile                      |     7 +-
 external/cddl/osnet/lib/libctf/Makefile                      |    34 +
 external/cddl/osnet/lib/libdtrace/Makefile                   |    97 +
 external/cddl/osnet/lib/libdtrace/errno.d                    |   228 +
 external/cddl/osnet/lib/libdtrace/net.d                      |    43 +
 external/cddl/osnet/lib/libdtrace/nfs.d                      |    96 +
 external/cddl/osnet/lib/libdtrace/psinfo.d                   |    95 +
 external/cddl/osnet/lib/libdtrace/sched.d                    |    86 +
 external/cddl/osnet/lib/libdtrace/signal.d                   |   101 +
 external/cddl/osnet/lib/libdtrace/unistd.d                   |    56 +
 external/cddl/osnet/lib/libnvpair/Makefile                   |    21 +-
 external/cddl/osnet/lib/libumem/Makefile                     |     6 +-
 external/cddl/osnet/lib/libuutil/Makefile                    |    24 +-
 external/cddl/osnet/lib/libzfs/Makefile                      |    61 +-
 external/cddl/osnet/lib/libzpool/Makefile                    |    79 +-
 external/cddl/osnet/sys/sys/acl.h                            |    39 +
 external/cddl/osnet/sys/sys/atomic.h                         |   160 +-
 external/cddl/osnet/sys/sys/bitmap.h                         |     4 +-
 external/cddl/osnet/sys/sys/byteorder.h                      |     4 +-
 external/cddl/osnet/sys/sys/cmn_err.h                        |    82 +-
 external/cddl/osnet/sys/sys/cpupart.h                        |     4 +-
 external/cddl/osnet/sys/sys/cpuvar.h                         |    92 +-
 external/cddl/osnet/sys/sys/cpuvar_defs.h                    |    59 +
 external/cddl/osnet/sys/sys/cred.h                           |    71 +-
 external/cddl/osnet/sys/sys/cyclic.h                         |    94 +-
 external/cddl/osnet/sys/sys/cyclic_impl.h                    |   304 +
 external/cddl/osnet/sys/sys/debug.h                          |     4 +-
 external/cddl/osnet/sys/sys/dirent.h                         |     4 +-
 external/cddl/osnet/sys/sys/dkio.h                           |     7 +-
 external/cddl/osnet/sys/sys/dnlc.h                           |     6 +-
 external/cddl/osnet/sys/sys/elf.h                            |     4 +-
 external/cddl/osnet/sys/sys/feature_tests.h                  |    35 +
 external/cddl/osnet/sys/sys/file.h                           |    57 +
 external/cddl/osnet/sys/sys/kcondvar.h                       |    58 +-
 external/cddl/osnet/sys/sys/kidmap.h                         |     2 +-
 external/cddl/osnet/sys/sys/kmem.h                           |   103 +-
 external/cddl/osnet/sys/sys/kobj.h                           |     5 +-
 external/cddl/osnet/sys/sys/kstat.h                          |    39 +-
 external/cddl/osnet/sys/sys/lock.h                           |     7 +-
 external/cddl/osnet/sys/sys/misc.h                           |    17 +-
 external/cddl/osnet/sys/sys/mman.h                           |     4 +-
 external/cddl/osnet/sys/sys/mntent.h                         |    60 +
 external/cddl/osnet/sys/sys/mnttab.h                         |   123 +-
 external/cddl/osnet/sys/sys/modctl.h                         |     6 +-
 external/cddl/osnet/sys/sys/mount.h                          |    33 +-
 external/cddl/osnet/sys/sys/mutex.h                          |    76 +-
 external/cddl/osnet/sys/sys/objfs.h                          |     4 +-
 external/cddl/osnet/sys/sys/param.h                          |    10 +-
 external/cddl/osnet/sys/sys/pathname.h                       |    10 +-
 external/cddl/osnet/sys/sys/pcpu.h                           |     8 +-
 external/cddl/osnet/sys/sys/policy.h                         |    57 +-
 external/cddl/osnet/sys/sys/proc.h                           |    97 +-
 external/cddl/osnet/sys/sys/random.h                         |    10 +-
 external/cddl/osnet/sys/sys/refstr.h                         |    34 +
 external/cddl/osnet/sys/sys/rwlock.h                         |    83 +-
 external/cddl/osnet/sys/sys/sdt.h                            |     4 +-
 external/cddl/osnet/sys/sys/sema.h                           |    40 +
 external/cddl/osnet/sys/sys/sid.h                            |    36 +-
 external/cddl/osnet/sys/sys/sig.h                            |    69 +
 external/cddl/osnet/sys/sys/stat.h                           |     6 +-
 external/cddl/osnet/sys/sys/string.h                         |     6 +-
 external/cddl/osnet/sys/sys/sunddi.h                         |     6 +-
 external/cddl/osnet/sys/sys/sysmacros.h                      |   320 +-
 external/cddl/osnet/sys/sys/systm.h                          |    41 +-
 external/cddl/osnet/sys/sys/time.h                           |    13 +-
 external/cddl/osnet/sys/sys/types.h                          |    87 +-
 external/cddl/osnet/sys/sys/uio.h                            |    43 +-
 external/cddl/osnet/sys/sys/varargs.h                        |     4 +-
 external/cddl/osnet/sys/sys/vfs.h                            |    70 +-
 external/cddl/osnet/sys/sys/vnode.h                          |   617 +-
 external/cddl/osnet/sys/sys/zone.h                           |    16 +-
 external/cddl/osnet/usr.bin/ctfconvert/Makefile              |    51 +
 external/cddl/osnet/usr.bin/ctfdump/Makefile                 |    31 +
 external/cddl/osnet/usr.bin/ctfmerge/Makefile                |    47 +
 external/cddl/osnet/usr.sbin/dtrace/Makefile                 |    37 +
 202 files changed, 24524 insertions(+), 2784 deletions(-)

diffs (truncated from 35821 to 300 lines):

diff -r df28574d136d -r f9399d315404 external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c     Sun Feb 21 00:49:51 2010 +0000
@@ -0,0 +1,133 @@
+/*-
+ * Copyright 2007 John Birrell <jb%FreeBSD.org@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/cddl/dev/cyclic/amd64/cyclic_machdep.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $
+ *
+ */
+
+static void enable(cyb_arg_t);
+static void disable(cyb_arg_t);
+static void reprogram(cyb_arg_t, hrtime_t);
+static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *);
+
+static cyc_backend_t   be      = {
+       NULL,           /* cyb_configure */
+       NULL,           /* cyb_unconfigure */
+       enable,
+       disable,
+       reprogram,
+       xcall,
+       NULL            /* cyb_arg_t cyb_arg */
+};
+
+static void
+cyclic_ap_start(void *dummy)
+{
+       /* Initialise the rest of the CPUs. */
+       cyclic_mp_init();
+}
+
+SYSINIT(cyclic_ap_start, SI_SUB_SMP, SI_ORDER_ANY, cyclic_ap_start, NULL);
+
+/*
+ *  Machine dependent cyclic subsystem initialisation.
+ */
+static void
+cyclic_machdep_init(void)
+{
+       /* Register the cyclic backend. */
+       cyclic_init(&be);
+}
+
+static void
+cyclic_machdep_uninit(void)
+{
+       int i;
+
+       for (i = 0; i <= mp_maxid; i++)
+               /* Reset the cyclic clock callback hook. */
+               lapic_cyclic_clock_func[i] = NULL;
+
+       /* De-register the cyclic backend. */
+       cyclic_uninit();
+}
+
+static hrtime_t exp_due[MAXCPU];
+
+/*
+ * This function is the one registered by the machine dependent
+ * initialiser as the callback for high speed timer events.
+ */
+static void
+cyclic_clock(struct trapframe *frame)
+{
+       cpu_t *c = &solaris_cpu[curcpu];
+
+       if (c->cpu_cyclic != NULL && gethrtime() >= exp_due[curcpu]) {
+               if (TRAPF_USERMODE(frame)) {
+                       c->cpu_profile_pc = 0;
+                       c->cpu_profile_upc = TRAPF_PC(frame);
+               } else {
+                       c->cpu_profile_pc = TRAPF_PC(frame);
+                       c->cpu_profile_upc = 0;
+               }
+
+               c->cpu_intr_actv = 1;
+
+               /* Fire any timers that are due. */
+               cyclic_fire(c);
+
+               c->cpu_intr_actv = 0;
+       }
+}
+
+static void enable(cyb_arg_t arg)
+{
+       /* Register the cyclic clock callback function. */
+       lapic_cyclic_clock_func[curcpu] = cyclic_clock;
+}
+
+static void disable(cyb_arg_t arg)
+{
+       /* Reset the cyclic clock callback function. */
+       lapic_cyclic_clock_func[curcpu] = NULL;
+}
+
+static void reprogram(cyb_arg_t arg, hrtime_t exp)
+{
+       exp_due[curcpu] = exp;
+}
+
+static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param)
+{
+       /*
+        * If the target CPU is the current one, just call the
+        * function. This covers the non-SMP case.
+        */
+       if (c == &solaris_cpu[curcpu])
+               (*func)(param);
+       else
+               smp_rendezvous_cpus((cpumask_t) (1 << c->cpuid), NULL,
+                   func, smp_no_rendevous_barrier, param);
+}
diff -r df28574d136d -r f9399d315404 external/cddl/osnet/dev/cyclic/cyclic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/cddl/osnet/dev/cyclic/cyclic.c   Sun Feb 21 00:49:51 2010 +0000
@@ -0,0 +1,1420 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * Portions Copyright 2008 John Birrell <jb%freebsd.org@localhost>
+ *
+ * $FreeBSD: src/sys/cddl/dev/cyclic/cyclic.c,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
+ *
+ * This is a simplified version of the cyclic timer subsystem from
+ * OpenSolaris. In the FreeBSD version, we don't use interrupt levels.
+ */
+
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ *  The Cyclic Subsystem
+ *  --------------------
+ *
+ *  Prehistory
+ *
+ *  Historically, most computer architectures have specified interval-based
+ *  timer parts (e.g. SPARCstation's counter/timer; Intel's i8254).  While
+ *  these parts deal in relative (i.e. not absolute) time values, they are
+ *  typically used by the operating system to implement the abstraction of
+ *  absolute time.  As a result, these parts cannot typically be reprogrammed
+ *  without introducing error in the system's notion of time.
+ *
+ *  Starting in about 1994, chip architectures began specifying high resolution
+ *  timestamp registers.  As of this writing (1999), all major chip families
+ *  (UltraSPARC, PentiumPro, MIPS, PowerPC, Alpha) have high resolution
+ *  timestamp registers, and two (UltraSPARC and MIPS) have added the capacity
+ *  to interrupt based on timestamp values.  These timestamp-compare registers
+ *  present a time-based interrupt source which can be reprogrammed arbitrarily
+ *  often without introducing error.  Given the low cost of implementing such a
+ *  timestamp-compare register (and the tangible benefit of eliminating
+ *  discrete timer parts), it is reasonable to expect that future chip
+ *  architectures will adopt this feature.
+ *
+ *  The cyclic subsystem has been designed to take advantage of chip
+ *  architectures with the capacity to interrupt based on absolute, high
+ *  resolution values of time.
+ *
+ *  Subsystem Overview
+ *
+ *  The cyclic subsystem is a low-level kernel subsystem designed to provide
+ *  arbitrarily high resolution, per-CPU interval timers (to avoid colliding
+ *  with existing terms, we dub such an interval timer a "cyclic").
+ *  Alternatively, a cyclic may be specified to be "omnipresent", denoting
+ *  firing on all online CPUs.
+ *
+ *  Cyclic Subsystem Interface Overview
+ *  -----------------------------------
+ *
+ *  The cyclic subsystem has interfaces with the kernel at-large, with other
+ *  kernel subsystems (e.g. the processor management subsystem, the checkpoint
+ *  resume subsystem) and with the platform (the cyclic backend).  Each
+ *  of these interfaces is given a brief synopsis here, and is described
+ *  in full above the interface's implementation.
+ *
+ *  The following diagram displays the cyclic subsystem's interfaces to
+ *  other kernel components.  The arrows denote a "calls" relationship, with
+ *  the large arrow indicating the cyclic subsystem's consumer interface.
+ *  Each arrow is labeled with the section in which the corresponding
+ *  interface is described.
+ *
+ *           Kernel at-large consumers
+ *           -----------++------------
+ *                      ||
+ *                      ||
+ *                     _||_
+ *                     \  /
+ *                      \/
+ *            +---------------------+
+ *            |                     |
+ *            |  Cyclic subsystem   |<-----------  Other kernel subsystems
+ *            |                     |
+ *            +---------------------+
+ *                   ^       |
+ *                   |       |
+ *                   |       |
+ *                   |       v
+ *            +---------------------+
+ *            |                     |
+ *            |   Cyclic backend    |
+ *            | (platform specific) |
+ *            |                     |
+ *            +---------------------+
+ *
+ *
+ *  Kernel At-Large Interfaces
+ *
+ *      cyclic_add()         <-- Creates a cyclic
+ *      cyclic_add_omni()    <-- Creates an omnipresent cyclic
+ *      cyclic_remove()      <-- Removes a cyclic
+ *
+ *  Backend Interfaces
+ *
+ *      cyclic_init()        <-- Initializes the cyclic subsystem
+ *      cyclic_fire()        <-- Interrupt entry point
+ *
+ *  The backend-supplied interfaces (through the cyc_backend structure) are
+ *  documented in detail in <sys/cyclic_impl.h>
+ *
+ *
+ *  Cyclic Subsystem Implementation Overview
+ *  ----------------------------------------
+ *
+ *  The cyclic subsystem is designed to minimize interference between cyclics
+ *  on different CPUs.  Thus, all of the cyclic subsystem's data structures
+ *  hang off of a per-CPU structure, cyc_cpu.
+ *
+ *  Each cyc_cpu has a power-of-two sized array of cyclic structures (the
+ *  cyp_cyclics member of the cyc_cpu structure).  If cyclic_add() is called
+ *  and there does not exist a free slot in the cyp_cyclics array, the size of
+ *  the array will be doubled.  The array will never shrink.  Cyclics are
+ *  referred to by their index in the cyp_cyclics array, which is of type
+ *  cyc_index_t.
+ *
+ *  The cyclics are kept sorted by expiration time in the cyc_cpu's heap.  The
+ *  heap is keyed by cyclic expiration time, with parents expiring earlier
+ *  than their children.
+ *
+ *  Heap Management
+ *
+ *  The heap is managed primarily by cyclic_fire().  Upon entry, cyclic_fire()
+ *  compares the root cyclic's expiration time to the current time.  If the
+ *  expiration time is in the past, cyclic_expire() is called on the root
+ *  cyclic.  Upon return from cyclic_expire(), the cyclic's new expiration time
+ *  is derived by adding its interval to its old expiration time, and a
+ *  downheap operation is performed.  After the downheap, cyclic_fire()
+ *  examines the (potentially changed) root cyclic, repeating the
+ *  cyclic_expire()/add interval/cyclic_downheap() sequence until the root
+ *  cyclic has an expiration time in the future.  This expiration time
+ *  (guaranteed to be the earliest in the heap) is then communicated to the
+ *  backend via cyb_reprogram.  Optimal backends will next call cyclic_fire()
+ *  shortly after the root cyclic's expiration time.
+ *
+ *  To allow efficient, deterministic downheap operations, we implement the
+ *  heap as an array (the cyp_heap member of the cyc_cpu structure), with each



Home | Main Index | Thread Index | Old Index