-/* $OpenBSD: dt_prov_kprobe.c,v 1.1 2021/09/03 16:45:45 jasper Exp $ */
+/* $OpenBSD: dt_prov_kprobe.c,v 1.2 2021/10/25 17:15:29 jasper Exp $ */
/*
* Copyright (c) 2020 Tom Rollet <tom.rollet@epita.fr>
return ENOMEM;
/* Patch only if it's first pcb referencing this probe */
- mtx_enter(&dtp->dtp_mtx);
dtp->dtp_ref++;
KASSERT(dtp->dtp_ref != 0);
db_write_bytes(dtp->dtp_addr, BKPT_SIZE, &patch);
intr_restore(s);
}
- mtx_leave(&dtp->dtp_mtx);
dp->dp_filter = dtrq->dtrq_filter;
dp->dp_evtflags = dtrq->dtrq_evtflags & DTEVT_PROV_KPROBE;
} else
KASSERT(0 && "Trying to dealloc not yet implemented probe type");
- mtx_enter(&dtp->dtp_mtx);
dtp->dtp_ref--;
if (dtp->dtp_ref == 0) {
intr_restore(s);
}
- mtx_leave(&dtp->dtp_mtx);
-
/* Deallocation of PCB is done by dt_pcb_purge when closing the dev */
return 0;
}
for (i = 0; i < PPTMASK; ++i) {
SLIST_FOREACH(kprobe_dtp, &dtpf_entry[i], kprobe_next) {
dtp = kprobe_dtp->dtp;
-
- mtx_enter(&dtp->dtp_mtx);
dtp->dtp_ref++;
if (dtp->dtp_ref == 1) {
db_write_bytes(dtp->dtp_addr, BKPT_SIZE, &patch);
intr_restore(s);
}
-
- mtx_leave(&dtp->dtp_mtx);
}
}
}
for (i = 0; i < PPTMASK; ++i) {
SLIST_FOREACH(kprobe_dtp, &dtpf_entry[i], kprobe_next) {
dtp = kprobe_dtp->dtp;
-
- mtx_enter(&dtp->dtp_mtx);
dtp->dtp_ref--;
if (dtp->dtp_ref == 0) {
db_write_bytes(dtp->dtp_addr, SSF_SIZE, &patch);
intr_restore(s);
}
-
- mtx_leave(&dtp->dtp_mtx);
}
}
-/* $OpenBSD: dtvar.h,v 1.8 2021/09/03 16:45:45 jasper Exp $ */
+/* $OpenBSD: dtvar.h,v 1.9 2021/10/25 17:15:29 jasper Exp $ */
/*
* Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org>
const char *dtp_name; /* [I] probe name */
uint32_t dtp_pbn; /* [I] unique ID */
volatile uint32_t dtp_recording; /* [d] is it recording? */
- struct mutex dtp_mtx;
unsigned dtp_ref; /* [m] # of PCBs referencing the probe */
/* Provider specific fields. */