From c2c0b0cf71ce557aae83f97fc19afa3becb5a76f Mon Sep 17 00:00:00 2001 From: mpi Date: Sat, 6 Apr 2024 11:18:02 +0000 Subject: [PATCH] Remove (unused) in-kernel event filtering, it's currently dead code. All events are currently exported to userland in order to support complex filters. If this becomes a bottleneck it should be possible to translate (some) user-land filters to in-kernel fitlers. Prodded by a diff from Christian Ludwig to also trace the tracing program. ok claudio@ --- sys/dev/dt/dt_dev.c | 77 +----------------------------------- sys/dev/dt/dt_prov_kprobe.c | 3 +- sys/dev/dt/dt_prov_profile.c | 4 +- sys/dev/dt/dt_prov_static.c | 4 +- sys/dev/dt/dt_prov_syscall.c | 4 +- sys/dev/dt/dtvar.h | 27 +------------ 6 files changed, 6 insertions(+), 113 deletions(-) diff --git a/sys/dev/dt/dt_dev.c b/sys/dev/dt/dt_dev.c index 98b19792d82..2d01b4f5eee 100644 --- a/sys/dev/dt/dt_dev.c +++ b/sys/dev/dt/dt_dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_dev.c,v 1.32 2024/02/29 00:18:48 cheloha Exp $ */ +/* $OpenBSD: dt_dev.c,v 1.33 2024/04/06 11:18:02 mpi Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -347,30 +347,6 @@ dtlookup(int unit) return sc; } -int -dtioc_req_isvalid(struct dtioc_req *dtrq) -{ - switch (dtrq->dtrq_filter.dtf_operand) { - case DT_OP_NONE: - case DT_OP_EQ: - case DT_OP_NE: - break; - default: - return 0; - } - - switch (dtrq->dtrq_filter.dtf_variable) { - case DT_FV_NONE: - case DT_FV_PID: - case DT_FV_TID: - break; - default: - return 0; - } - - return 1; -} - int dt_ioctl_list_probes(struct dt_softc *sc, struct dtioc_probe *dtpr) { @@ -552,9 +528,6 @@ dt_ioctl_probe_enable(struct dt_softc *sc, struct dtioc_req *dtrq) struct dt_probe *dtp; int error; - if (!dtioc_req_isvalid(dtrq)) - return EINVAL; - SIMPLEQ_FOREACH(dtp, &dt_probe_list, dtp_next) { if (dtp->dtp_pbn == dtrq->dtrq_pbn) break; @@ -582,9 +555,6 @@ dt_ioctl_probe_disable(struct dt_softc *sc, struct dtioc_req *dtrq) struct dt_probe *dtp; int error; - if (!dtioc_req_isvalid(dtrq)) - return EINVAL; - SIMPLEQ_FOREACH(dtp, &dt_probe_list, dtp_next) { if (dtp->dtp_pbn == dtrq->dtrq_pbn) break; @@ -711,48 +681,6 @@ dt_pcb_purge(struct dt_pcb_list *plist) } } -int -dt_pcb_filter(struct dt_pcb *dp) -{ - struct dt_filter *dtf = &dp->dp_filter; - struct proc *p = curproc; - unsigned int var = 0; - int match = 1; - - /* Filter out tracing program. */ - if (dp->dp_sc->ds_pid == p->p_p->ps_pid) - return 1; - - switch (dtf->dtf_variable) { - case DT_FV_PID: - var = p->p_p->ps_pid; - break; - case DT_FV_TID: - var = p->p_tid + THREAD_PID_OFFSET; - break; - case DT_FV_NONE: - break; - default: - KASSERT(0); - } - - switch (dtf->dtf_operand) { - case DT_OP_EQ: - match = !!(var == dtf->dtf_value); - break; - case DT_OP_NE: - match = !!(var != dtf->dtf_value); - break; - case DT_OP_NONE: - break; - default: - KASSERT(0); - } - - return !match; -} - - /* * Get a reference to the next free event state from the ring. */ @@ -763,9 +691,6 @@ dt_pcb_ring_get(struct dt_pcb *dp, int profiling) struct dt_evt *dtev; int distance; - if (dt_pcb_filter(dp)) - return NULL; - mtx_enter(&dp->dp_mtx); distance = dp->dp_prod - dp->dp_cons; if (distance == 1 || distance == (1 - DT_EVTRING_SIZE)) { diff --git a/sys/dev/dt/dt_prov_kprobe.c b/sys/dev/dt/dt_prov_kprobe.c index c506b6908d3..f929dd56d6f 100644 --- a/sys/dev/dt/dt_prov_kprobe.c +++ b/sys/dev/dt/dt_prov_kprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_prov_kprobe.c,v 1.7 2023/07/06 10:53:11 jasper Exp $ */ +/* $OpenBSD: dt_prov_kprobe.c,v 1.8 2024/04/06 11:18:02 mpi Exp $ */ /* * Copyright (c) 2020 Tom Rollet @@ -263,7 +263,6 @@ dt_prov_kprobe_alloc(struct dt_probe *dtp, struct dt_softc *sc, intr_restore(s); } - dp->dp_filter = dtrq->dtrq_filter; dp->dp_evtflags = dtrq->dtrq_evtflags & DTEVT_PROV_KPROBE; TAILQ_INSERT_HEAD(plist, dp, dp_snext); return 0; diff --git a/sys/dev/dt/dt_prov_profile.c b/sys/dev/dt/dt_prov_profile.c index 26972585d04..62900152e14 100644 --- a/sys/dev/dt/dt_prov_profile.c +++ b/sys/dev/dt/dt_prov_profile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_prov_profile.c,v 1.7 2024/03/13 13:13:57 bluhm Exp $ */ +/* $OpenBSD: dt_prov_profile.c,v 1.8 2024/04/06 11:18:02 mpi Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -72,7 +72,6 @@ dt_prov_profile_alloc(struct dt_probe *dtp, struct dt_softc *sc, CPU_INFO_ITERATOR cii; extern int hz; - KASSERT(dtioc_req_isvalid(dtrq)); KASSERT(TAILQ_EMPTY(plist)); KASSERT(dtp == dtpp_profile || dtp == dtpp_interval); @@ -92,7 +91,6 @@ dt_prov_profile_alloc(struct dt_probe *dtp, struct dt_softc *sc, dp->dp_nsecs = SEC_TO_NSEC(1) / dtrq->dtrq_rate; dp->dp_cpu = ci; - dp->dp_filter = dtrq->dtrq_filter; dp->dp_evtflags = dtrq->dtrq_evtflags & DTEVT_PROV_PROFILE; TAILQ_INSERT_HEAD(plist, dp, dp_snext); } diff --git a/sys/dev/dt/dt_prov_static.c b/sys/dev/dt/dt_prov_static.c index d03badccbbe..4a87bc9161a 100644 --- a/sys/dev/dt/dt_prov_static.c +++ b/sys/dev/dt/dt_prov_static.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_prov_static.c,v 1.22 2023/08/28 14:50:01 bluhm Exp $ */ +/* $OpenBSD: dt_prov_static.c,v 1.23 2024/04/06 11:18:02 mpi Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -179,14 +179,12 @@ dt_prov_static_alloc(struct dt_probe *dtp, struct dt_softc *sc, { struct dt_pcb *dp; - KASSERT(dtioc_req_isvalid(dtrq)); KASSERT(TAILQ_EMPTY(plist)); dp = dt_pcb_alloc(dtp, sc); if (dp == NULL) return ENOMEM; - dp->dp_filter = dtrq->dtrq_filter; dp->dp_evtflags = dtrq->dtrq_evtflags; TAILQ_INSERT_HEAD(plist, dp, dp_snext); diff --git a/sys/dev/dt/dt_prov_syscall.c b/sys/dev/dt/dt_prov_syscall.c index f272ac768f9..03c561eece8 100644 --- a/sys/dev/dt/dt_prov_syscall.c +++ b/sys/dev/dt/dt_prov_syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_prov_syscall.c,v 1.8 2023/04/13 02:19:05 jsg Exp $ */ +/* $OpenBSD: dt_prov_syscall.c,v 1.9 2024/04/06 11:18:02 mpi Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -101,7 +101,6 @@ dt_prov_syscall_alloc(struct dt_probe *dtp, struct dt_softc *sc, { struct dt_pcb *dp; - KASSERT(dtioc_req_isvalid(dtrq)); KASSERT(TAILQ_EMPTY(plist)); KASSERT(dtp->dtp_prov == &dt_prov_syscall); KASSERT((dtp->dtp_sysnum >= 0) && (dtp->dtp_sysnum < dtps_nsysent)); @@ -110,7 +109,6 @@ dt_prov_syscall_alloc(struct dt_probe *dtp, struct dt_softc *sc, if (dp == NULL) return ENOMEM; - dp->dp_filter = dtrq->dtrq_filter; dp->dp_evtflags = dtrq->dtrq_evtflags & DTEVT_PROV_SYSCALL; TAILQ_INSERT_HEAD(plist, dp, dp_snext); diff --git a/sys/dev/dt/dtvar.h b/sys/dev/dt/dtvar.h index f69a41c6506..5bb7ab0d771 100644 --- a/sys/dev/dt/dtvar.h +++ b/sys/dev/dt/dtvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dtvar.h,v 1.18 2024/02/09 17:42:18 cheloha Exp $ */ +/* $OpenBSD: dtvar.h,v 1.19 2024/04/06 11:18:02 mpi Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -82,26 +82,6 @@ struct dt_evt { "\003KSTACK" \ "\004FUNCARGS" \ -/* - * Each PCB can have a filter attached to itself. A filter do not - * prevent an enabled probe to fire, but when that happens, event - * states are only recorded if it is matched. - */ -struct dt_filter { - enum dt_operand { - DT_OP_NONE = 0, - DT_OP_EQ, - DT_OP_NE, - } dtf_operand; - enum dt_filtervar { - DT_FV_NONE = 0, - DT_FV_PID, - DT_FV_TID, - } dtf_variable /* what should be filtered */; - unsigned int dtf_value; /* PID or TID to filter */ -}; - - struct dtioc_probe_info { uint32_t dtpi_pbn; /* probe number */ uint8_t dtpi_nargs; /* # of arguments */ @@ -129,7 +109,6 @@ struct dtioc_arg { struct dtioc_req { uint32_t dtrq_pbn; /* probe number */ - struct dt_filter dtrq_filter; /* probe filter */ uint32_t dtrq_rate; /* number of ticks */ uint64_t dtrq_evtflags; /* states to record */ }; @@ -165,8 +144,6 @@ struct dtioc_getaux { struct dt_softc; -int dtioc_req_isvalid(struct dtioc_req *); - /* * Probe control block, possibly per-CPU. * @@ -195,7 +172,6 @@ struct dt_pcb { struct dt_softc *dp_sc; /* [I] related softc */ struct dt_probe *dp_dtp; /* [I] related probe */ uint64_t dp_evtflags; /* [I] event states to record */ - struct dt_filter dp_filter; /* [I] filter to match */ /* Provider specific fields. */ struct clockintr dp_clockintr; /* [D] profiling handle */ @@ -211,7 +187,6 @@ TAILQ_HEAD(dt_pcb_list, dt_pcb); struct dt_pcb *dt_pcb_alloc(struct dt_probe *, struct dt_softc *); void dt_pcb_free(struct dt_pcb *); void dt_pcb_purge(struct dt_pcb_list *); -int dt_pcb_filter(struct dt_pcb *); struct dt_evt *dt_pcb_ring_get(struct dt_pcb *, int); void dt_pcb_ring_consume(struct dt_pcb *, struct dt_evt *); -- 2.20.1