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

From: Mark Millard <marklmi_at_yahoo.com>
Date: Tue, 20 May 2025 05:51:12 UTC
Dennis Clarke <dclarke_at_blastwave.org> wrote on
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) {

Looks to me like "out of required resources, cannot
continue with the mode of use" code: an empty free
list so no node is available to put to use to
continue with the witness handling.

> 		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?

Until the next boot, anyway.

===
Mark Millard
marklmi at yahoo.com