Introduce kcov_silence_enter() and kcov_silence_leave(), to allow to
temporarily disable KCOV on the current lwp. Should be used in the rare but problematic cases where extreme noise is introduced by an uninteresting subsystem. Use this capability to silence KCOV during the LOCKDEBUG lookups. This divides the size of the KCOV output by more than two in my KCOV+vHCI tests.
This commit is contained in:
parent
5e7beab597
commit
69ffbd327c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_kcov.c,v 1.13 2020/05/15 12:34:52 maxv Exp $ */
|
||||
/* $NetBSD: subr_kcov.c,v 1.14 2020/05/15 13:09:02 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
|
||||
|
@ -108,6 +108,7 @@ typedef struct kcov_desc {
|
|||
/* Local only */
|
||||
kmutex_t lock;
|
||||
bool lwpfree;
|
||||
bool silenced;
|
||||
|
||||
/* Pointer to the end of the structure, if any */
|
||||
struct kcov_desc *remote;
|
||||
|
@ -423,6 +424,26 @@ kcov_disable(kcov_t *kd)
|
|||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
kcov_silence_enter(void)
|
||||
{
|
||||
kcov_t *kd = curlwp->l_kcov;
|
||||
|
||||
if (kd != NULL)
|
||||
kd->silenced = true;
|
||||
}
|
||||
|
||||
void
|
||||
kcov_silence_leave(void)
|
||||
{
|
||||
kcov_t *kd = curlwp->l_kcov;
|
||||
|
||||
if (kd != NULL)
|
||||
kd->silenced = false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
kcov_open(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
{
|
||||
|
@ -581,6 +602,11 @@ __sanitizer_cov_trace_pc(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (__predict_false(kd->silenced)) {
|
||||
/* Silenced. */
|
||||
return;
|
||||
}
|
||||
|
||||
if (kd->mode != KCOV_MODE_TRACE_PC) {
|
||||
/* PC tracing mode not enabled */
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: subr_lockdebug.c,v 1.76 2020/04/10 17:16:21 ad Exp $ */
|
||||
/* $NetBSD: subr_lockdebug.c,v 1.77 2020/05/15 13:09:02 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.76 2020/04/10 17:16:21 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.77 2020/05/15 13:09:02 maxv Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ddb.h"
|
||||
|
@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.76 2020/04/10 17:16:21 ad Exp $
|
|||
#include <sys/lock.h>
|
||||
#include <sys/rbtree.h>
|
||||
#include <sys/ksyms.h>
|
||||
#include <sys/kcov.h>
|
||||
|
||||
#include <machine/lock.h>
|
||||
|
||||
|
@ -209,7 +210,10 @@ lockdebug_lookup(const char *func, size_t line, const volatile void *lock,
|
|||
{
|
||||
lockdebug_t *ld;
|
||||
|
||||
kcov_silence_enter();
|
||||
ld = lockdebug_lookup1(lock);
|
||||
kcov_silence_leave();
|
||||
|
||||
if (__predict_false(ld == NULL)) {
|
||||
panic("%s,%zu: uninitialized lock (lock=%p, from=%08"
|
||||
PRIxPTR ")", func, line, lock, where);
|
||||
|
@ -675,6 +679,8 @@ lockdebug_mem_check(const char *func, size_t line, void *base, size_t sz)
|
|||
if (__predict_false(panicstr != NULL || ld_panic))
|
||||
return;
|
||||
|
||||
kcov_silence_enter();
|
||||
|
||||
s = splhigh();
|
||||
ci = curcpu();
|
||||
__cpu_simple_lock(&ci->ci_data.cpu_ld_lock);
|
||||
|
@ -693,9 +699,12 @@ lockdebug_mem_check(const char *func, size_t line, void *base, size_t sz)
|
|||
__cpu_simple_lock(&ld->ld_spinlock);
|
||||
lockdebug_abort1(func, line, ld, s,
|
||||
"allocation contains active lock", !cold);
|
||||
kcov_silence_leave();
|
||||
return;
|
||||
}
|
||||
splx(s);
|
||||
|
||||
kcov_silence_leave();
|
||||
}
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kcov.h,v 1.8 2020/05/15 12:34:52 maxv Exp $ */
|
||||
/* $NetBSD: kcov.h,v 1.9 2020/05/15 13:09:02 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
|
||||
|
@ -66,11 +66,15 @@ typedef volatile uint64_t kcov_int_t;
|
|||
void kcov_remote_register(uint64_t, uint64_t);
|
||||
void kcov_remote_enter(uint64_t, uint64_t);
|
||||
void kcov_remote_leave(uint64_t, uint64_t);
|
||||
void kcov_silence_enter(void);
|
||||
void kcov_silence_leave(void);
|
||||
void kcov_lwp_free(struct lwp *);
|
||||
#else
|
||||
#define kcov_remote_register(s, i) __nothing
|
||||
#define kcov_remote_enter(s, i) __nothing
|
||||
#define kcov_remote_leave(s, i) __nothing
|
||||
#define kcov_silence_enter() __nothing
|
||||
#define kcov_silence_leave() __nothing
|
||||
#define kcov_lwp_free(a) __nothing
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue