PERFORCE change 132447 for review

John Birrell jb at FreeBSD.org
Thu Jan 3 15:56:55 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=132447

Change 132447 by jb at jb_freebsd1 on 2008/01/03 23:56:36

	Remove the OpenSolaris version of the cyclic subsystem in favour of a
	reduced functionality, FreeBSD-specific version.
	
	The cyclic requirement in FreeBSD is currently limited to the 'dtrace' module
	and the DTrace 'profile' provider. The latter needs to be able to fire
	timesr on one CPU or all CPUs.
	
	OpenSolaris uses the cyclic timer subsystem for a lot more than this, so
	obviously it's feature set is very much larger.
	
	In FreeBSD, we don't have the provision to enable and disable CPUs. We don't
	need to suspend and resume the cyclic timer subsystem. We don't need to
	juggle cyclics from one CPU to another. We don't have the concept for CPU
	partitions.
	
	Of course, one day we could add all that. :-)
	
	The area where the design of the OpenSolaris cyclic subsystem really bites
	us in it's basis on interrupt levels, processor levels or protection levels
	or whatever you choose to call them. They are all CPU-specific, so the
	OpenSolaris cyclic code tends to cross call over to the target CPU to do
	things that it needs to protect by setting a spl/ipl.
	
	In FreeBSD, we have a SMP model which uses locking(9) functions in place
	of spl/ipl etc. As a result, locking the cyclic operation is better done in
	a different way.
	
	For the FreeBSD-specific cyclic timer, I have removed all concept of
	interrupt levels. This means that much of the complexity of the OpenSolaris
	system is removed, perhaps with a performance penalty. I'm not sure of that.
	in OpenSolaris, they got to some length to avoid locking in the most
	executed path (adding and firing).
	
	For FreeBSD I have added a spinlock to each cyclic CPU structure. The addition,
	removal and firing of timers all lock the CPU specific spinlock. I assume this
	has a low performance impact because there should be little lock contention.
	As a result, the resizing of the buffers for a target CPU can occur on any
	CPU. The only time that a cross CPU call is required is to notify the target
	CPU that it's backend timer has been reprogrammed, enabled or disabled.
	
	Since the per-CPU locks are spinlocks, this limits the types of operations
	that a timer handler can perform. Allocating memory with wait is an obvious
	one which isn't allowed. I'll have to wait and see if that works our OK
	for the couple of uses listed above.
	
	Note that Apple uses their own kernel timers rather than a port of the
	cyclic device in their DTrace implementation.

Affected files ...

.. //depot/projects/dtrace/src/sys/cddl/amd64/cyclic_machdep.c#7 edit
.. //depot/projects/dtrace/src/sys/cddl/kern/cyclic.c#6 add
.. //depot/projects/dtrace/src/sys/cddl/kern/kern_cyclic.c#10 delete
.. //depot/projects/dtrace/src/sys/compat/opensolaris/sys/cyclic.h#2 edit
.. //depot/projects/dtrace/src/sys/compat/opensolaris/sys/cyclic_impl.h#2 edit
.. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/os/cyclic.c#14 delete
.. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/cyclic.h#9 delete
.. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/cyclic_impl.h#4 delete
.. //depot/projects/dtrace/src/sys/modules/cyclic/Makefile#7 edit

Differences ...

==== //depot/projects/dtrace/src/sys/cddl/amd64/cyclic_machdep.c#7 (text+ko) ====

@@ -26,65 +26,23 @@
  *
  */
 
-static cyb_arg_t configure(cpu_t *);
-static void unconfigure(cyb_arg_t);
 static void enable(cyb_arg_t);
 static void disable(cyb_arg_t);
 static void reprogram(cyb_arg_t, hrtime_t);
-static void softint(cyb_arg_t, cyc_level_t);
-static cyc_cookie_t set_level(cyb_arg_t, cyc_level_t);
-static void restore_level(cyb_arg_t, cyc_cookie_t);
 static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *);
-static void suspend(cyb_arg_t);
-static void resume(cyb_arg_t);
 static void cyclic_clock(void);
 
 static cyc_backend_t	be	= {
-	configure,
-	unconfigure,
+	NULL,		/* cyb_configure */
+	NULL,		/* cyb_unconfigure */
 	enable,
 	disable,
 	reprogram,
-	softint,
-	set_level,
-	restore_level,
 	xcall,
-	suspend,
-	resume,
 	NULL		/* cyb_arg_t cyb_arg */
 };
 
-static void	*cyclic_lock_ih;
-static void	*cyclic_low_ih;
-
-/*
- * Software interrupt callbacks.
- */
 static void
-cyclic_swi_low(void *dummy)
-{
-	cpu_t *c = &solaris_cpu[curcpu];
-
-	c->cpu_intr_actv |= (1 << CY_LOW_LEVEL);
-
-	cyclic_softint(c, CY_LOW_LEVEL);
-
-	c->cpu_intr_actv &= ~(1 << CY_LOW_LEVEL);
-}
-
-static void
-cyclic_swi_lock(void *dummy)
-{
-	cpu_t *c = &solaris_cpu[curcpu];
-
-	c->cpu_intr_actv |= (1 << CY_LOCK_LEVEL);
-
-	cyclic_softint(c, CY_LOCK_LEVEL);
-
-	c->cpu_intr_actv &= ~(1 << CY_LOCK_LEVEL);
-}
-
-static void
 cyclic_ap_start(void *dummy)
 {
 	/* Initialise the rest of the CPUs. */
@@ -99,20 +57,8 @@
 static void
 cyclic_machdep_init(void)
 {
-	/*
-	 * Add a software interrupt handlers for low priority cyclic
-	 * events.
-	 */
-	swi_add(&clk_intr_event, "low cyclic", cyclic_swi_low, NULL,
-	    SWI_TQ, 0, &cyclic_low_ih);
-	swi_add(&clk_intr_event, "lock cyclic", cyclic_swi_lock, NULL,
-	    SWI_TQ_FAST, 0, &cyclic_lock_ih);
-
-	/*
-	 * Register the cyclic backend. Note that the resolution argument
-	 * is only used on Solaris, so we don't bother with that.
-	 */
-	cyclic_init(&be, 0);
+	/* Register the cyclic backend. */
+	cyclic_init(&be);
 }
 
 static void
@@ -120,27 +66,12 @@
 {
 	int i;
 
-	for (i = 0; i < mp_maxid; 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();
-
-	/* Remove the software interrupt handlers. */
-	swi_remove(cyclic_low_ih);
-	swi_remove(cyclic_lock_ih);
-}
-
-static cyb_arg_t configure(cpu_t *c)
-{
-
-	return (NULL);
-}
-
-static void unconfigure(cyb_arg_t arg)
-{
-
 }
 
 static void enable(cyb_arg_t arg)
@@ -155,38 +86,10 @@
 	lapic_cyclic_clock_func[curcpu] = NULL;
 }
 
-static void reprogram(cyb_arg_t arg, hrtime_t interval)
+static hrtime_t exp_due[SMP_MAXCPU];
+static void reprogram(cyb_arg_t arg, hrtime_t exp)
 {
-	/* XXX */
-}
-
-static void softint(cyb_arg_t arg, cyc_level_t level)
-{
-	/*
-	 * Schedule the software interrupt processing at the
-	 * requested level.
-	 */
-	switch (level) {
-	case CY_LOW_LEVEL:
-		swi_sched(cyclic_low_ih, 0);
-		break;
-	case CY_LOCK_LEVEL:
-		swi_sched(cyclic_lock_ih, 0);
-		break;
-	default:
-		printf("%s:%s(%d): unexpected soft level %d\n",__FUNCTION__,__FILE__,__LINE__,level);
-		break;
-	}
-}
-
-static cyc_cookie_t set_level(cyb_arg_t arg, cyc_level_t level)
-{
-	return (intr_disable());
-}
-
-static void restore_level(cyb_arg_t arg, cyc_cookie_t cookie)
-{
-	intr_restore(cookie);
+	exp_due[curcpu] = exp;
 }
 
 static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param)
@@ -202,11 +105,3 @@
 		    func, NULL, param);
 }
 
-static void suspend(cyb_arg_t arg)
-{
-}
-
-static void resume(cyb_arg_t arg)
-{
-}
-

==== //depot/projects/dtrace/src/sys/compat/opensolaris/sys/cyclic.h#2 (text+ko) ====

@@ -1,31 +1,31 @@
 /*
- * Copyright (C) 2007 John Birrell <jb at freebsd.org>
- * All rights reserved.
- * 
- * 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.
+ * 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
  *
- * $FreeBSD: src/sys/compat/opensolaris/sys/cyclic.h,v 1.1 2007/11/28 21:50:40 jb Exp $
+ * $FreeBSD$
  *
  */
+/*
+ * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
 
 #ifndef _COMPAT_OPENSOLARIS_SYS_CYCLIC_H_
 #define _COMPAT_OPENSOLARIS_SYS_CYCLIC_H_
@@ -34,6 +34,46 @@
 typedef	void	cpu_t;
 #endif
 
-#include_next <sys/cyclic.h>
+
+#ifndef _ASM
+#include <sys/time.h>
+#include <sys/cpuvar.h>
+#endif /* !_ASM */
+
+#ifndef _ASM
+
+typedef uintptr_t cyclic_id_t;
+typedef int cyc_index_t;
+typedef uint16_t cyc_level_t;
+typedef void (*cyc_func_t)(void *);
+typedef void *cyb_arg_t;
+
+#define	CYCLIC_NONE		((cyclic_id_t)0)
+
+typedef struct cyc_handler {
+	cyc_func_t cyh_func;
+	void *cyh_arg;
+} cyc_handler_t;
+
+typedef struct cyc_time {
+	hrtime_t cyt_when;
+	hrtime_t cyt_interval;
+} cyc_time_t;
+
+typedef struct cyc_omni_handler {
+	void (*cyo_online)(void *, cpu_t *, cyc_handler_t *, cyc_time_t *);
+	void (*cyo_offline)(void *, cpu_t *, void *);
+	void *cyo_arg;
+} cyc_omni_handler_t;
+
+#ifdef _KERNEL
+
+cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
+cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *);
+void cyclic_remove(cyclic_id_t);
+
+#endif /* _KERNEL */
+
+#endif /* !_ASM */
 
 #endif

==== //depot/projects/dtrace/src/sys/compat/opensolaris/sys/cyclic_impl.h#2 (text+ko) ====

@@ -1,41 +1,305 @@
 /*
- * Copyright (C) 2007 John Birrell <jb at freebsd.org>
- * All rights reserved.
- * 
- * 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.
+ * 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
  *
- * $FreeBSD: src/sys/compat/opensolaris/sys/cyclic.h,v 1.1 2007/11/28 21:50:40 jb Exp $
+ * $FreeBSD$
  *
  */
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
 
 #ifndef _COMPAT_OPENSOLARIS_SYS_CYCLIC_IMPL_H_
 #define _COMPAT_OPENSOLARIS_SYS_CYCLIC_IMPL_H_
 
-#include <sys/types.h>
-#include <machine/atomic.h>
-#include <sys/lock.h>
-#include <sys/sx.h>
-#include <sys/sema.h>
+#include <sys/cyclic.h>
+
+/*
+ *  Cyclic Subsystem Backend-supplied Interfaces
+ *  --------------------------------------------
+ *
+ *  0  Background
+ *
+ *    The design, implementation and interfaces of the cyclic subsystem are
+ *    covered in detail in block comments in the implementation.  This
+ *    comment covers the interface from the cyclic subsystem into the cyclic
+ *    backend.  The backend is specified by a structure of function pointers
+ *    defined below.
+ *
+ *  1  Overview
+ *
+ *      cyb_configure()      <-- Configures the backend on the specified CPU
+ *      cyb_unconfigure()    <-- Unconfigures the backend
+ *      cyb_enable()         <-- Enables the CY_HIGH_LEVEL interrupt source
+ *      cyb_disable()        <-- Disables the CY_HIGH_LEVEL interrupt source
+ *      cyb_reprogram()      <-- Reprograms the CY_HIGH_LEVEL interrupt source
+ *      cyb_xcall()          <-- Cross calls to the specified CPU
+ *
+ *  2  cyb_arg_t cyb_configure(cpu_t *)
+ *
+ *  2.1  Overview
+ *
+ *    cyb_configure() should configure the specified CPU for cyclic operation.
+ *
+ *  2.2  Arguments and notes
+ *
+ *    cyb_configure() should initialize any backend-specific per-CPU
+ *    structures for the specified CPU.  cyb_configure() will be called for
+ *    each CPU (including the boot CPU) during boot.  If the platform
+ *    supports dynamic reconfiguration, cyb_configure() will be called for
+ *    new CPUs as they are configured into the system.
+ *
+ *  2.3  Return value
+ *
+ *    cyb_configure() is expected to return a cookie (a cyb_arg_t, which is
+ *    of type void *) which will be used as the first argument for all future
+ *    cyclic calls into the backend on the specified CPU.
+ *
+ *  2.4  Caller's context
+ *
+ *    cpu_lock will be held.  The caller's CPU is unspecified, and may or
+ *    may not be the CPU specified to cyb_configure().
+ *
+ *  3  void cyb_unconfigure(cyb_arg_t arg)
+ *
+ *  3.1  Overview
+ *
+ *    cyb_unconfigure() should unconfigure the specified backend.
+ *
+ *  3.2  Arguments and notes
+ *
+ *    The only argument to cyb_unconfigure() is a cookie as returned from
+ *    cyb_configure().
+ *
+ *    cyb_unconfigure() should free any backend-specific per-CPU structures
+ *    for the specified backend.  cyb_unconfigure() will _only_ be called on
+ *    platforms which support dynamic reconfiguration.  If the platform does
+ *    not support dynamic reconfiguration, cyb_unconfigure() may panic.
+ *
+ *    After cyb_unconfigure() returns, the backend must not call cyclic_fire()
+ *    on the corresponding CPU; doing so will result in a bad trap.
+ *
+ *  3.3  Return value
+ *
+ *    None.
+ *
+ *  3.4  Caller's context
+ *
+ *    cpu_lock will be held.  The caller's CPU is unspecified, and may or
+ *    may not be the CPU specified to cyb_unconfigure().  The specified
+ *    CPU is guaranteed to exist at the time cyb_unconfigure() is called.
+ *    The cyclic subsystem is guaranteed to be suspended when cyb_unconfigure()
+ *    is called, and interrupts are guaranteed to be disabled.
+ *
+ *  4  void cyb_enable(cyb_arg_t arg)
+ *
+ *  4.1  Overview
+ *
+ *    cyb_enable() should enable the CY_HIGH_LEVEL interrupt source on
+ *    the specified backend.
+ *
+ *  4.2  Arguments and notes
+ *
+ *    The only argument to cyb_enable() is a backend cookie as returned from
+ *    cyb_configure().
+ *
+ *    cyb_enable() will only be called if a) the specified backend has never
+ *    been enabled or b) the specified backend has been explicitly disabled with
+ *    cyb_disable().  In either case, cyb_enable() will only be called if
+ *    the cyclic subsystem wishes to add a cyclic to the CPU corresponding
+ *    to the specified backend.  cyb_enable() will be called before
+ *    cyb_reprogram() for a given backend.
+ *
+ *    cyclic_fire() should not be called on a CPU which has not had its backend
+ *    explicitly cyb_enable()'d, but to do so does not constitute fatal error.
+ *
+ *  4.3  Return value
+ *
+ *    None.
+ *
+ *  4.4  Caller's context
+ *
+ *    cyb_enable() will only be called from CY_HIGH_LEVEL context on the CPU
+ *    corresponding to the specified backend.
+ *
+ *  5  void cyb_disable(cyb_arg_t arg)
+ *
+ *  5.1  Overview
+ *
+ *    cyb_disable() should disable the CY_HIGH_LEVEL interrupt source on
+ *    the specified backend.
+ *
+ *  5.2  Arguments and notes
+ *
+ *    The only argument to cyb_disable() is a backend cookie as returned from
+ *    cyb_configure().
+ *
+ *    cyb_disable() will only be called on backends which have been previously
+ *    been cyb_enable()'d.  cyb_disable() will be called when all cyclics have
+ *    been juggled away or removed from a cyb_enable()'d CPU.
+ *
+ *    cyclic_fire() should not be called on a CPU which has had its backend
+ *    explicitly cyb_disable()'d, but to do so does not constitute fatal
+ *    error.  cyb_disable() is thus not required to check for a pending
+ *    CY_HIGH_LEVEL interrupt.
+ *
+ *  5.3  Return value
+ *
+ *    None.
+ *
+ *  5.4  Caller's context
+ *
+ *    cyb_disable() will only be called from CY_HIGH_LEVEL context on the CPU
+ *    corresponding to the specified backend.
+ *
+ *  6  void cyb_reprogram(cyb_arg_t arg, hrtime_t time)
+ *
+ *  6.1  Overview
+ *
+ *    cyb_reprogram() should reprogram the CY_HIGH_LEVEL interrupt source
+ *    to fire at the absolute time specified.
+ *
+ *  6.2  Arguments and notes
+ *
+ *    The first argument to cyb_reprogram() is a backend cookie as returned from
+ *    cyb_configure().
+ *
+ *    The second argument is an absolute time at which the CY_HIGH_LEVEL
+ *    interrupt should fire.  The specified time _may_ be in the past (albeit
+ *    the very recent past).  If this is the case, the backend should generate
+ *    a CY_HIGH_LEVEL interrupt as soon as possible.
+ *
+ *    The platform should not assume that cyb_reprogram() will be called with
+ *    monotonically increasing values.
+ *
+ *    If the platform does not allow for interrupts at arbitrary times in the
+ *    future, cyb_reprogram() may do nothing -- as long as cyclic_fire() is
+ *    called periodically at CY_HIGH_LEVEL.  While this is clearly suboptimal
+ *    (cyclic granularity will be bounded by the length of the period between
+ *    cyclic_fire()'s), it allows the cyclic subsystem to be implemented on
+ *    inferior hardware.
+ *
+ *  6.3  Return value
+ *
+ *     None.
+ *
+ *  6.4  Caller's context
+ *
+ *    cyb_reprogram() will only be called from CY_HIGH_LEVEL context on the CPU
+ *    corresponding to the specified backend.
+ *
+ *  10  cyb_xcall(cyb_arg_t arg, cpu_t *, void(*func)(void *), void *farg)
+ *
+ *  10.1  Overview
+ *
+ *    cyb_xcall() should execute the specified function on the specified CPU.
+ *
+ *  10.2  Arguments and notes
+ *
+ *    The first argument to cyb_restore_level() is a backend cookie as returned
+ *    from cyb_configure().  The second argument is a CPU on which the third
+ *    argument, a function pointer, should be executed.  The fourth argument,
+ *    a void *, should be passed as the argument to the specified function.
+ *
+ *    cyb_xcall() must provide exactly-once semantics.  If the specified
+ *    function is called more than once, or not at all, the cyclic subsystem
+ *    will become internally inconsistent.  The specified function must be
+ *    be executed on the specified CPU, but may be executed in any context
+ *    (any interrupt context or kernel context).
+ *
+ *    cyb_xcall() cannot block.  Any resources which cyb_xcall() needs to
+ *    acquire must thus be protected by synchronization primitives which
+ *    never require the caller to block.
+ *
+ *  10.3  Return value
+ *
+ *    None.
+ *
+ *  10.4  Caller's context
+ *
+ *    cpu_lock will be held and kernel preemption may be disabled.  The caller
+ *    may be unable to block, giving rise to the constraint outlined in
+ *    10.2, above.
+ *
+ */
+typedef struct cyc_backend {
+	cyb_arg_t (*cyb_configure)(cpu_t *);
+	void (*cyb_unconfigure)(cyb_arg_t);
+	void (*cyb_enable)(cyb_arg_t);
+	void (*cyb_disable)(cyb_arg_t);
+	void (*cyb_reprogram)(cyb_arg_t, hrtime_t);
+	void (*cyb_xcall)(cyb_arg_t, cpu_t *, cyc_func_t, void *);
+	cyb_arg_t cyb_arg;
+} cyc_backend_t;
+
+#define	CYF_FREE		0x0001
+
+typedef struct cyclic {
+	hrtime_t cy_expire;
+	hrtime_t cy_interval;
+	void (*cy_handler)(void *);
+	void *cy_arg;
+	uint16_t cy_flags;
+} cyclic_t;
+
+typedef struct cyc_cpu {
+	cpu_t *cyp_cpu;
+	cyc_index_t *cyp_heap;
+	cyclic_t *cyp_cyclics;
+	cyc_index_t cyp_nelems;
+	cyc_index_t cyp_size;
+	cyc_backend_t *cyp_backend;
+	struct mtx cyp_mtx;
+} cyc_cpu_t;
+
+typedef struct cyc_omni_cpu {
+	cyc_cpu_t *cyo_cpu;
+	cyc_index_t cyo_ndx;
+	void *cyo_arg;
+	struct cyc_omni_cpu *cyo_next;
+} cyc_omni_cpu_t;
+
+typedef struct cyc_id {
+	cyc_cpu_t *cyi_cpu;
+	cyc_index_t cyi_ndx;
+	struct cyc_id *cyi_prev;
+	struct cyc_id *cyi_next;
+	cyc_omni_handler_t cyi_omni_hdlr;
+	cyc_omni_cpu_t *cyi_omni_list;
+} cyc_id_t;
+
+typedef struct cyc_xcallarg {
+	cyc_cpu_t *cyx_cpu;
+	hrtime_t cyx_exp;
+	volatile int cyx_wait;
+} cyc_xcallarg_t;
+
+#define	CY_DEFAULT_PERCPU	1
+#define	CY_PASSIVE_LEVEL	-1
+
+#define	CY_WAIT			0
+#define	CY_NOWAIT		1
 
-#include_next <sys/cyclic_impl.h>
+#define	CYC_HEAP_PARENT(ndx)		(((ndx) - 1) >> 1)
+#define	CYC_HEAP_RIGHT(ndx)		(((ndx) + 1) << 1)
+#define	CYC_HEAP_LEFT(ndx)		((((ndx) + 1) << 1) - 1)
 
 #endif

==== //depot/projects/dtrace/src/sys/modules/cyclic/Makefile#7 (text+ko) ====

@@ -1,17 +1,15 @@
 # $FreeBSD#
 
-.PATH: ${.CURDIR}/../../contrib/opensolaris/uts/common/os
-.PATH: ${.CURDIR}/../../compat/opensolaris/kern
+.PATH: ${.CURDIR}/../../cddl/kern
 
 KMOD=		cyclic
 SRCS=		cyclic.c
 		
-SRCS+=		bus_if.h device_if.h vnode_if.h
+SRCS+=		vnode_if.h
 
 CFLAGS+=	-I${.CURDIR}/../../compat/opensolaris			\
 		-I${.CURDIR}/../../contrib/opensolaris/uts/common	\
 		-I${.CURDIR}/../..					\
-		-I${.CURDIR}/../../cddl/kern				\
 		-I${.CURDIR}/../../cddl/${MACHINE_ARCH}
 
 CFLAGS+=	-DDEBUG=1


More information about the p4-projects mailing list