-/* $OpenBSD: kcov.c,v 1.42 2021/12/27 15:38:25 anton Exp $ */
+/* $OpenBSD: kcov.c,v 1.43 2021/12/28 17:50:10 anton Exp $ */
/*
* Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
struct kcov_dev {
int kd_state; /* [M] */
int kd_mode; /* [M] */
- int kd_unit; /* [I] device minor */
+ int kd_unit; /* [I] D_CLONE unique device minor */
int kd_intr; /* [M] currently used in interrupt */
uintptr_t *kd_buf; /* [a] traced coverage */
size_t kd_nmemb; /* [I] */
{
struct kcov_dev *kd;
- mtx_enter(&kcov_mtx);
-
- if (kd_lookup(minor(dev)) != NULL) {
- mtx_leave(&kcov_mtx);
- return (EBUSY);
- }
-
- if (kcov_cold)
- kcov_cold = 0;
-
- mtx_leave(&kcov_mtx);
kd = malloc(sizeof(*kd), M_SUBPROC, M_WAITOK | M_ZERO);
kd->kd_unit = minor(dev);
mtx_enter(&kcov_mtx);
+ KASSERT(kd_lookup(kd->kd_unit) == NULL);
TAILQ_INSERT_TAIL(&kd_list, kd, kd_entry);
+ if (kcov_cold)
+ kcov_cold = 0;
mtx_leave(&kcov_mtx);
return (0);
}