-/* $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 <mpi@openbsd.org>
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)
{
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;
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;
}
}
-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.
*/
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)) {
-/* $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 <tom.rollet@epita.fr>
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;
-/* $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 <mpi@openbsd.org>
CPU_INFO_ITERATOR cii;
extern int hz;
- KASSERT(dtioc_req_isvalid(dtrq));
KASSERT(TAILQ_EMPTY(plist));
KASSERT(dtp == dtpp_profile || dtp == dtpp_interval);
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);
}
-/* $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 <mpi@openbsd.org>
{
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);
-/* $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 <mpi@openbsd.org>
{
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));
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);
-/* $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 <mpi@openbsd.org>
"\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 */
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 */
};
struct dt_softc;
-int dtioc_req_isvalid(struct dtioc_req *);
-
/*
* Probe control block, possibly per-CPU.
*
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 */
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 *);