Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src update cyclic module to the freebsd 8-stable version as of s...
details: https://anonhg.NetBSD.org/src/rev/10a36e9b597c
branches: trunk
changeset: 783029:10a36e9b597c
user: chs <chs%NetBSD.org@localhost>
date: Sun Dec 02 00:05:38 2012 +0000
description:
update cyclic module to the freebsd 8-stable version as of svn r219520.
diffstat:
external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c | 135 ------
external/cddl/osnet/dev/cyclic/cyclic.c | 354 ++++++++---------
external/cddl/osnet/dev/cyclic/i386/cyclic_machdep.c | 22 +-
external/cddl/osnet/sys/sys/cyclic.h | 94 +++-
external/cddl/osnet/sys/sys/cyclic_impl.h | 13 +-
sys/sys/dtrace_bsd.h | 4 +-
6 files changed, 257 insertions(+), 365 deletions(-)
diffs (truncated from 903 to 300 lines):
diff -r 59c5dbb550dd -r 10a36e9b597c external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c
--- a/external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c Sat Dec 01 21:37:41 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/* $NetBSD: cyclic_machdep.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
-
-/*-
- * 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 59c5dbb550dd -r 10a36e9b597c external/cddl/osnet/dev/cyclic/cyclic.c
--- a/external/cddl/osnet/dev/cyclic/cyclic.c Sat Dec 01 21:37:41 2012 +0000
+++ b/external/cddl/osnet/dev/cyclic/cyclic.c Sun Dec 02 00:05:38 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cyclic.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
+/* $NetBSD: cyclic.c,v 1.3 2012/12/02 00:05:38 chs Exp $ */
/*
* CDDL HEADER START
@@ -23,7 +23,7 @@
*
* 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 $
+ * $FreeBSD$
*
* This is a simplified version of the cyclic timer subsystem from
* OpenSolaris. In the FreeBSD version, we don't use interrupt levels.
@@ -475,73 +475,6 @@
(*handler)(arg);
}
-static void
-cyclic_enable_xcall(void *v)
-{
- cyc_xcallarg_t *argp = v;
- cyc_cpu_t *cpu = argp->cyx_cpu;
- cyc_backend_t *be = cpu->cyp_backend;
-
- be->cyb_enable(be->cyb_arg);
-}
-
-static void
-cyclic_enable(cyc_cpu_t *cpu)
-{
- cyc_backend_t *be = cpu->cyp_backend;
- cyc_xcallarg_t arg;
-
- arg.cyx_cpu = cpu;
-
- /* Cross call to the target CPU */
- be->cyb_xcall(be->cyb_arg, cpu->cyp_cpu, cyclic_enable_xcall, &arg);
-}
-
-static void
-cyclic_disable_xcall(void *v)
-{
- cyc_xcallarg_t *argp = v;
- cyc_cpu_t *cpu = argp->cyx_cpu;
- cyc_backend_t *be = cpu->cyp_backend;
-
- be->cyb_disable(be->cyb_arg);
-}
-
-static void
-cyclic_disable(cyc_cpu_t *cpu)
-{
- cyc_backend_t *be = cpu->cyp_backend;
- cyc_xcallarg_t arg;
-
- arg.cyx_cpu = cpu;
-
- /* Cross call to the target CPU */
- be->cyb_xcall(be->cyb_arg, cpu->cyp_cpu, cyclic_disable_xcall, &arg);
-}
-
-static void
-cyclic_reprogram_xcall(void *v)
-{
- cyc_xcallarg_t *argp = v;
- cyc_cpu_t *cpu = argp->cyx_cpu;
- cyc_backend_t *be = cpu->cyp_backend;
-
- be->cyb_reprogram(be->cyb_arg, argp->cyx_exp);
-}
-
-static void
-cyclic_reprogram(cyc_cpu_t *cpu, hrtime_t exp)
-{
- cyc_backend_t *be = cpu->cyp_backend;
- cyc_xcallarg_t arg;
-
- arg.cyx_cpu = cpu;
- arg.cyx_exp = exp;
-
- /* Cross call to the target CPU */
- be->cyb_xcall(be->cyb_arg, cpu->cyp_cpu, cyclic_reprogram_xcall, &arg);
-}
-
/*
* cyclic_fire(cpu_t *)
*
@@ -572,17 +505,15 @@
cyclic_fire(cpu_t *c)
{
cyc_cpu_t *cpu = c->cpu_cyclic;
-
- mtx_lock_spin(&cpu->cyp_mtx);
-
+ cyc_backend_t *be = cpu->cyp_backend;
cyc_index_t *heap = cpu->cyp_heap;
cyclic_t *cyclic, *cyclics = cpu->cyp_cyclics;
+ void *arg = be->cyb_arg;
hrtime_t now = gethrtime();
hrtime_t exp;
if (cpu->cyp_nelems == 0) {
/* This is a spurious fire. */
- mtx_unlock_spin(&cpu->cyp_mtx);
return;
}
@@ -633,63 +564,34 @@
* Now we have a cyclic in the root slot which isn't in the past;
* reprogram the interrupt source.
*/
- cyclic_reprogram(cpu, exp);
-
- mtx_unlock_spin(&cpu->cyp_mtx);
+ be->cyb_reprogram(arg, exp);
}
-/*
- * cyclic_expand() will cross call onto the CPU to perform the actual
- * expand operation.
- */
static void
-cyclic_expand(cyc_cpu_t *cpu)
+cyclic_expand_xcall(cyc_xcallarg_t *arg)
{
- cyc_index_t new_size, old_size, i;
- cyc_index_t *new_heap, *old_heap;
- cyclic_t *new_cyclics, *old_cyclics;
+ cyc_cpu_t *cpu = arg->cyx_cpu;
+ cyc_index_t new_size = arg->cyx_size, size = cpu->cyp_size, i;
+ cyc_index_t *new_heap = arg->cyx_heap;
+ cyclic_t *cyclics = cpu->cyp_cyclics, *new_cyclics = arg->cyx_cyclics;
- ASSERT(MUTEX_HELD(&cpu_lock));
-
- if ((new_size = ((old_size = cpu->cyp_size) << 1)) == 0)
- new_size = CY_DEFAULT_PERCPU;
+ /* Disable preemption and interrupts. */
+ mtx_lock_spin(&cpu->cyp_mtx);
/*
- * Check that the new_size is a power of 2.
+ * Assert that the new size is a power of 2.
*/
- ASSERT(((new_size - 1) & new_size) == 0);
-
- /* Unlock the mutex while allocating memory so we can wait... */
- mtx_unlock_spin(&cpu->cyp_mtx);
-
- new_heap = malloc(sizeof(cyc_index_t) * new_size, M_CYCLIC, M_WAITOK);
- new_cyclics = malloc(sizeof(cyclic_t) * new_size, M_CYCLIC, M_ZERO | M_WAITOK);
-
- /* Grab the lock again now we've got the memory... */
- mtx_lock_spin(&cpu->cyp_mtx);
+ ASSERT((new_size & (new_size - 1)) == 0);
+ ASSERT(new_size == (size << 1));
Home |
Main Index |
Thread Index |
Old Index