From nobody Sat Oct 10 18:29:04 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4j2C1D6y3jz6vdN1 for ; Sat, 10 Oct 2026 18:29:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4j2C1D32cNz4nFS for ; Sat, 10 Oct 2026 18:29:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791656944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8l6c+J10nPOu3np9k/Ej9qVnhCxE2s3By2+geH6YwvE=; b=hF86l6YePep8wJPMG+wFhODwkbIxxc511ad83T01ML5mwDmvd/jADkpJUJ828pIwTGHEFd 8CrMaS8iNPCbfDDsMUUsdmQG5jznjjjAy5cg2jo1S+pmMU4JQi//gecF9+9wNynEeTUpJx 9AuTf3wKpAHFUBbqCZRFtlbkNpzGoQ2EEF2V+QXh+/+KjL7wCp7zZdU8qKdTc0B795MfkN aQ8OQpUCfjgtvgdKCUMcWS4Kv+BvkNlnIGuMk4TRBHRtTWC4k+WKMDuh5FRJ1i7lasWRC2 rTPMD5TyY8qzvRNj6tTOgPniLLZPxlOGaw6d4VF0uv0q9o7ESg/rqKtHN7VYIQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791656944; b=R+tvXmz8VzZgmWHg0/5BPoTK6F6uZpKk66MWzCEbS/aotCFEPEdTsB5aKZR40zMdAUDsrW lECApVSSq5XU80RbZVd6IlhRz/k7lPcjF884tQEDWqF+QlJdB357uM/7prd7HfFeKsMKwz 5vPZqdC0jq7MmvlxwJBY4xl/stVzkt7LBC0ZEUMsY2Ig1SZlfnzK6xo2MSuecC9/0LXFoP mVreOZoYB7KH1Sjoa6x0X7lQDR5YOXyuf0fAOc0E7kccw08/FWLcyy7LylkDu8fpNWZ5Wi km+vg+aJrZEEmPRuMJOS2vhD4swTl17rmbKjfVZmCiCg+yPqW/C4SzbbIATdvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791656944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8l6c+J10nPOu3np9k/Ej9qVnhCxE2s3By2+geH6YwvE=; b=ExgU96qbtbTS3T+oMQ9Mduox0YK/EWo/IGjfeVZXrkLjOhXnb/j4duHPoaHIjgBO5yVSw4 RLg2lsl4ycyMmWVml0SdHRgZuC+iD4ikmldOE2G+X+z5aGAZzXyjMxISQX8Uf2jyacD+eD SQkxc0CIzjD5mHBfxpgQwx7/QxaTv5MXxwEsLth5OFYCRYGN0G18UoWV5+gz+LEW0HFlk6 51ukv1hdArafnTzOVuq2WF06qJULzmR3MbpRzMee3uyuuY2xpqWHhEpa1MXbcWNpJZYaZa jTmPmthTHgPXM1eRJBUR3dWx4i4v1bnwrslG/Nu68xhHLBWk7RzPGRmt1sGVgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4j2C1D21CYz15QC for ; Sat, 10 Oct 2026 18:29:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 22618 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 10 Oct 2026 18:29:04 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bjoern A. Zeeb Subject: git: bbfd52dcbeb7 - main - LinuxKPI: use LINUXKPI_DEBUG to determine on witness lock tracing List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bbfd52dcbeb7b6e540220b3b24b664df6d200200 Auto-Submitted: auto-generated Date: Sat, 10 Oct 2026 18:29:04 +0000 Message-Id: <6aca83f0.22618.7c52ec5d@gitrepo.freebsd.org> The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=bbfd52dcbeb7b6e540220b3b24b664df6d200200 commit bbfd52dcbeb7b6e540220b3b24b664df6d200200 Author: Bjoern A. Zeeb AuthorDate: 2026-08-21 13:15:22 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-10-10 18:28:33 +0000 LinuxKPI: use LINUXKPI_DEBUG to determine on witness lock tracing LinuxKPI by default tells witness to ignore the locks, which is unhelpful in case of panics like 'panic: sleeping thread holds lnxspin'. While I have edited the lock initialitzation manually in the past, make this dependent on both LINUXKPI_DEBUG and WITNESS. Define an internal _LKPI_MTX_NOWITNESS (and equivalent for other lock types used) and set them accordingly in kconfig.h, a file automatically included to all LinuxKPI compiled code (like global.h). (*) In addition, in the debug case, also define WITNESS_ALL to get file, line, and lock name as a lock name rather than just, e.g., lnxspin. (*) We will need another follow-up as -include ordering is currently wrong for LinuxKPI modules. See D60207. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D59231 --- sys/compat/linuxkpi/common/include/linux/kconfig.h | 29 +++++++++++++++++++++- sys/compat/linuxkpi/common/include/linux/mutex.h | 4 +-- sys/compat/linuxkpi/common/include/linux/rwlock.h | 2 +- sys/compat/linuxkpi/common/include/linux/rwsem.h | 2 +- sys/compat/linuxkpi/common/include/linux/seqlock.h | 2 +- .../linuxkpi/common/include/linux/spinlock.h | 8 +++--- sys/compat/linuxkpi/common/include/linux/wait.h | 2 +- .../linuxkpi/common/include/linux/ww_mutex.h | 2 +- sys/compat/linuxkpi/common/src/linux_hrtimer.c | 2 +- sys/compat/linuxkpi/common/src/linux_work.c | 2 +- 10 files changed, 42 insertions(+), 13 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kconfig.h b/sys/compat/linuxkpi/common/include/linux/kconfig.h index 529d41991900..232bdd13656c 100644 --- a/sys/compat/linuxkpi/common/include/linux/kconfig.h +++ b/sys/compat/linuxkpi/common/include/linux/kconfig.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2020 The FreeBSD Foundation + * Copyright (c) 2020-2026 The FreeBSD Foundation * * This software was developed by Björn Zeeb under sponsorship from * the FreeBSD Foundation. @@ -31,6 +31,33 @@ #ifndef _LINUXKPI_LINUX_KCONFIG_H_ #define _LINUXKPI_LINUX_KCONFIG_H_ +/* -------------------------------------------------------------------------- */ +#include "opt_linuxkpi.h" + +/* + * LinuxKPI internals are here as this file is globally included for everything + * compiled with LinuxKPI. + */ + +/* + * Do not tell witness to ignore locks if debugging and witness are enabled. + * This helps debugging and hopefully also long-term code quality. + */ +#if defined(LINUXKPI_DEBUG) && defined(WITNESS) +#define _LKPI_MTX_NOWITNESS (0) +#define _LKPI_RW_NOWITNESS (0) +#define _LKPI_SX_NOWITNESS (0) +#define WITNESS_ALL /* Get better lock names. */ +#else +#define _LKPI_MTX_NOWITNESS MTX_NOWITNESS +#define _LKPI_RW_NOWITNESS RW_NOWITNESS +#define _LKPI_SX_NOWITNESS SX_NOWITNESS +#endif + + + +/* -------------------------------------------------------------------------- */ + /* * Checking if an option is defined would be easy if we could do CPP inside CPP. * The defined case whether -Dxxx or -Dxxx=1 are easy to deal with. In either diff --git a/sys/compat/linuxkpi/common/include/linux/mutex.h b/sys/compat/linuxkpi/common/include/linux/mutex.h index 64d76491a76f..8008cb574552 100644 --- a/sys/compat/linuxkpi/common/include/linux/mutex.h +++ b/sys/compat/linuxkpi/common/include/linux/mutex.h @@ -109,10 +109,10 @@ mutex_trylock_recursive(struct mutex *lock) } #define mutex_init(_m) \ - linux_mutex_init(_m, mutex_name(#_m), SX_NOWITNESS) + linux_mutex_init(_m, mutex_name(#_m), _LKPI_SX_NOWITNESS) #define __mutex_init(_m, _n, _l) \ - linux_mutex_init(_m, _n, SX_NOWITNESS) + linux_mutex_init(_m, _n, _LKPI_SX_NOWITNESS) #define mutex_init_witness(_m) \ linux_mutex_init(_m, mutex_name(#_m), SX_DUPOK) diff --git a/sys/compat/linuxkpi/common/include/linux/rwlock.h b/sys/compat/linuxkpi/common/include/linux/rwlock.h index 3030ec89ff1e..1a75831d3750 100644 --- a/sys/compat/linuxkpi/common/include/linux/rwlock.h +++ b/sys/compat/linuxkpi/common/include/linux/rwlock.h @@ -52,6 +52,6 @@ typedef struct rwlock rwlock_t; do { read_unlock(lock); } while (0) #define write_unlock_irqrestore(lock, flags) \ do { write_unlock(lock); } while (0) -#define rwlock_init(_l) rw_init_flags(_l, "lnxrw", RW_NOWITNESS | RW_NEW) +#define rwlock_init(_l) rw_init_flags(_l, "lnxrw", _LKPI_RW_NOWITNESS | RW_NEW) #endif /* _LINUXKPI_LINUX_RWLOCK_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/rwsem.h b/sys/compat/linuxkpi/common/include/linux/rwsem.h index 43688ab93796..2fed94f0a81a 100644 --- a/sys/compat/linuxkpi/common/include/linux/rwsem.h +++ b/sys/compat/linuxkpi/common/include/linux/rwsem.h @@ -77,7 +77,7 @@ linux_init_rwsem(struct rw_semaphore *rw, const char *name) { memset(rw, 0, sizeof(*rw)); - sx_init_flags(&rw->sx, name, SX_NOWITNESS); + sx_init_flags(&rw->sx, name, _LKPI_SX_NOWITNESS); } extern int linux_down_read_killable(struct rw_semaphore *); diff --git a/sys/compat/linuxkpi/common/include/linux/seqlock.h b/sys/compat/linuxkpi/common/include/linux/seqlock.h index 554fdfd6e202..be2fe5f3daed 100644 --- a/sys/compat/linuxkpi/common/include/linux/seqlock.h +++ b/sys/compat/linuxkpi/common/include/linux/seqlock.h @@ -119,7 +119,7 @@ seqlock_init(struct seqlock *seqlock) * seqlock has been freed. There is no seqlock destructor exists so we * can't expect automatic mtx_destroy() execution before free(). */ - mtx_init(&seqlock->seql_lock, "seqlock", NULL, MTX_DEF|MTX_NOWITNESS); + mtx_init(&seqlock->seql_lock, "seqlock", NULL, MTX_DEF | _LKPI_MTX_NOWITNESS); seqcount_init(&seqlock->seql_count); } diff --git a/sys/compat/linuxkpi/common/include/linux/spinlock.h b/sys/compat/linuxkpi/common/include/linux/spinlock.h index a786cbab5e13..258322ea8ce7 100644 --- a/sys/compat/linuxkpi/common/include/linux/spinlock.h +++ b/sys/compat/linuxkpi/common/include/linux/spinlock.h @@ -29,6 +29,8 @@ #ifndef _LINUXKPI_LINUX_SPINLOCK_H_ #define _LINUXKPI_LINUX_SPINLOCK_H_ +#include "opt_linuxkpi.h" + #include #include #include @@ -130,7 +132,7 @@ typedef struct mtx spinlock_t; spin_unlock(_l); \ } while (0) -#ifdef WITNESS_ALL +#if defined(LINUXKPI_DEBUG) && defined(WITNESS) /* NOTE: the maximum WITNESS name is 64 chars */ #define __spin_lock_name(name, file, line) \ (((const char *){file ":" #line "-" name}) + \ @@ -142,7 +144,7 @@ typedef struct mtx spinlock_t; #define spin_lock_name(name) _spin_lock_name(name, __FILE__, __LINE__) #define spin_lock_init(lock) mtx_init(lock, spin_lock_name("lnxspin"), \ - NULL, MTX_DEF | MTX_NOWITNESS | MTX_NEW) + NULL, MTX_DEF | _LKPI_MTX_NOWITNESS | MTX_NEW) #define spin_lock_destroy(_l) mtx_destroy(_l) @@ -190,7 +192,7 @@ typedef struct raw_spinlock { #define raw_spin_lock_init(rlock) \ mtx_init(&(rlock)->lock, spin_lock_name("lnxspin_raw"), \ - NULL, MTX_DEF | MTX_NOWITNESS | MTX_NEW) + NULL, MTX_DEF | _LKPI_MTX_NOWITNESS | MTX_NEW) #define raw_spin_lock(rl) spin_lock(&(rl)->lock) #define raw_spin_trylock(rl) spin_trylock(&(rl)->lock) diff --git a/sys/compat/linuxkpi/common/include/linux/wait.h b/sys/compat/linuxkpi/common/include/linux/wait.h index 698a1056b713..5d98ccfa7af8 100644 --- a/sys/compat/linuxkpi/common/include/linux/wait.h +++ b/sys/compat/linuxkpi/common/include/linux/wait.h @@ -115,7 +115,7 @@ long linux_wait_woken(wait_queue_t *wq, unsigned state, long timeout); #define init_waitqueue_head(wqh) do { \ mtx_init(&(wqh)->lock, spin_lock_name("wqhead"), \ - NULL, MTX_DEF | MTX_NEW | MTX_NOWITNESS); \ + NULL, MTX_DEF | MTX_NEW | _LKPI_MTX_NOWITNESS); \ INIT_LIST_HEAD(&(wqh)->task_list); \ } while (0) diff --git a/sys/compat/linuxkpi/common/include/linux/ww_mutex.h b/sys/compat/linuxkpi/common/include/linux/ww_mutex.h index 9219755bb78e..eff838ab214a 100644 --- a/sys/compat/linuxkpi/common/include/linux/ww_mutex.h +++ b/sys/compat/linuxkpi/common/include/linux/ww_mutex.h @@ -132,7 +132,7 @@ ww_acquire_init(struct ww_acquire_ctx *ctx, struct ww_class *ww_class) static inline void ww_mutex_init(struct ww_mutex *lock, struct ww_class *ww_class) { - linux_mutex_init(&lock->base, ww_class->mutex_name, SX_NOWITNESS); + linux_mutex_init(&lock->base, ww_class->mutex_name, _LKPI_SX_NOWITNESS); cv_init(&lock->condvar, "lkpi-ww"); } diff --git a/sys/compat/linuxkpi/common/src/linux_hrtimer.c b/sys/compat/linuxkpi/common/src/linux_hrtimer.c index bbd99dec2d83..58c55fed5d1a 100644 --- a/sys/compat/linuxkpi/common/src/linux_hrtimer.c +++ b/sys/compat/linuxkpi/common/src/linux_hrtimer.c @@ -101,7 +101,7 @@ linux_hrtimer_init(struct hrtimer *hrtimer) memset(hrtimer, 0, sizeof(*hrtimer)); mtx_init(&hrtimer->mtx, "hrtimer", NULL, - MTX_DEF | MTX_RECURSE | MTX_NOWITNESS); + MTX_DEF | MTX_RECURSE | _LKPI_MTX_NOWITNESS); callout_init_mtx(&hrtimer->callout, &hrtimer->mtx, 0); } diff --git a/sys/compat/linuxkpi/common/src/linux_work.c b/sys/compat/linuxkpi/common/src/linux_work.c index bf4c82767621..ef2891b1f249 100644 --- a/sys/compat/linuxkpi/common/src/linux_work.c +++ b/sys/compat/linuxkpi/common/src/linux_work.c @@ -706,7 +706,7 @@ linux_init_delayed_work(struct delayed_work *dwork, work_func_t func) dwork->work.func = func; TASK_INIT(&dwork->work.work_task, 0, linux_delayed_work_fn, dwork); mtx_init(&dwork->timer.mtx, spin_lock_name("lkpi-dwork"), NULL, - MTX_DEF | MTX_NOWITNESS); + MTX_DEF | _LKPI_MTX_NOWITNESS); callout_init_mtx(&dwork->timer.callout, &dwork->timer.mtx, 0); }