svn commit: r299003 - in stable/10/sys/cddl/contrib/opensolaris/uts: common/dtrace common/sys intel/dtrace powerpc/dtrace
Mark Johnston
markj at FreeBSD.org
Tue May 3 20:08:06 UTC 2016
Author: markj
Date: Tue May 3 20:08:05 2016
New Revision: 299003
URL: https://svnweb.freebsd.org/changeset/base/299003
Log:
MFC r296479:
Fix fasttrap tracepoint locking.
Modified:
stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h
stable/10/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
stable/10/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Tue May 3 19:45:24 2016 (r299002)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c Tue May 3 20:08:05 2016 (r299003)
@@ -63,14 +63,16 @@
#ifndef illumos
#include <sys/dtrace_bsd.h>
#include <sys/eventhandler.h>
+#include <sys/rmlock.h>
#include <sys/sysctl.h>
#include <sys/u8_textprep.h>
#include <sys/user.h>
+
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_param.h>
-#include <sys/u8_textprep.h>
+
#include <cddl/dev/dtrace/dtrace_cddl.h>
#endif
@@ -225,7 +227,7 @@ static void fasttrap_thread_dtor(void *,
#define FASTTRAP_PROCS_INDEX(pid) ((pid) & fasttrap_procs.fth_mask)
#ifndef illumos
-static kmutex_t fasttrap_cpuc_pid_lock[MAXCPU];
+struct rmlock fasttrap_tp_lock;
static eventhandler_tag fasttrap_thread_dtor_tag;
#endif
@@ -440,10 +442,15 @@ fasttrap_mod_barrier(uint64_t gen)
fasttrap_mod_gen++;
+#ifdef illumos
CPU_FOREACH(i) {
mutex_enter(&fasttrap_cpuc_pid_lock[i]);
mutex_exit(&fasttrap_cpuc_pid_lock[i]);
}
+#else
+ rm_wlock(&fasttrap_tp_lock);
+ rm_wunlock(&fasttrap_tp_lock);
+#endif
}
/*
@@ -2565,10 +2572,7 @@ fasttrap_load(void)
mutex_init(&fasttrap_procs.fth_table[i].ftb_mtx,
"processes bucket mtx", MUTEX_DEFAULT, NULL);
- CPU_FOREACH(i) {
- mutex_init(&fasttrap_cpuc_pid_lock[i], "fasttrap barrier",
- MUTEX_DEFAULT, NULL);
- }
+ rm_init(&fasttrap_tp_lock, "fasttrap tracepoint");
/*
* This event handler must run before kdtrace_thread_dtor() since it
@@ -2701,9 +2705,7 @@ fasttrap_unload(void)
#ifndef illumos
destroy_dev(fasttrap_cdev);
mutex_destroy(&fasttrap_count_mtx);
- CPU_FOREACH(i) {
- mutex_destroy(&fasttrap_cpuc_pid_lock[i]);
- }
+ rm_destroy(&fasttrap_tp_lock);
#endif
return (0);
Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h Tue May 3 19:45:24 2016 (r299002)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h Tue May 3 20:08:05 2016 (r299003)
@@ -206,6 +206,10 @@ extern fasttrap_scrspace_t *fasttrap_scr
extern dtrace_id_t fasttrap_probe_id;
extern fasttrap_hash_t fasttrap_tpoints;
+#ifndef illumos
+extern struct rmlock fasttrap_tp_lock;
+#endif
+
#define FASTTRAP_TPOINTS_INDEX(pid, pc) \
(((pc) / sizeof (fasttrap_instr_t) + (pid)) & fasttrap_tpoints.fth_mask)
Modified: stable/10/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c Tue May 3 19:45:24 2016 (r299002)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c Tue May 3 20:08:05 2016 (r299003)
@@ -46,6 +46,7 @@
#include <cddl/dev/dtrace/dtrace_cddl.h>
#include <sys/types.h>
#include <sys/proc.h>
+#include <sys/rmlock.h>
#include <sys/dtrace_bsd.h>
#include <cddl/dev/dtrace/x86/regset.h>
#include <machine/segments.h>
@@ -749,11 +750,13 @@ fasttrap_return_common(struct reg *rp, u
fasttrap_id_t *id;
#ifdef illumos
kmutex_t *pid_mtx;
-#endif
-#ifdef illumos
pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
mutex_enter(pid_mtx);
+#else
+ struct rm_priotracker tracker;
+
+ rm_rlock(&fasttrap_tp_lock, &tracker);
#endif
bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
@@ -771,6 +774,8 @@ fasttrap_return_common(struct reg *rp, u
if (tp == NULL) {
#ifdef illumos
mutex_exit(pid_mtx);
+#else
+ rm_runlock(&fasttrap_tp_lock, &tracker);
#endif
return;
}
@@ -794,6 +799,8 @@ fasttrap_return_common(struct reg *rp, u
#ifdef illumos
mutex_exit(pid_mtx);
+#else
+ rm_runlock(&fasttrap_tp_lock, &tracker);
#endif
}
@@ -1002,6 +1009,7 @@ fasttrap_pid_probe(struct reg *rp)
{
proc_t *p = curproc;
#ifndef illumos
+ struct rm_priotracker tracker;
proc_t *pp;
#endif
uintptr_t pc = rp->r_rip - 1;
@@ -1061,8 +1069,7 @@ fasttrap_pid_probe(struct reg *rp)
sx_sunlock(&proctree_lock);
pp = NULL;
- PROC_LOCK(p);
- _PHOLD(p);
+ rm_rlock(&fasttrap_tp_lock, &tracker);
#endif
bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
@@ -1085,8 +1092,7 @@ fasttrap_pid_probe(struct reg *rp)
#ifdef illumos
mutex_exit(pid_mtx);
#else
- _PRELE(p);
- PROC_UNLOCK(p);
+ rm_runlock(&fasttrap_tp_lock, &tracker);
#endif
return (-1);
}
@@ -1212,7 +1218,7 @@ fasttrap_pid_probe(struct reg *rp)
#ifdef illumos
mutex_exit(pid_mtx);
#else
- PROC_UNLOCK(p);
+ rm_runlock(&fasttrap_tp_lock, &tracker);
#endif
tp = &tp_local;
@@ -1825,7 +1831,6 @@ done:
#ifndef illumos
PROC_LOCK(p);
proc_write_regs(curthread, rp);
- _PRELE(p);
PROC_UNLOCK(p);
#endif
Modified: stable/10/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
==============================================================================
--- stable/10/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c Tue May 3 19:45:24 2016 (r299002)
+++ stable/10/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c Tue May 3 20:08:05 2016 (r299003)
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/ptrace.h>
+#include <sys/rmlock.h>
#include <sys/sysent.h>
#define OP(x) ((x) >> 26)
@@ -302,10 +303,12 @@ static void
fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
uintptr_t new_pc)
{
+ struct rm_priotracker tracker;
fasttrap_tracepoint_t *tp;
fasttrap_bucket_t *bucket;
fasttrap_id_t *id;
+ rm_rlock(&fasttrap_tp_lock, &tracker);
bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
for (tp = bucket->ftb_data; tp != NULL; tp = tp->ftt_next) {
@@ -320,6 +323,7 @@ fasttrap_return_common(struct reg *rp, u
* is not essential to the correct execution of the process.
*/
if (tp == NULL) {
+ rm_runlock(&fasttrap_tp_lock, &tracker);
return;
}
@@ -337,6 +341,7 @@ fasttrap_return_common(struct reg *rp, u
pc - id->fti_probe->ftp_faddr,
rp->fixreg[3], rp->fixreg[4], 0, 0);
}
+ rm_runlock(&fasttrap_tp_lock, &tracker);
}
@@ -365,6 +370,7 @@ fasttrap_branch_taken(int bo, int bi, st
int
fasttrap_pid_probe(struct reg *rp)
{
+ struct rm_priotracker tracker;
proc_t *p = curproc;
uintptr_t pc = rp->pc;
uintptr_t new_pc = 0;
@@ -395,8 +401,7 @@ fasttrap_pid_probe(struct reg *rp)
curthread->t_dtrace_scrpc = 0;
curthread->t_dtrace_astpc = 0;
-
- PROC_LOCK(p);
+ rm_rlock(&fasttrap_tp_lock, &tracker);
pid = p->p_pid;
bucket = &fasttrap_tpoints.fth_table[FASTTRAP_TPOINTS_INDEX(pid, pc)];
@@ -415,7 +420,7 @@ fasttrap_pid_probe(struct reg *rp)
* fasttrap_ioctl), or somehow we have mislaid this tracepoint.
*/
if (tp == NULL) {
- PROC_UNLOCK(p);
+ rm_runlock(&fasttrap_tp_lock, &tracker);
return (-1);
}
@@ -469,7 +474,7 @@ fasttrap_pid_probe(struct reg *rp)
* tracepoint again later if we need to light up any return probes.
*/
tp_local = *tp;
- PROC_UNLOCK(p);
+ rm_runlock(&fasttrap_tp_lock, &tracker);
tp = &tp_local;
/*
More information about the svn-src-stable
mailing list