1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 30*7c478bd9Sstevel@tonic-gate #include <sys/param.h> 31*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 32*7c478bd9Sstevel@tonic-gate #include <sys/open.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/file.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/conf.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/bitmap.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/debug.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/errno.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/lockstat.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/atomic.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/dtrace.h> 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 47*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate typedef struct lockstat_probe { 50*7c478bd9Sstevel@tonic-gate const char *lsp_func; 51*7c478bd9Sstevel@tonic-gate const char *lsp_name; 52*7c478bd9Sstevel@tonic-gate int lsp_probe; 53*7c478bd9Sstevel@tonic-gate dtrace_id_t lsp_id; 54*7c478bd9Sstevel@tonic-gate } lockstat_probe_t; 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate lockstat_probe_t lockstat_probes[] = 57*7c478bd9Sstevel@tonic-gate { 58*7c478bd9Sstevel@tonic-gate { LS_MUTEX_ENTER, LSA_ACQUIRE, LS_MUTEX_ENTER_ACQUIRE }, 59*7c478bd9Sstevel@tonic-gate { LS_MUTEX_ENTER, LSA_BLOCK, LS_MUTEX_ENTER_BLOCK }, 60*7c478bd9Sstevel@tonic-gate { LS_MUTEX_ENTER, LSA_SPIN, LS_MUTEX_ENTER_SPIN }, 61*7c478bd9Sstevel@tonic-gate { LS_MUTEX_EXIT, LSA_RELEASE, LS_MUTEX_EXIT_RELEASE }, 62*7c478bd9Sstevel@tonic-gate { LS_MUTEX_DESTROY, LSA_RELEASE, LS_MUTEX_DESTROY_RELEASE }, 63*7c478bd9Sstevel@tonic-gate { LS_MUTEX_TRYENTER, LSA_ACQUIRE, LS_MUTEX_TRYENTER_ACQUIRE }, 64*7c478bd9Sstevel@tonic-gate { LS_LOCK_SET, LSS_ACQUIRE, LS_LOCK_SET_ACQUIRE }, 65*7c478bd9Sstevel@tonic-gate { LS_LOCK_SET, LSS_SPIN, LS_LOCK_SET_SPIN }, 66*7c478bd9Sstevel@tonic-gate { LS_LOCK_SET_SPL, LSS_ACQUIRE, LS_LOCK_SET_SPL_ACQUIRE }, 67*7c478bd9Sstevel@tonic-gate { LS_LOCK_SET_SPL, LSS_SPIN, LS_LOCK_SET_SPL_SPIN }, 68*7c478bd9Sstevel@tonic-gate { LS_LOCK_TRY, LSS_ACQUIRE, LS_LOCK_TRY_ACQUIRE }, 69*7c478bd9Sstevel@tonic-gate { LS_LOCK_CLEAR, LSS_RELEASE, LS_LOCK_CLEAR_RELEASE }, 70*7c478bd9Sstevel@tonic-gate { LS_LOCK_CLEAR_SPLX, LSS_RELEASE, LS_LOCK_CLEAR_SPLX_RELEASE }, 71*7c478bd9Sstevel@tonic-gate { LS_CLOCK_UNLOCK, LSS_RELEASE, LS_CLOCK_UNLOCK_RELEASE }, 72*7c478bd9Sstevel@tonic-gate { LS_RW_ENTER, LSR_ACQUIRE, LS_RW_ENTER_ACQUIRE }, 73*7c478bd9Sstevel@tonic-gate { LS_RW_ENTER, LSR_BLOCK, LS_RW_ENTER_BLOCK }, 74*7c478bd9Sstevel@tonic-gate { LS_RW_EXIT, LSR_RELEASE, LS_RW_EXIT_RELEASE }, 75*7c478bd9Sstevel@tonic-gate { LS_RW_TRYENTER, LSR_ACQUIRE, LS_RW_TRYENTER_ACQUIRE }, 76*7c478bd9Sstevel@tonic-gate { LS_RW_TRYUPGRADE, LSR_UPGRADE, LS_RW_TRYUPGRADE_UPGRADE }, 77*7c478bd9Sstevel@tonic-gate { LS_RW_DOWNGRADE, LSR_DOWNGRADE, LS_RW_DOWNGRADE_DOWNGRADE }, 78*7c478bd9Sstevel@tonic-gate { LS_THREAD_LOCK, LST_SPIN, LS_THREAD_LOCK_SPIN }, 79*7c478bd9Sstevel@tonic-gate { LS_THREAD_LOCK_HIGH, LST_SPIN, LS_THREAD_LOCK_HIGH_SPIN }, 80*7c478bd9Sstevel@tonic-gate { NULL } 81*7c478bd9Sstevel@tonic-gate }; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate static dev_info_t *lockstat_devi; /* saved in xxattach() for xxinfo() */ 84*7c478bd9Sstevel@tonic-gate static kmutex_t lockstat_test; /* for testing purposes only */ 85*7c478bd9Sstevel@tonic-gate static dtrace_provider_id_t lockstat_id; 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 88*7c478bd9Sstevel@tonic-gate static void 89*7c478bd9Sstevel@tonic-gate lockstat_enable(void *arg, dtrace_id_t id, void *parg) 90*7c478bd9Sstevel@tonic-gate { 91*7c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = parg; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate ASSERT(!lockstat_probemap[probe->lsp_probe]); 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate lockstat_probemap[probe->lsp_probe] = id; 96*7c478bd9Sstevel@tonic-gate membar_producer(); 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate lockstat_probe = dtrace_probe; 99*7c478bd9Sstevel@tonic-gate membar_producer(); 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate lockstat_hot_patch(); 102*7c478bd9Sstevel@tonic-gate membar_producer(); 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate /* 105*7c478bd9Sstevel@tonic-gate * Immediately generate a record for the lockstat_test mutex 106*7c478bd9Sstevel@tonic-gate * to verify that the mutex hot-patch code worked as expected. 107*7c478bd9Sstevel@tonic-gate */ 108*7c478bd9Sstevel@tonic-gate mutex_enter(&lockstat_test); 109*7c478bd9Sstevel@tonic-gate mutex_exit(&lockstat_test); 110*7c478bd9Sstevel@tonic-gate } 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 113*7c478bd9Sstevel@tonic-gate static void 114*7c478bd9Sstevel@tonic-gate lockstat_disable(void *arg, dtrace_id_t id, void *parg) 115*7c478bd9Sstevel@tonic-gate { 116*7c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = parg; 117*7c478bd9Sstevel@tonic-gate int i; 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate ASSERT(lockstat_probemap[probe->lsp_probe]); 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate lockstat_probemap[probe->lsp_probe] = 0; 122*7c478bd9Sstevel@tonic-gate lockstat_hot_patch(); 123*7c478bd9Sstevel@tonic-gate membar_producer(); 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate /* 126*7c478bd9Sstevel@tonic-gate * See if we have any probes left enabled. 127*7c478bd9Sstevel@tonic-gate */ 128*7c478bd9Sstevel@tonic-gate for (i = 0; i < LS_NPROBES; i++) { 129*7c478bd9Sstevel@tonic-gate if (lockstat_probemap[i]) { 130*7c478bd9Sstevel@tonic-gate /* 131*7c478bd9Sstevel@tonic-gate * This probe is still enabled. We don't need to deal 132*7c478bd9Sstevel@tonic-gate * with waiting for all threads to be out of the 133*7c478bd9Sstevel@tonic-gate * lockstat critical sections; just return. 134*7c478bd9Sstevel@tonic-gate */ 135*7c478bd9Sstevel@tonic-gate return; 136*7c478bd9Sstevel@tonic-gate } 137*7c478bd9Sstevel@tonic-gate } 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate /* 140*7c478bd9Sstevel@tonic-gate * The delay() here isn't as cheesy as you might think. We don't 141*7c478bd9Sstevel@tonic-gate * want to busy-loop in the kernel, so we have to give up the 142*7c478bd9Sstevel@tonic-gate * CPU between calls to lockstat_active_threads(); that much is 143*7c478bd9Sstevel@tonic-gate * obvious. But the reason it's a do..while loop rather than a 144*7c478bd9Sstevel@tonic-gate * while loop is subtle. The memory barrier above guarantees that 145*7c478bd9Sstevel@tonic-gate * no threads will enter the lockstat code from this point forward. 146*7c478bd9Sstevel@tonic-gate * However, another thread could already be executing lockstat code 147*7c478bd9Sstevel@tonic-gate * without our knowledge if the update to its t_lockstat field hasn't 148*7c478bd9Sstevel@tonic-gate * cleared its CPU's store buffer. Delaying for one clock tick 149*7c478bd9Sstevel@tonic-gate * guarantees that either (1) the thread will have *ample* time to 150*7c478bd9Sstevel@tonic-gate * complete its work, or (2) the thread will be preempted, in which 151*7c478bd9Sstevel@tonic-gate * case it will have to grab and release a dispatcher lock, which 152*7c478bd9Sstevel@tonic-gate * will flush that CPU's store buffer. Either way we're covered. 153*7c478bd9Sstevel@tonic-gate */ 154*7c478bd9Sstevel@tonic-gate do { 155*7c478bd9Sstevel@tonic-gate delay(1); 156*7c478bd9Sstevel@tonic-gate } while (lockstat_active_threads()); 157*7c478bd9Sstevel@tonic-gate } 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 160*7c478bd9Sstevel@tonic-gate static int 161*7c478bd9Sstevel@tonic-gate lockstat_open(dev_t *devp, int flag, int otyp, cred_t *cred_p) 162*7c478bd9Sstevel@tonic-gate { 163*7c478bd9Sstevel@tonic-gate return (0); 164*7c478bd9Sstevel@tonic-gate } 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 167*7c478bd9Sstevel@tonic-gate static int 168*7c478bd9Sstevel@tonic-gate lockstat_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) 169*7c478bd9Sstevel@tonic-gate { 170*7c478bd9Sstevel@tonic-gate int error; 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate switch (infocmd) { 173*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO: 174*7c478bd9Sstevel@tonic-gate *result = (void *) lockstat_devi; 175*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 176*7c478bd9Sstevel@tonic-gate break; 177*7c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE: 178*7c478bd9Sstevel@tonic-gate *result = (void *)0; 179*7c478bd9Sstevel@tonic-gate error = DDI_SUCCESS; 180*7c478bd9Sstevel@tonic-gate break; 181*7c478bd9Sstevel@tonic-gate default: 182*7c478bd9Sstevel@tonic-gate error = DDI_FAILURE; 183*7c478bd9Sstevel@tonic-gate } 184*7c478bd9Sstevel@tonic-gate return (error); 185*7c478bd9Sstevel@tonic-gate } 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 188*7c478bd9Sstevel@tonic-gate static void 189*7c478bd9Sstevel@tonic-gate lockstat_provide(void *arg, const dtrace_probedesc_t *desc) 190*7c478bd9Sstevel@tonic-gate { 191*7c478bd9Sstevel@tonic-gate int i = 0; 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate for (i = 0; lockstat_probes[i].lsp_func != NULL; i++) { 194*7c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = &lockstat_probes[i]; 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate if (dtrace_probe_lookup(lockstat_id, "genunix", 197*7c478bd9Sstevel@tonic-gate probe->lsp_func, probe->lsp_name) != 0) 198*7c478bd9Sstevel@tonic-gate continue; 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate ASSERT(!probe->lsp_id); 201*7c478bd9Sstevel@tonic-gate probe->lsp_id = dtrace_probe_create(lockstat_id, 202*7c478bd9Sstevel@tonic-gate "genunix", probe->lsp_func, probe->lsp_name, 203*7c478bd9Sstevel@tonic-gate 1, probe); 204*7c478bd9Sstevel@tonic-gate } 205*7c478bd9Sstevel@tonic-gate } 206*7c478bd9Sstevel@tonic-gate 207*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 208*7c478bd9Sstevel@tonic-gate static void 209*7c478bd9Sstevel@tonic-gate lockstat_destroy(void *arg, dtrace_id_t id, void *parg) 210*7c478bd9Sstevel@tonic-gate { 211*7c478bd9Sstevel@tonic-gate lockstat_probe_t *probe = parg; 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate ASSERT(!lockstat_probemap[probe->lsp_probe]); 214*7c478bd9Sstevel@tonic-gate probe->lsp_id = 0; 215*7c478bd9Sstevel@tonic-gate } 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate static dtrace_pattr_t lockstat_attr = { 218*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON }, 219*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN }, 220*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN }, 221*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON }, 222*7c478bd9Sstevel@tonic-gate { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON }, 223*7c478bd9Sstevel@tonic-gate }; 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate static dtrace_pops_t lockstat_pops = { 226*7c478bd9Sstevel@tonic-gate lockstat_provide, 227*7c478bd9Sstevel@tonic-gate NULL, 228*7c478bd9Sstevel@tonic-gate lockstat_enable, 229*7c478bd9Sstevel@tonic-gate lockstat_disable, 230*7c478bd9Sstevel@tonic-gate NULL, 231*7c478bd9Sstevel@tonic-gate NULL, 232*7c478bd9Sstevel@tonic-gate NULL, 233*7c478bd9Sstevel@tonic-gate NULL, 234*7c478bd9Sstevel@tonic-gate NULL, 235*7c478bd9Sstevel@tonic-gate lockstat_destroy 236*7c478bd9Sstevel@tonic-gate }; 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate static int 239*7c478bd9Sstevel@tonic-gate lockstat_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 240*7c478bd9Sstevel@tonic-gate { 241*7c478bd9Sstevel@tonic-gate switch (cmd) { 242*7c478bd9Sstevel@tonic-gate case DDI_ATTACH: 243*7c478bd9Sstevel@tonic-gate break; 244*7c478bd9Sstevel@tonic-gate case DDI_RESUME: 245*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 246*7c478bd9Sstevel@tonic-gate default: 247*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 248*7c478bd9Sstevel@tonic-gate } 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(devi, "lockstat", S_IFCHR, 0, 251*7c478bd9Sstevel@tonic-gate DDI_PSEUDO, 0) == DDI_FAILURE || 252*7c478bd9Sstevel@tonic-gate dtrace_register("lockstat", &lockstat_attr, DTRACE_PRIV_KERNEL, 0, 253*7c478bd9Sstevel@tonic-gate &lockstat_pops, NULL, &lockstat_id) != 0) { 254*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 255*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 256*7c478bd9Sstevel@tonic-gate } 257*7c478bd9Sstevel@tonic-gate 258*7c478bd9Sstevel@tonic-gate ddi_report_dev(devi); 259*7c478bd9Sstevel@tonic-gate lockstat_devi = devi; 260*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 261*7c478bd9Sstevel@tonic-gate } 262*7c478bd9Sstevel@tonic-gate 263*7c478bd9Sstevel@tonic-gate static int 264*7c478bd9Sstevel@tonic-gate lockstat_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) 265*7c478bd9Sstevel@tonic-gate { 266*7c478bd9Sstevel@tonic-gate switch (cmd) { 267*7c478bd9Sstevel@tonic-gate case DDI_DETACH: 268*7c478bd9Sstevel@tonic-gate break; 269*7c478bd9Sstevel@tonic-gate case DDI_SUSPEND: 270*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 271*7c478bd9Sstevel@tonic-gate default: 272*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 273*7c478bd9Sstevel@tonic-gate } 274*7c478bd9Sstevel@tonic-gate 275*7c478bd9Sstevel@tonic-gate if (dtrace_unregister(lockstat_id) != 0) 276*7c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate ddi_remove_minor_node(devi, NULL); 279*7c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 280*7c478bd9Sstevel@tonic-gate } 281*7c478bd9Sstevel@tonic-gate 282*7c478bd9Sstevel@tonic-gate /* 283*7c478bd9Sstevel@tonic-gate * Configuration data structures 284*7c478bd9Sstevel@tonic-gate */ 285*7c478bd9Sstevel@tonic-gate static struct cb_ops lockstat_cb_ops = { 286*7c478bd9Sstevel@tonic-gate lockstat_open, /* open */ 287*7c478bd9Sstevel@tonic-gate nodev, /* close */ 288*7c478bd9Sstevel@tonic-gate nulldev, /* strategy */ 289*7c478bd9Sstevel@tonic-gate nulldev, /* print */ 290*7c478bd9Sstevel@tonic-gate nodev, /* dump */ 291*7c478bd9Sstevel@tonic-gate nodev, /* read */ 292*7c478bd9Sstevel@tonic-gate nodev, /* write */ 293*7c478bd9Sstevel@tonic-gate nodev, /* ioctl */ 294*7c478bd9Sstevel@tonic-gate nodev, /* devmap */ 295*7c478bd9Sstevel@tonic-gate nodev, /* mmap */ 296*7c478bd9Sstevel@tonic-gate nodev, /* segmap */ 297*7c478bd9Sstevel@tonic-gate nochpoll, /* poll */ 298*7c478bd9Sstevel@tonic-gate ddi_prop_op, /* cb_prop_op */ 299*7c478bd9Sstevel@tonic-gate 0, /* streamtab */ 300*7c478bd9Sstevel@tonic-gate D_MP | D_NEW /* Driver compatibility flag */ 301*7c478bd9Sstevel@tonic-gate }; 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate static struct dev_ops lockstat_ops = { 304*7c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */ 305*7c478bd9Sstevel@tonic-gate 0, /* refcnt */ 306*7c478bd9Sstevel@tonic-gate lockstat_info, /* getinfo */ 307*7c478bd9Sstevel@tonic-gate nulldev, /* identify */ 308*7c478bd9Sstevel@tonic-gate nulldev, /* probe */ 309*7c478bd9Sstevel@tonic-gate lockstat_attach, /* attach */ 310*7c478bd9Sstevel@tonic-gate lockstat_detach, /* detach */ 311*7c478bd9Sstevel@tonic-gate nulldev, /* reset */ 312*7c478bd9Sstevel@tonic-gate &lockstat_cb_ops, /* cb_ops */ 313*7c478bd9Sstevel@tonic-gate NULL, /* bus_ops */ 314*7c478bd9Sstevel@tonic-gate }; 315*7c478bd9Sstevel@tonic-gate 316*7c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 317*7c478bd9Sstevel@tonic-gate &mod_driverops, /* Type of module. This one is a driver */ 318*7c478bd9Sstevel@tonic-gate "Lock Statistics %I%", /* name of module */ 319*7c478bd9Sstevel@tonic-gate &lockstat_ops, /* driver ops */ 320*7c478bd9Sstevel@tonic-gate }; 321*7c478bd9Sstevel@tonic-gate 322*7c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 323*7c478bd9Sstevel@tonic-gate MODREV_1, (void *)&modldrv, NULL 324*7c478bd9Sstevel@tonic-gate }; 325*7c478bd9Sstevel@tonic-gate 326*7c478bd9Sstevel@tonic-gate int 327*7c478bd9Sstevel@tonic-gate _init(void) 328*7c478bd9Sstevel@tonic-gate { 329*7c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 330*7c478bd9Sstevel@tonic-gate } 331*7c478bd9Sstevel@tonic-gate 332*7c478bd9Sstevel@tonic-gate int 333*7c478bd9Sstevel@tonic-gate _fini(void) 334*7c478bd9Sstevel@tonic-gate { 335*7c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage)); 336*7c478bd9Sstevel@tonic-gate } 337*7c478bd9Sstevel@tonic-gate 338*7c478bd9Sstevel@tonic-gate int 339*7c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 340*7c478bd9Sstevel@tonic-gate { 341*7c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 342*7c478bd9Sstevel@tonic-gate } 343