Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178306683
D59231.1796471582.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
D59231.1796471582.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/kconfig.h b/sys/compat/linuxkpi/common/include/linux/kconfig.h
--- 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
--- a/sys/compat/linuxkpi/common/include/linux/mutex.h
+++ b/sys/compat/linuxkpi/common/include/linux/mutex.h
@@ -109,10 +109,10 @@
}
#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
--- a/sys/compat/linuxkpi/common/include/linux/rwlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/rwlock.h
@@ -52,6 +52,6 @@
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
--- a/sys/compat/linuxkpi/common/include/linux/rwsem.h
+++ b/sys/compat/linuxkpi/common/include/linux/rwsem.h
@@ -77,7 +77,7 @@
{
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
--- a/sys/compat/linuxkpi/common/include/linux/seqlock.h
+++ b/sys/compat/linuxkpi/common/include/linux/seqlock.h
@@ -119,7 +119,7 @@
* 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
--- 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 <asm/atomic.h>
#include <sys/param.h>
#include <sys/kernel.h>
@@ -130,7 +132,7 @@
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 @@
#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 @@
#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
--- a/sys/compat/linuxkpi/common/include/linux/wait.h
+++ b/sys/compat/linuxkpi/common/include/linux/wait.h
@@ -115,7 +115,7 @@
#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
--- a/sys/compat/linuxkpi/common/include/linux/ww_mutex.h
+++ b/sys/compat/linuxkpi/common/include/linux/ww_mutex.h
@@ -132,7 +132,7 @@
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
--- a/sys/compat/linuxkpi/common/src/linux_hrtimer.c
+++ b/sys/compat/linuxkpi/common/src/linux_hrtimer.c
@@ -101,7 +101,7 @@
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
--- a/sys/compat/linuxkpi/common/src/linux_work.c
+++ b/sys/compat/linuxkpi/common/src/linux_work.c
@@ -706,7 +706,7 @@
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);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 5, 11:53 AM (14 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42229947
Default Alt Text
D59231.1796471582.diff (7 KB)
Attached To
Mode
D59231: LinuxKPI: use LINUXKPI_DEBUG to determine on witness lock tracing
Attached
Detach File
Event Timeline