Hide references to mod_lock. In FreeBSD it is always acquired with the

provider lock held, so its use has no effect.
This commit is contained in:
Mark Johnston 2013-07-05 22:42:10 +00:00
parent 636621d9d9
commit 46d27dbb38
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=252850
4 changed files with 31 additions and 14 deletions

View File

@ -278,8 +278,6 @@ static kmutex_t dtrace_meta_lock; /* meta-provider state lock */
#if !defined(sun)
/* XXX FreeBSD hacks. */
static kmutex_t mod_lock;
#define cr_suid cr_svuid
#define cr_sgid cr_svgid
#define ipaddr_t in_addr_t
@ -7678,7 +7676,9 @@ dtrace_unregister(dtrace_provider_id_t id)
}
} else {
mutex_enter(&dtrace_provider_lock);
#if defined(sun)
mutex_enter(&mod_lock);
#endif
mutex_enter(&dtrace_lock);
}
@ -7692,7 +7692,9 @@ dtrace_unregister(dtrace_provider_id_t id)
dtrace_anon.dta_state->dts_necbs > 0))) {
if (!self) {
mutex_exit(&dtrace_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
}
return (EBUSY);
@ -7726,7 +7728,9 @@ dtrace_unregister(dtrace_provider_id_t id)
if (!self) {
mutex_exit(&dtrace_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
}
@ -7808,7 +7812,9 @@ dtrace_unregister(dtrace_provider_id_t id)
if (!self) {
mutex_exit(&dtrace_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
}
@ -8141,6 +8147,7 @@ dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv)
*/
prv->dtpv_pops.dtps_provide(prv->dtpv_arg, desc);
#if defined(sun)
/*
* Now call the per-module provide operation. We will grab
* mod_lock to prevent the list from being modified. Note
@ -8149,7 +8156,6 @@ dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv)
*/
mutex_enter(&mod_lock);
#if defined(sun)
ctl = &modules;
do {
if (ctl->mod_busy || ctl->mod_mp == NULL)
@ -8158,11 +8164,11 @@ dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv)
prv->dtpv_pops.dtps_provide_module(prv->dtpv_arg, ctl);
} while ((ctl = ctl->mod_next) != &modules);
mutex_exit(&mod_lock);
#else
(void) linker_file_foreach(dtrace_probe_provide_cb, prv);
#endif
mutex_exit(&mod_lock);
} while (all && (prv = prv->dtpv_next) != NULL);
}
@ -15156,7 +15162,9 @@ dtrace_module_loaded(modctl_t *ctl)
dtrace_provider_t *prv;
mutex_enter(&dtrace_provider_lock);
#if defined(sun)
mutex_enter(&mod_lock);
#endif
ASSERT(ctl->mod_busy);
@ -15167,7 +15175,9 @@ dtrace_module_loaded(modctl_t *ctl)
for (prv = dtrace_provider; prv != NULL; prv = prv->dtpv_next)
prv->dtpv_pops.dtps_provide_module(prv->dtpv_arg, ctl);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
/*
@ -15212,7 +15222,9 @@ dtrace_module_unloaded(modctl_t *ctl)
template.dtpr_mod = ctl->mod_modname;
mutex_enter(&dtrace_provider_lock);
#if defined(sun)
mutex_enter(&mod_lock);
#endif
mutex_enter(&dtrace_lock);
if (dtrace_bymod == NULL) {
@ -15221,7 +15233,9 @@ dtrace_module_unloaded(modctl_t *ctl)
* we don't have any work to do.
*/
mutex_exit(&dtrace_provider_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_lock);
return;
}
@ -15230,7 +15244,9 @@ dtrace_module_unloaded(modctl_t *ctl)
probe != NULL; probe = probe->dtpr_nextmod) {
if (probe->dtpr_ecb != NULL) {
mutex_exit(&dtrace_provider_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_lock);
/*
@ -15293,7 +15309,9 @@ dtrace_module_unloaded(modctl_t *ctl)
}
mutex_exit(&dtrace_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
}

View File

@ -580,19 +580,25 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
return (EINVAL);
mutex_enter(&dtrace_provider_lock);
#if defined(sun)
mutex_enter(&mod_lock);
#endif
mutex_enter(&dtrace_lock);
if (desc->dtargd_id > dtrace_nprobes) {
mutex_exit(&dtrace_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
return (EINVAL);
}
if ((probe = dtrace_probes[desc->dtargd_id - 1]) == NULL) {
mutex_exit(&dtrace_lock);
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
return (EINVAL);
}
@ -616,7 +622,9 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
probe->dtpr_id, probe->dtpr_arg, desc);
}
#if defined(sun)
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
return (0);

View File

@ -56,12 +56,6 @@ dtrace_load(void *dummy)
/* Hang our hook for exceptions. */
dtrace_invop_init();
/*
* XXX This is a short term hack to avoid having to comment
* out lots and lots of lock/unlock calls.
*/
mutex_init(&mod_lock,"XXX mod_lock hack", MUTEX_DEFAULT, NULL);
/*
* Initialise the mutexes without 'witness' because the dtrace
* code is mostly written to wait for memory. To have the

View File

@ -123,9 +123,6 @@ dtrace_unload()
mutex_destroy(&dtrace_lock);
mutex_destroy(&dtrace_errlock);
/* XXX Hack */
mutex_destroy(&mod_lock);
/* Reset our hook for exceptions. */
dtrace_invop_uninit();