17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5ad4023c4Sdp * Common Development and Distribution License (the "License").
6ad4023c4Sdp * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22b9e93c10SJonathan Haslam * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
24*ee6ee36aSPatrick Mooney * Copyright 2022 Oxide Computer Company
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate #include <sys/types.h>
297c478bd9Sstevel@tonic-gate #include <sys/param.h>
307c478bd9Sstevel@tonic-gate #include <sys/stat.h>
317c478bd9Sstevel@tonic-gate #include <sys/open.h>
327c478bd9Sstevel@tonic-gate #include <sys/file.h>
337c478bd9Sstevel@tonic-gate #include <sys/conf.h>
347c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
357c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
367c478bd9Sstevel@tonic-gate #include <sys/bitmap.h>
377c478bd9Sstevel@tonic-gate #include <sys/debug.h>
387c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
397c478bd9Sstevel@tonic-gate #include <sys/errno.h>
407c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
417c478bd9Sstevel@tonic-gate #include <sys/lockstat.h>
427c478bd9Sstevel@tonic-gate #include <sys/atomic.h>
437c478bd9Sstevel@tonic-gate #include <sys/dtrace.h>
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
467c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate typedef struct lockstat_probe {
497c478bd9Sstevel@tonic-gate const char *lsp_func;
507c478bd9Sstevel@tonic-gate const char *lsp_name;
517c478bd9Sstevel@tonic-gate int lsp_probe;
527c478bd9Sstevel@tonic-gate dtrace_id_t lsp_id;
537c478bd9Sstevel@tonic-gate } lockstat_probe_t;
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate lockstat_probe_t lockstat_probes[] =
567c478bd9Sstevel@tonic-gate {
577c478bd9Sstevel@tonic-gate { LS_MUTEX_ENTER, LSA_ACQUIRE, LS_MUTEX_ENTER_ACQUIRE },
587c478bd9Sstevel@tonic-gate { LS_MUTEX_ENTER, LSA_BLOCK, LS_MUTEX_ENTER_BLOCK },
597c478bd9Sstevel@tonic-gate { LS_MUTEX_ENTER, LSA_SPIN, LS_MUTEX_ENTER_SPIN },
607c478bd9Sstevel@tonic-gate { LS_MUTEX_EXIT, LSA_RELEASE, LS_MUTEX_EXIT_RELEASE },
617c478bd9Sstevel@tonic-gate { LS_MUTEX_DESTROY, LSA_RELEASE, LS_MUTEX_DESTROY_RELEASE },
627c478bd9Sstevel@tonic-gate { LS_MUTEX_TRYENTER, LSA_ACQUIRE, LS_MUTEX_TRYENTER_ACQUIRE },
637c478bd9Sstevel@tonic-gate { LS_LOCK_SET, LSS_ACQUIRE, LS_LOCK_SET_ACQUIRE },
647c478bd9Sstevel@tonic-gate { LS_LOCK_SET, LSS_SPIN, LS_LOCK_SET_SPIN },
657c478bd9Sstevel@tonic-gate { LS_LOCK_SET_SPL, LSS_ACQUIRE, LS_LOCK_SET_SPL_ACQUIRE },
667c478bd9Sstevel@tonic-gate { LS_LOCK_SET_SPL, LSS_SPIN, LS_LOCK_SET_SPL_SPIN },
677c478bd9Sstevel@tonic-gate { LS_LOCK_TRY, LSS_ACQUIRE, LS_LOCK_TRY_ACQUIRE },
687c478bd9Sstevel@tonic-gate { LS_LOCK_CLEAR, LSS_RELEASE, LS_LOCK_CLEAR_RELEASE },
697c478bd9Sstevel@tonic-gate { LS_LOCK_CLEAR_SPLX, LSS_RELEASE, LS_LOCK_CLEAR_SPLX_RELEASE },
707c478bd9Sstevel@tonic-gate { LS_CLOCK_UNLOCK, LSS_RELEASE, LS_CLOCK_UNLOCK_RELEASE },
717c478bd9Sstevel@tonic-gate { LS_RW_ENTER, LSR_ACQUIRE, LS_RW_ENTER_ACQUIRE },
727c478bd9Sstevel@tonic-gate { LS_RW_ENTER, LSR_BLOCK, LS_RW_ENTER_BLOCK },
737c478bd9Sstevel@tonic-gate { LS_RW_EXIT, LSR_RELEASE, LS_RW_EXIT_RELEASE },
747c478bd9Sstevel@tonic-gate { LS_RW_TRYENTER, LSR_ACQUIRE, LS_RW_TRYENTER_ACQUIRE },
757c478bd9Sstevel@tonic-gate { LS_RW_TRYUPGRADE, LSR_UPGRADE, LS_RW_TRYUPGRADE_UPGRADE },
767c478bd9Sstevel@tonic-gate { LS_RW_DOWNGRADE, LSR_DOWNGRADE, LS_RW_DOWNGRADE_DOWNGRADE },
777c478bd9Sstevel@tonic-gate { LS_THREAD_LOCK, LST_SPIN, LS_THREAD_LOCK_SPIN },
787c478bd9Sstevel@tonic-gate { LS_THREAD_LOCK_HIGH, LST_SPIN, LS_THREAD_LOCK_HIGH_SPIN },
797c478bd9Sstevel@tonic-gate { NULL }
807c478bd9Sstevel@tonic-gate };
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate static dev_info_t *lockstat_devi; /* saved in xxattach() for xxinfo() */
837c478bd9Sstevel@tonic-gate static kmutex_t lockstat_test; /* for testing purposes only */
847c478bd9Sstevel@tonic-gate static dtrace_provider_id_t lockstat_id;
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gate /*ARGSUSED*/
87b9e93c10SJonathan Haslam static int
lockstat_enable(void * arg,dtrace_id_t id,void * parg)887c478bd9Sstevel@tonic-gate lockstat_enable(void *arg, dtrace_id_t id, void *parg)
897c478bd9Sstevel@tonic-gate {
907c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = parg;
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate ASSERT(!lockstat_probemap[probe->lsp_probe]);
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate lockstat_probemap[probe->lsp_probe] = id;
957c478bd9Sstevel@tonic-gate membar_producer();
967c478bd9Sstevel@tonic-gate
97*ee6ee36aSPatrick Mooney lockstat_hotpatch_probe(probe->lsp_probe);
987c478bd9Sstevel@tonic-gate membar_producer();
997c478bd9Sstevel@tonic-gate
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate * Immediately generate a record for the lockstat_test mutex
1027c478bd9Sstevel@tonic-gate * to verify that the mutex hot-patch code worked as expected.
1037c478bd9Sstevel@tonic-gate */
1047c478bd9Sstevel@tonic-gate mutex_enter(&lockstat_test);
1057c478bd9Sstevel@tonic-gate mutex_exit(&lockstat_test);
106b9e93c10SJonathan Haslam return (0);
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1107c478bd9Sstevel@tonic-gate static void
lockstat_disable(void * arg,dtrace_id_t id,void * parg)1117c478bd9Sstevel@tonic-gate lockstat_disable(void *arg, dtrace_id_t id, void *parg)
1127c478bd9Sstevel@tonic-gate {
1137c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = parg;
1147c478bd9Sstevel@tonic-gate int i;
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate ASSERT(lockstat_probemap[probe->lsp_probe]);
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gate lockstat_probemap[probe->lsp_probe] = 0;
119*ee6ee36aSPatrick Mooney lockstat_hotpatch_probe(probe->lsp_probe);
1207c478bd9Sstevel@tonic-gate membar_producer();
1217c478bd9Sstevel@tonic-gate
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate * See if we have any probes left enabled.
1247c478bd9Sstevel@tonic-gate */
1257c478bd9Sstevel@tonic-gate for (i = 0; i < LS_NPROBES; i++) {
1267c478bd9Sstevel@tonic-gate if (lockstat_probemap[i]) {
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate * This probe is still enabled. We don't need to deal
1297c478bd9Sstevel@tonic-gate * with waiting for all threads to be out of the
1307c478bd9Sstevel@tonic-gate * lockstat critical sections; just return.
1317c478bd9Sstevel@tonic-gate */
1327c478bd9Sstevel@tonic-gate return;
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate
1367c478bd9Sstevel@tonic-gate /*
1377c478bd9Sstevel@tonic-gate * The delay() here isn't as cheesy as you might think. We don't
1387c478bd9Sstevel@tonic-gate * want to busy-loop in the kernel, so we have to give up the
1397c478bd9Sstevel@tonic-gate * CPU between calls to lockstat_active_threads(); that much is
1407c478bd9Sstevel@tonic-gate * obvious. But the reason it's a do..while loop rather than a
1417c478bd9Sstevel@tonic-gate * while loop is subtle. The memory barrier above guarantees that
1427c478bd9Sstevel@tonic-gate * no threads will enter the lockstat code from this point forward.
1437c478bd9Sstevel@tonic-gate * However, another thread could already be executing lockstat code
1447c478bd9Sstevel@tonic-gate * without our knowledge if the update to its t_lockstat field hasn't
1457c478bd9Sstevel@tonic-gate * cleared its CPU's store buffer. Delaying for one clock tick
1467c478bd9Sstevel@tonic-gate * guarantees that either (1) the thread will have *ample* time to
1477c478bd9Sstevel@tonic-gate * complete its work, or (2) the thread will be preempted, in which
1487c478bd9Sstevel@tonic-gate * case it will have to grab and release a dispatcher lock, which
1497c478bd9Sstevel@tonic-gate * will flush that CPU's store buffer. Either way we're covered.
1507c478bd9Sstevel@tonic-gate */
1517c478bd9Sstevel@tonic-gate do {
1527c478bd9Sstevel@tonic-gate delay(1);
1537c478bd9Sstevel@tonic-gate } while (lockstat_active_threads());
1547c478bd9Sstevel@tonic-gate }
1557c478bd9Sstevel@tonic-gate
1567c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1577c478bd9Sstevel@tonic-gate static int
lockstat_open(dev_t * devp,int flag,int otyp,cred_t * cred_p)1587c478bd9Sstevel@tonic-gate lockstat_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
1597c478bd9Sstevel@tonic-gate {
1607c478bd9Sstevel@tonic-gate return (0);
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate /* ARGSUSED */
1647c478bd9Sstevel@tonic-gate static int
lockstat_info(dev_info_t * dip,ddi_info_cmd_t infocmd,void * arg,void ** result)1657c478bd9Sstevel@tonic-gate lockstat_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
1667c478bd9Sstevel@tonic-gate {
1677c478bd9Sstevel@tonic-gate int error;
1687c478bd9Sstevel@tonic-gate
1697c478bd9Sstevel@tonic-gate switch (infocmd) {
1707c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO:
1717c478bd9Sstevel@tonic-gate *result = (void *) lockstat_devi;
1727c478bd9Sstevel@tonic-gate error = DDI_SUCCESS;
1737c478bd9Sstevel@tonic-gate break;
1747c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE:
1757c478bd9Sstevel@tonic-gate *result = (void *)0;
1767c478bd9Sstevel@tonic-gate error = DDI_SUCCESS;
1777c478bd9Sstevel@tonic-gate break;
1787c478bd9Sstevel@tonic-gate default:
1797c478bd9Sstevel@tonic-gate error = DDI_FAILURE;
1807c478bd9Sstevel@tonic-gate }
1817c478bd9Sstevel@tonic-gate return (error);
1827c478bd9Sstevel@tonic-gate }
1837c478bd9Sstevel@tonic-gate
1847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1857c478bd9Sstevel@tonic-gate static void
lockstat_provide(void * arg,const dtrace_probedesc_t * desc)1867c478bd9Sstevel@tonic-gate lockstat_provide(void *arg, const dtrace_probedesc_t *desc)
1877c478bd9Sstevel@tonic-gate {
1887c478bd9Sstevel@tonic-gate int i = 0;
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate for (i = 0; lockstat_probes[i].lsp_func != NULL; i++) {
1917c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = &lockstat_probes[i];
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate if (dtrace_probe_lookup(lockstat_id, "genunix",
1947c478bd9Sstevel@tonic-gate probe->lsp_func, probe->lsp_name) != 0)
1957c478bd9Sstevel@tonic-gate continue;
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate ASSERT(!probe->lsp_id);
1987c478bd9Sstevel@tonic-gate probe->lsp_id = dtrace_probe_create(lockstat_id,
1997c478bd9Sstevel@tonic-gate "genunix", probe->lsp_func, probe->lsp_name,
2007c478bd9Sstevel@tonic-gate 1, probe);
2017c478bd9Sstevel@tonic-gate }
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2057c478bd9Sstevel@tonic-gate static void
lockstat_destroy(void * arg,dtrace_id_t id,void * parg)2067c478bd9Sstevel@tonic-gate lockstat_destroy(void *arg, dtrace_id_t id, void *parg)
2077c478bd9Sstevel@tonic-gate {
2087c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = parg;
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate ASSERT(!lockstat_probemap[probe->lsp_probe]);
2117c478bd9Sstevel@tonic-gate probe->lsp_id = 0;
2127c478bd9Sstevel@tonic-gate }
2137c478bd9Sstevel@tonic-gate
2147c478bd9Sstevel@tonic-gate static dtrace_pattr_t lockstat_attr = {
2157c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
2167c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
2177c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
2187c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
2197c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
2207c478bd9Sstevel@tonic-gate };
2217c478bd9Sstevel@tonic-gate
2227c478bd9Sstevel@tonic-gate static dtrace_pops_t lockstat_pops = {
2237c478bd9Sstevel@tonic-gate lockstat_provide,
2247c478bd9Sstevel@tonic-gate NULL,
2257c478bd9Sstevel@tonic-gate lockstat_enable,
2267c478bd9Sstevel@tonic-gate lockstat_disable,
2277c478bd9Sstevel@tonic-gate NULL,
2287c478bd9Sstevel@tonic-gate NULL,
2297c478bd9Sstevel@tonic-gate NULL,
2307c478bd9Sstevel@tonic-gate NULL,
2317c478bd9Sstevel@tonic-gate NULL,
2327c478bd9Sstevel@tonic-gate lockstat_destroy
2337c478bd9Sstevel@tonic-gate };
2347c478bd9Sstevel@tonic-gate
2357c478bd9Sstevel@tonic-gate static int
lockstat_attach(dev_info_t * devi,ddi_attach_cmd_t cmd)2367c478bd9Sstevel@tonic-gate lockstat_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
2377c478bd9Sstevel@tonic-gate {
2387c478bd9Sstevel@tonic-gate switch (cmd) {
2397c478bd9Sstevel@tonic-gate case DDI_ATTACH:
2407c478bd9Sstevel@tonic-gate break;
2417c478bd9Sstevel@tonic-gate case DDI_RESUME:
2427c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
2437c478bd9Sstevel@tonic-gate default:
2447c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
2457c478bd9Sstevel@tonic-gate }
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(devi, "lockstat", S_IFCHR, 0,
2487c478bd9Sstevel@tonic-gate DDI_PSEUDO, 0) == DDI_FAILURE ||
249ad4023c4Sdp dtrace_register("lockstat", &lockstat_attr, DTRACE_PRIV_KERNEL,
250ad4023c4Sdp NULL, &lockstat_pops, NULL, &lockstat_id) != 0) {
2517c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL);
2527c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
2537c478bd9Sstevel@tonic-gate }
2547c478bd9Sstevel@tonic-gate
255aaa19a19Sjhaslam lockstat_probe = dtrace_probe;
256aaa19a19Sjhaslam membar_producer();
257aaa19a19Sjhaslam
2587c478bd9Sstevel@tonic-gate ddi_report_dev(devi);
2597c478bd9Sstevel@tonic-gate lockstat_devi = devi;
2607c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
2617c478bd9Sstevel@tonic-gate }
2627c478bd9Sstevel@tonic-gate
2637c478bd9Sstevel@tonic-gate static int
lockstat_detach(dev_info_t * devi,ddi_detach_cmd_t cmd)2647c478bd9Sstevel@tonic-gate lockstat_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
2657c478bd9Sstevel@tonic-gate {
2667c478bd9Sstevel@tonic-gate switch (cmd) {
2677c478bd9Sstevel@tonic-gate case DDI_DETACH:
2687c478bd9Sstevel@tonic-gate break;
2697c478bd9Sstevel@tonic-gate case DDI_SUSPEND:
2707c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
2717c478bd9Sstevel@tonic-gate default:
2727c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate
2757c478bd9Sstevel@tonic-gate if (dtrace_unregister(lockstat_id) != 0)
2767c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
2777c478bd9Sstevel@tonic-gate
2787c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL);
2797c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
2807c478bd9Sstevel@tonic-gate }
2817c478bd9Sstevel@tonic-gate
2827c478bd9Sstevel@tonic-gate /*
2837c478bd9Sstevel@tonic-gate * Configuration data structures
2847c478bd9Sstevel@tonic-gate */
2857c478bd9Sstevel@tonic-gate static struct cb_ops lockstat_cb_ops = {
2867c478bd9Sstevel@tonic-gate lockstat_open, /* open */
2877c478bd9Sstevel@tonic-gate nodev, /* close */
2887c478bd9Sstevel@tonic-gate nulldev, /* strategy */
2897c478bd9Sstevel@tonic-gate nulldev, /* print */
2907c478bd9Sstevel@tonic-gate nodev, /* dump */
2917c478bd9Sstevel@tonic-gate nodev, /* read */
2927c478bd9Sstevel@tonic-gate nodev, /* write */
2937c478bd9Sstevel@tonic-gate nodev, /* ioctl */
2947c478bd9Sstevel@tonic-gate nodev, /* devmap */
2957c478bd9Sstevel@tonic-gate nodev, /* mmap */
2967c478bd9Sstevel@tonic-gate nodev, /* segmap */
2977c478bd9Sstevel@tonic-gate nochpoll, /* poll */
2987c478bd9Sstevel@tonic-gate ddi_prop_op, /* cb_prop_op */
2997c478bd9Sstevel@tonic-gate 0, /* streamtab */
3007c478bd9Sstevel@tonic-gate D_MP | D_NEW /* Driver compatibility flag */
3017c478bd9Sstevel@tonic-gate };
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate static struct dev_ops lockstat_ops = {
3047c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */
3057c478bd9Sstevel@tonic-gate 0, /* refcnt */
3067c478bd9Sstevel@tonic-gate lockstat_info, /* getinfo */
3077c478bd9Sstevel@tonic-gate nulldev, /* identify */
3087c478bd9Sstevel@tonic-gate nulldev, /* probe */
3097c478bd9Sstevel@tonic-gate lockstat_attach, /* attach */
3107c478bd9Sstevel@tonic-gate lockstat_detach, /* detach */
3117c478bd9Sstevel@tonic-gate nulldev, /* reset */
3127c478bd9Sstevel@tonic-gate &lockstat_cb_ops, /* cb_ops */
3137c478bd9Sstevel@tonic-gate NULL, /* bus_ops */
31419397407SSherry Moore NULL, /* power */
31519397407SSherry Moore ddi_quiesce_not_needed, /* quiesce */
3167c478bd9Sstevel@tonic-gate };
3177c478bd9Sstevel@tonic-gate
3187c478bd9Sstevel@tonic-gate static struct modldrv modldrv = {
3197c478bd9Sstevel@tonic-gate &mod_driverops, /* Type of module. This one is a driver */
32019397407SSherry Moore "Lock Statistics", /* name of module */
3217c478bd9Sstevel@tonic-gate &lockstat_ops, /* driver ops */
3227c478bd9Sstevel@tonic-gate };
3237c478bd9Sstevel@tonic-gate
3247c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
3257c478bd9Sstevel@tonic-gate MODREV_1, (void *)&modldrv, NULL
3267c478bd9Sstevel@tonic-gate };
3277c478bd9Sstevel@tonic-gate
3287c478bd9Sstevel@tonic-gate int
_init(void)3297c478bd9Sstevel@tonic-gate _init(void)
3307c478bd9Sstevel@tonic-gate {
3317c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage));
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate int
_fini(void)3357c478bd9Sstevel@tonic-gate _fini(void)
3367c478bd9Sstevel@tonic-gate {
3377c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage));
3387c478bd9Sstevel@tonic-gate }
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)3417c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
3427c478bd9Sstevel@tonic-gate {
3437c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop));
3447c478bd9Sstevel@tonic-gate }
345