Just a question about sys/kern/subr_witness.c where witness_watch may be flipped to -1

From: Dennis Clarke <dclarke_at_blastwave.org>
Date: Tue, 20 May 2025 02:33:58 UTC
Just an odd message to see on the console :

     # witness_lock_list_get: witness exhausted

Looking at https://cgit.freebsd.org/src/tree/sys/kern/subr_witness.c it
seems that the comment at line 370 is very clear :

/*
  * If set to 0, lock order checking is disabled.  If set to -1,
  * witness is completely disabled.  Otherwise witness performs full
  * lock order checking for all locks.  At runtime, lock order checking
  * may be toggled.  However, witness cannot be reenabled once it is
  * completely disabled.
  */
static int witness_watch = 1;

So I wonder how I managed to get that message "witness exhausted" ?

At line 2203 I see :

static struct lock_list_entry *
witness_lock_list_get(void)
{
	struct lock_list_entry *lle;

	if (witness_watch == -1)
		return (NULL);
	mtx_lock_spin(&w_mtx);
	lle = w_lock_list_free;
	if (lle == NULL) {
		witness_watch = -1;
		mtx_unlock_spin(&w_mtx);
		printf("%s: witness exhausted\n", __func__);
		return (NULL);
	}
	w_lock_list_free = lle->ll_next;
	mtx_unlock_spin(&w_mtx);
	bzero(lle, sizeof(*lle));
	return (lle);
}

Where it seems that indeed witness_watch has been flipped to -1 and that 
functionality is now gone?



-- 
--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken

ps: the comment at line 43 is just plain silly.