summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r--usr/src/uts/common/sys/Makefile1
-rw-r--r--usr/src/uts/common/sys/clock_impl.h125
-rw-r--r--usr/src/uts/common/sys/condvar.h31
-rw-r--r--usr/src/uts/common/sys/cpucaps_impl.h6
-rw-r--r--usr/src/uts/common/sys/cpuvar.h2
-rw-r--r--usr/src/uts/common/sys/fcoe/fcoe_common.h2
-rw-r--r--usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h7
-rw-r--r--usr/src/uts/common/sys/sunddi.h3
-rw-r--r--usr/src/uts/common/sys/systm.h2
-rw-r--r--usr/src/uts/common/sys/time.h3
10 files changed, 158 insertions, 24 deletions
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile
index 9ffc1d4a44..63c569a5c1 100644
--- a/usr/src/uts/common/sys/Makefile
+++ b/usr/src/uts/common/sys/Makefile
@@ -105,6 +105,7 @@ CHKHDRS= \
cladm.h \
class.h \
clconf.h \
+ clock_impl.h \
cmlb.h \
cmn_err.h \
compress.h \
diff --git a/usr/src/uts/common/sys/clock_impl.h b/usr/src/uts/common/sys/clock_impl.h
new file mode 100644
index 0000000000..85f26a16c6
--- /dev/null
+++ b/usr/src/uts/common/sys/clock_impl.h
@@ -0,0 +1,125 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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
+ */
+
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_CLOCK_IMPL_H
+#define _SYS_CLOCK_IMPL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if (defined(_KERNEL) || defined(_KMEMUSER))
+#include <sys/types.h>
+#include <sys/cpuvar.h>
+#include <sys/cyclic.h>
+#include <sys/time.h>
+
+/*
+ * Default clock rate in Hz.
+ */
+#define HZ_DEFAULT 100
+
+/*
+ * Thresholds over which we switch between event and cyclic driven lbolt. The
+ * current default values were derived experimentally and will keep the
+ * system on event driven mode when idle and respond to activity around the
+ * lbolt DDI functions by switching to cyclic mode.
+ */
+#define LBOLT_THRESH_CALLS (75)
+#define LBOLT_THRESH_INTERVAL (1)
+
+/*
+ * Both lbolt_cpu_t and lbolt_info_t are cache line sized and aligned,
+ * please take that in consideration if modifying these.
+ */
+typedef struct lbolt_cpu {
+ int64_t lbc_counter; /* number of calls to the DDI lbolt routines */
+ int64_t lbc_cnt_start; /* beggining of the cnt interval (in ticks) */
+ char lbc_pad[CPU_CACHE_COHERENCE_SIZE - (2 * sizeof (int64_t))];
+} lbolt_cpu_t;
+
+typedef struct lbolt_info {
+ cyclic_id_t lbi_cyclic_id; /* lbolt's cyclic id */
+ int64_t lbi_internal; /* lbolt source when on cyclic mode */
+ int64_t lbi_debug_time; /* time spent in the debugger */
+ int64_t lbi_debug_ts; /* last time we dropped into kmdb */
+ int64_t lbi_thresh_calls; /* max calls per interval */
+ int64_t lbi_thresh_interval; /* interval window for the # of calls */
+ uint32_t lbi_token; /* synchronize cyclic mode switch */
+ boolean_t lbi_cyc_deactivate; /* lbolt_cyclic self deactivation */
+ int64_t lbi_cyc_deac_start; /* deactivation interval */
+} lbolt_info_t;
+
+extern int64_t lbolt_event_driven(void);
+extern int64_t lbolt_cyclic_driven(void);
+extern int64_t (*lbolt_hybrid)(void);
+extern uint_t lbolt_ev_to_cyclic(caddr_t, caddr_t);
+
+extern void lbolt_softint_add(void);
+extern void lbolt_softint_post(void);
+
+extern void lbolt_debug_entry(void);
+extern void lbolt_debug_return(void);
+
+extern lbolt_info_t *lb_info;
+
+/*
+ * LBOLT_WAITFREE provides a non-waiting version of lbolt.
+ */
+#define LBOLT_WAITFREE \
+ (lbolt_hybrid == lbolt_event_driven ? \
+ ((gethrtime_waitfree()/nsec_per_tick) - \
+ lb_info->lbi_debug_time) : \
+ (lb_info->lbi_internal - lb_info->lbi_debug_time))
+
+/*
+ * LBOLT_FASTPATH should *only* be used where the cost of calling
+ * ddi_get_lbolt() affects performance. This is currently only used by the
+ * TCP/IP code and will be removed once it's no longer required.
+ */
+#define LBOLT_FASTPATH \
+ (lbolt_hybrid == lbolt_event_driven ? ddi_get_lbolt() : \
+ (clock_t)(lb_info->lbi_internal - lb_info->lbi_debug_time))
+
+/*
+ * LBOLT_NO_ACCOUNT is used by lbolt consumers who fire at a periodic rate,
+ * such as clock(), for which the lbolt usage statistics are not updated.
+ * This is specially important for consumers whose rate may be modified by
+ * the user, resulting in an unaccounted for increase in activity around the
+ * lbolt routines that could cause a mode switch.
+ */
+#define LBOLT_NO_ACCOUNT \
+ (lbolt_hybrid == lbolt_event_driven ? \
+ ((gethrtime()/nsec_per_tick) - lb_info->lbi_debug_time) : \
+ (lb_info->lbi_internal - lb_info->lbi_debug_time))
+
+#endif /* _KERNEL || _KMEMUSER */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_CLOCK_IMPL_H */
diff --git a/usr/src/uts/common/sys/condvar.h b/usr/src/uts/common/sys/condvar.h
index 5d618e6284..be2240a8ed 100644
--- a/usr/src/uts/common/sys/condvar.h
+++ b/usr/src/uts/common/sys/condvar.h
@@ -2,9 +2,8 @@
* 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.
+ * Common Development and Distribution License (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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -35,8 +34,6 @@
#ifndef _SYS_CONDVAR_H
#define _SYS_CONDVAR_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifndef _ASM
#include <sys/types.h>
#include <sys/time.h>
@@ -64,6 +61,25 @@ typedef enum {
CV_DRIVER
} kcv_type_t;
+/*
+ * Time resolution values used in cv_reltimedwait() and cv_reltimedwait_sig()
+ * to specify how accurately a relative timeout must expire - if it can be
+ * anticipated or deferred.
+ */
+enum time_res {
+ TR_NANOSEC,
+ TR_MICROSEC,
+ TR_MILLISEC,
+ TR_SEC,
+ TR_CLOCK_TICK,
+ TR_COUNT
+};
+
+typedef enum time_res time_res_t;
+
+extern time_res_t time_res[];
+
+#define TIME_RES_VALID(tr) (tr >= TR_NANOSEC && tr < TR_COUNT)
#if defined(_KERNEL)
@@ -76,8 +92,11 @@ extern void cv_destroy(kcondvar_t *);
extern void cv_wait(kcondvar_t *, kmutex_t *);
extern void cv_wait_stop(kcondvar_t *, kmutex_t *, int);
extern clock_t cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
+extern clock_t cv_reltimedwait(kcondvar_t *, kmutex_t *, clock_t, time_res_t);
extern int cv_wait_sig(kcondvar_t *, kmutex_t *);
extern clock_t cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
+extern clock_t cv_reltimedwait_sig(kcondvar_t *, kmutex_t *, clock_t,
+ time_res_t);
extern int cv_wait_sig_swap(kcondvar_t *, kmutex_t *);
extern int cv_wait_sig_swap_core(kcondvar_t *, kmutex_t *, int *);
extern void cv_signal(kcondvar_t *);
diff --git a/usr/src/uts/common/sys/cpucaps_impl.h b/usr/src/uts/common/sys/cpucaps_impl.h
index ba4132993f..95afd21827 100644
--- a/usr/src/uts/common/sys/cpucaps_impl.h
+++ b/usr/src/uts/common/sys/cpucaps_impl.h
@@ -20,15 +20,13 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_CPUCAPS_IMPL_H
#define _SYS_CPUCAPS_IMPL_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -67,7 +65,7 @@ typedef struct cpucap {
struct zone *cap_zone; /* zone for the cap */
waitq_t cap_waitq; /* waitq for capped threads */
kstat_t *cap_kstat; /* cpucaps specific kstat */
- int64_t cap_lbolt; /* zone cap specific */
+ int64_t cap_gen; /* zone cap specific */
hrtime_t cap_value; /* scaled CPU usage cap */
hrtime_t cap_usage; /* current CPU usage */
disp_lock_t cap_usagelock; /* protects cap_usage above */
diff --git a/usr/src/uts/common/sys/cpuvar.h b/usr/src/uts/common/sys/cpuvar.h
index 1493aa6a33..aece259a35 100644
--- a/usr/src/uts/common/sys/cpuvar.h
+++ b/usr/src/uts/common/sys/cpuvar.h
@@ -168,7 +168,7 @@ typedef struct cpu {
ftrace_data_t cpu_ftrace; /* per cpu ftrace data */
- clock_t cpu_deadman_lbolt; /* used by deadman() */
+ clock_t cpu_deadman_counter; /* used by deadman() */
uint_t cpu_deadman_countdown; /* used by deadman() */
kmutex_t cpu_cpc_ctxlock; /* protects context for idle thread */
diff --git a/usr/src/uts/common/sys/fcoe/fcoe_common.h b/usr/src/uts/common/sys/fcoe/fcoe_common.h
index 6ab5ea2cbf..efb763a196 100644
--- a/usr/src/uts/common/sys/fcoe/fcoe_common.h
+++ b/usr/src/uts/common/sys/fcoe/fcoe_common.h
@@ -371,7 +371,7 @@ typedef struct fcoe_fcp_xfer_rdy {
/*
* timestamp (golbal variable in sys/systm.h)
*/
-#define CURRENT_CLOCK lbolt
+#define CURRENT_CLOCK (ddi_get_lbolt())
#define FCOE_SEC2TICK(x_sec) (drv_usectohz((x_sec) * 1000000))
/*
diff --git a/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h b/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h
index 657d3a31e4..7dafe2ec2d 100644
--- a/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h
+++ b/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h
@@ -967,13 +967,6 @@ typedef struct mptsas_dma_alloc_state
#define MPTSAS_PASS_THRU_TIME_DEFAULT 60 /* 60 seconds */
/*
- * macro for getting value in micro-seconds since last boot to be used as
- * timeout in cv_timedwait call.
- */
-#define MPTSAS_CV_TIMEOUT(timeout) (ddi_get_lbolt() + \
- drv_usectohz(timeout * MICROSEC))
-
-/*
* macro to return the effective address of a given per-target field
*/
#define EFF_ADDR(start, offset) ((start) + (offset))
diff --git a/usr/src/uts/common/sys/sunddi.h b/usr/src/uts/common/sys/sunddi.h
index 1ba098608c..1534fe4caf 100644
--- a/usr/src/uts/common/sys/sunddi.h
+++ b/usr/src/uts/common/sys/sunddi.h
@@ -1511,9 +1511,6 @@ ddivoid();
cred_t *
ddi_get_cred(void);
-clock_t
-ddi_get_lbolt(void);
-
time_t
ddi_get_time(void);
diff --git a/usr/src/uts/common/sys/systm.h b/usr/src/uts/common/sys/systm.h
index 4e529b9cce..84ccfb9991 100644
--- a/usr/src/uts/common/sys/systm.h
+++ b/usr/src/uts/common/sys/systm.h
@@ -61,8 +61,6 @@ typedef uintptr_t pc_t;
extern int hz; /* system clock rate */
extern struct vnode *rootdir; /* pointer to vnode of root directory */
extern struct vnode *devicesdir; /* pointer to /devices vnode */
-extern volatile clock_t lbolt; /* time in HZ since last boot */
-extern volatile int64_t lbolt64; /* lbolt computed as 64-bit value */
extern int interrupts_unleashed; /* set after the spl0() in main() */
extern char runin; /* scheduling flag */
diff --git a/usr/src/uts/common/sys/time.h b/usr/src/uts/common/sys/time.h
index 860ec10383..fcb9a290fe 100644
--- a/usr/src/uts/common/sys/time.h
+++ b/usr/src/uts/common/sys/time.h
@@ -359,6 +359,9 @@ extern void timevalsub(struct timeval *, struct timeval *);
extern void timevalfix(struct timeval *);
extern void dtrace_hres_tick(void);
+extern clock_t ddi_get_lbolt(void);
+extern int64_t ddi_get_lbolt64(void);
+
#if defined(_SYSCALL32)
extern void hrt2ts32(hrtime_t, timestruc32_t *);
#endif