Compatibility stuff for DTrace.

This commit is contained in:
jb 2008-05-22 08:33:24 +00:00
parent fcb43193c1
commit 6b3503f4ce
6 changed files with 135 additions and 89 deletions

View File

@ -32,6 +32,10 @@
#include <sys/types.h>
#include <machine/atomic.h>
#define casptr(_a, _b, _c) \
atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr_t) (_c))
#define cas32 atomic_cmpset_32
#ifndef __LP64__
extern void atomic_add_64(volatile uint64_t *target, int64_t delta);
extern void *atomic_cas_ptr(volatile void *target, void *cmp, void *newval);

View File

@ -44,44 +44,8 @@ extern "C" {
#define CE_PANIC 3 /* panic */
#define CE_IGNORE 4 /* print nothing */
static __inline void
vcmn_err(int ce, const char *fmt, va_list adx)
{
char buf[256];
switch (ce) {
case CE_CONT:
snprintf(buf, sizeof(buf), "ZFS(cont): %s\n", fmt);
break;
case CE_NOTE:
snprintf(buf, sizeof(buf), "ZFS: NOTICE: %s\n", fmt);
break;
case CE_WARN:
snprintf(buf, sizeof(buf), "ZFS: WARNING: %s\n", fmt);
break;
case CE_PANIC:
snprintf(buf, sizeof(buf), "ZFS(panic): %s\n", fmt);
break;
case CE_IGNORE:
break;
default:
panic("unknown severity level");
}
if (ce != CE_IGNORE)
vprintf(buf, adx);
if (ce == CE_PANIC)
panic("ZFS");
}
static __inline void
cmn_err(int ce, const char *fmt, ...)
{
va_list adx;
va_start(adx, fmt);
vcmn_err(ce, fmt, adx);
va_end(adx);
}
void cmn_err(int, const char *, ...);
void vcmn_err(int, const char *, va_list);
#ifdef __cplusplus
}

View File

@ -30,8 +30,30 @@
#define _COMPAT_OPENSOLARIS_SYS_CPUVAR_H
#include <sys/mutex.h>
#include <sys/cpuvar_defs.h>
#ifdef _KERNEL
struct cyc_cpu;
typedef struct {
int cpuid;
struct cyc_cpu *cpu_cyclic;
uint32_t cpu_flags;
uint_t cpu_intr_actv;
uintptr_t cpu_profile_pc;
uintptr_t cpu_profile_upc;
uintptr_t cpu_dtrace_caller; /* DTrace: caller, if any */
hrtime_t cpu_dtrace_chillmark; /* DTrace: chill mark time */
hrtime_t cpu_dtrace_chilled; /* DTrace: total chill time */
} solaris_cpu_t;
/* Some code may choose to redefine this if pcpu_t would be more useful. */
#define cpu_t solaris_cpu_t
#define cpu_id cpuid
extern solaris_cpu_t solaris_cpu[];
#define CPU_CACHE_COHERENCE_SIZE 64
/*
@ -53,33 +75,50 @@ typedef struct cpu_core {
} cpu_core_t;
extern cpu_core_t cpu_core[];
extern kmutex_t cpu_lock;
#endif /* _KERNEL */
/*
* DTrace flags.
* Flags in the CPU structure.
*
* These are protected by cpu_lock (except during creation).
*
* Offlined-CPUs have three stages of being offline:
*
* CPU_ENABLE indicates that the CPU is participating in I/O interrupts
* that can be directed at a number of different CPUs. If CPU_ENABLE
* is off, the CPU will not be given interrupts that can be sent elsewhere,
* but will still get interrupts from devices associated with that CPU only,
* and from other CPUs.
*
* CPU_OFFLINE indicates that the dispatcher should not allow any threads
* other than interrupt threads to run on that CPU. A CPU will not have
* CPU_OFFLINE set if there are any bound threads (besides interrupts).
*
* CPU_QUIESCED is set if p_offline was able to completely turn idle the
* CPU and it will not have to run interrupt threads. In this case it'll
* stay in the idle loop until CPU_QUIESCED is turned off.
*
* CPU_FROZEN is used only by CPR to mark CPUs that have been successfully
* suspended (in the suspend path), or have yet to be resumed (in the resume
* case).
*
* On some platforms CPUs can be individually powered off.
* The following flags are set for powered off CPUs: CPU_QUIESCED,
* CPU_OFFLINE, and CPU_POWEROFF. The following flags are cleared:
* CPU_RUNNING, CPU_READY, CPU_EXISTS, and CPU_ENABLE.
*/
#define CPU_DTRACE_NOFAULT 0x0001 /* Don't fault */
#define CPU_DTRACE_DROP 0x0002 /* Drop this ECB */
#define CPU_DTRACE_BADADDR 0x0004 /* DTrace fault: bad address */
#define CPU_DTRACE_BADALIGN 0x0008 /* DTrace fault: bad alignment */
#define CPU_DTRACE_DIVZERO 0x0010 /* DTrace fault: divide by zero */
#define CPU_DTRACE_ILLOP 0x0020 /* DTrace fault: illegal operation */
#define CPU_DTRACE_NOSCRATCH 0x0040 /* DTrace fault: out of scratch */
#define CPU_DTRACE_KPRIV 0x0080 /* DTrace fault: bad kernel access */
#define CPU_DTRACE_UPRIV 0x0100 /* DTrace fault: bad user access */
#define CPU_DTRACE_TUPOFLOW 0x0200 /* DTrace fault: tuple stack overflow */
#if defined(__sparc)
#define CPU_DTRACE_FAKERESTORE 0x0400 /* pid provider hint to getreg */
#endif
#define CPU_DTRACE_ENTRY 0x0800 /* pid provider hint to ustack() */
#define CPU_DTRACE_BADSTACK 0x1000 /* DTrace fault: bad stack */
#define CPU_DTRACE_FAULT (CPU_DTRACE_BADADDR | CPU_DTRACE_BADALIGN | \
CPU_DTRACE_DIVZERO | CPU_DTRACE_ILLOP | \
CPU_DTRACE_NOSCRATCH | CPU_DTRACE_KPRIV | \
CPU_DTRACE_UPRIV | CPU_DTRACE_TUPOFLOW | \
CPU_DTRACE_BADSTACK)
#define CPU_DTRACE_ERROR (CPU_DTRACE_FAULT | CPU_DTRACE_DROP)
#define CPU_RUNNING 0x001 /* CPU running */
#define CPU_READY 0x002 /* CPU ready for cross-calls */
#define CPU_QUIESCED 0x004 /* CPU will stay in idle */
#define CPU_EXISTS 0x008 /* CPU is configured */
#define CPU_ENABLE 0x010 /* CPU enabled for interrupts */
#define CPU_OFFLINE 0x020 /* CPU offline via p_online */
#define CPU_POWEROFF 0x040 /* CPU is powered off */
#define CPU_FROZEN 0x080 /* CPU is frozen via CPR suspend */
#define CPU_SPARE 0x100 /* CPU offline available for use */
#define CPU_FAULTED 0x200 /* CPU offline diagnosed faulty */
typedef enum {
CPU_INIT,

View File

@ -1,31 +1,31 @@
/*
* Copyright (C) 2007 John Birrell <jb@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$
*
*/
/*
* 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

View File

@ -32,7 +32,6 @@
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/vmem.h>
#include <vm/uma.h>
#include <vm/vm.h>
@ -54,6 +53,8 @@ typedef struct kmem_cache {
void *kc_private;
} kmem_cache_t;
#define vmem_t void
void *zfs_kmem_alloc(size_t size, int kmflags);
void zfs_kmem_free(void *buf, size_t size);
uint64_t kmem_size(void);

View File

@ -32,8 +32,6 @@
#include_next <sys/pcpu.h>
typedef struct pcpu cpu_t;
#define cpu_id pc_cpuid
typedef struct pcpu pcpu_t;
#endif