OpenBSD CVS

CVS log for src/sys/kern/subr_witness.c


[BACK] Up to [local] / src / sys / kern

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.53 / (download) - annotate - [select for diffs], Mon Jun 3 14:34:19 2024 UTC (7 days, 17 hours ago) by claudio
Branch: MAIN
CVS Tags: HEAD
Changes since 1.52: +1 -7 lines
Diff to previous 1.52 (colored)

Remove lock_class_sched_lock from lock_classes since the corresponding
entry in enum lock_class_index was removed in sys/_lock.h
You get fireworks if the lock_classes array and enum lock_class_index
get out of sync.

Revision 1.52 / (download) - annotate - [select for diffs], Fri May 3 13:47:31 2024 UTC (5 weeks, 3 days ago) by visa
Branch: MAIN
Changes since 1.51: +100 -91 lines
Diff to previous 1.51 (colored)

witness: Display lock cycles longer than two locks

When a lock order reversal is found, perform a path search in the lock
order graph. This lets witness(4) display lock cycles that are longer
than two locks.

OK mpi@

Revision 1.51 / (download) - annotate - [select for diffs], Fri May 3 13:45:42 2024 UTC (5 weeks, 3 days ago) by visa
Branch: MAIN
Changes since 1.50: +6 -4 lines
Diff to previous 1.50 (colored)

witness: Make "show witness" display lock subtypes

Display lock subtypes in "show witness" output to reduce ambiguity.

OK mpi@

Revision 1.50 / (download) - annotate - [select for diffs], Tue May 30 08:30:01 2023 UTC (12 months, 1 week ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.49: +2 -2 lines
Diff to previous 1.49 (colored)

spelling
ok jmc@ guenther@ tb@

Revision 1.49 / (download) - annotate - [select for diffs], Thu May 25 19:32:34 2023 UTC (12 months, 2 weeks ago) by kurt
Branch: MAIN
Changes since 1.48: +12 -4 lines
Diff to previous 1.48 (colored)

Work around sparc64 WITNESS kernel failing to load by moving large witness
data structures from bss to be allocated in witness_initialize().

Tested on sparc64, amd64, arm64, i386, octeon. okay miod@

Revision 1.48 / (download) - annotate - [select for diffs], Mon Feb 21 14:16:49 2022 UTC (2 years, 3 months ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

anscestors -> ancestors

Revision 1.47 / (download) - annotate - [select for diffs], Tue Mar 23 10:22:20 2021 UTC (3 years, 2 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.46: +3 -3 lines
Diff to previous 1.46 (colored)

Skip first frame when saving stacktraces, it's always witness_checkorder().

ok visa@

Revision 1.46 / (download) - annotate - [select for diffs], Wed Mar 10 10:21:47 2021 UTC (3 years, 3 months ago) by jsg
Branch: MAIN
Changes since 1.45: +2 -2 lines
Diff to previous 1.45 (colored)

spelling

ok gnezdo@ semarie@ mpi@

Revision 1.45 / (download) - annotate - [select for diffs], Mon Feb 8 10:51:02 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.44: +3 -3 lines
Diff to previous 1.44 (colored)

Revert the convertion of per-process thread into a SMR_TAILQ.

We did not reach a consensus about using SMR to unlock single_thread_set()
so there's no point in keeping this change.

Revision 1.44 / (download) - annotate - [select for diffs], Thu Jan 28 15:13:27 2021 UTC (3 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.43: +14 -2 lines
Diff to previous 1.43 (colored)

Show when witness(4) has run out of lock order data entries.

This makes it clearer why lock order traces are sometimes not displayed.

Prompted by a question from, and OK anton@

Revision 1.43 / (download) - annotate - [select for diffs], Sat Jan 9 20:59:06 2021 UTC (3 years, 5 months ago) by gnezdo
Branch: MAIN
Changes since 1.42: +8 -10 lines
Diff to previous 1.42 (colored)

Enforce range with sysctl_int_bounded in witness_sysctl_watch

Makes previously explicit checking less verbose.

OK millert@

Revision 1.42 / (download) - annotate - [select for diffs], Sat Jan 9 12:20:37 2021 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.41: +10 -12 lines
Diff to previous 1.41 (colored)

Replace a custom linked list with SLIST.

Revision 1.41 / (download) - annotate - [select for diffs], Sat Jan 9 12:18:28 2021 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.40: +24 -26 lines
Diff to previous 1.40 (colored)

Replace SIMPLEQ with SLIST because the code does not need a queue.

Revision 1.40 / (download) - annotate - [select for diffs], Sat Jan 9 12:15:49 2021 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.39: +2 -10 lines
Diff to previous 1.39 (colored)

Remove unnecessary relocking of w_mtx as panic() should not return.

Revision 1.39 / (download) - annotate - [select for diffs], Mon Dec 7 16:55:29 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.38: +3 -3 lines
Diff to previous 1.38 (colored)

Convert the per-process thread list into a SMR_TAILQ.

Currently all iterations are done under KERNEL_LOCK() and therefor use
the *_LOCKED() variant.

From and ok claudio@

Revision 1.38 / (download) - annotate - [select for diffs], Thu Nov 12 05:49:26 2020 UTC (3 years, 6 months ago) by semarie
Branch: MAIN
Changes since 1.37: +15 -3 lines
Diff to previous 1.37 (colored)

witness: detect and report uninitialized (or zeroed) lock usage

ok visa@

Revision 1.37 / (download) - annotate - [select for diffs], Sun Mar 15 05:58:48 2020 UTC (4 years, 2 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.36: +13 -28 lines
Diff to previous 1.36 (colored)

Fix memory corruption with kern.witness.locktrace.

The allocating of lock stacks does not handle correctly the case where
the system-wide free list becomes empty. Consequently, the returned
stack buffer can still be on the CPU's free list.

This patch fixes the bug by simplifying the code. Lock stack buffers are
now allocated and freed one by one from the system-wide free list
instead of using batching.

The fix additionally addresses a buffer hoarding problem that can arise
under workloads where some CPUs are net acquirers and some other CPUs
net releasers of rwlocks.

Panic reported by Hrvoje Popovski

Revision 1.36 / (download) - annotate - [select for diffs], Mon Jan 20 15:58:23 2020 UTC (4 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.35: +11 -10 lines
Diff to previous 1.35 (colored)

Separate the stack trace saving interface from ddb. The saving does not
require the debugger on most architectures, and the separation makes the
code easier to use from other subsystems.

The function definitions are still conditional to DDB. However, that
should not matter for now.

OK deraadt@, mpi@

Revision 1.35 / (download) - annotate - [select for diffs], Fri Nov 15 15:50:14 2019 UTC (4 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.34: +1 -3 lines
Diff to previous 1.34 (colored)

Remove gratuitous #ifdef.

Revision 1.34 / (download) - annotate - [select for diffs], Sat Jul 20 23:06:51 2019 UTC (4 years, 10 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.33: +2 -2 lines
Diff to previous 1.33 (colored)

Get rid of `ddb_is_active' instead use `db_active'.

From Christian Ludwig <christian_ludwig at genua dot de>

ok visa@

Revision 1.33 / (download) - annotate - [select for diffs], Thu Jun 6 16:45:10 2019 UTC (5 years ago) by visa
Branch: MAIN
Changes since 1.32: +3 -1 lines
Diff to previous 1.32 (colored)

Restore missing newline.

Revision 1.32 / (download) - annotate - [select for diffs], Sun May 19 08:10:55 2019 UTC (5 years ago) by anton
Branch: MAIN
Changes since 1.31: +2 -2 lines
Diff to previous 1.31 (colored)

include uvm.h -> uvm_extern.h; ok visa@

Revision 1.31 / (download) - annotate - [select for diffs], Tue Apr 23 13:35:12 2019 UTC (5 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.30: +81 -223 lines
Diff to previous 1.30 (colored)

Remove file name and line number output from witness(4)

Reduce code clutter by removing the file name and line number output
from witness(4). Typically it is easy enough to locate offending locks
using the stack traces that are shown in lock order conflict reports.
Tricky cases can be tracked using sysctl kern.witness.locktrace=1 .

This patch additionally removes the witness(4) wrapper for mutexes.
Now each mutex implementation has to invoke the WITNESS_*() macros
in order to utilize the checker.

Discussed with and OK dlg@, OK mpi@

Revision 1.30 / (download) - annotate - [select for diffs], Fri Mar 15 05:42:38 2019 UTC (5 years, 2 months ago) by kevlo
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.29: +1 -5 lines
Diff to previous 1.29 (colored)

Remove FBSDID.

ok deraadt@

Revision 1.29 / (download) - annotate - [select for diffs], Thu Feb 7 15:11:38 2019 UTC (5 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.28: +157 -3 lines
Diff to previous 1.28 (colored)

Add lock stack trace saving for witness(4).

This lets witness(4) save a stack trace on each lock acquisition.
The saved traces can be viewed in ddb(4) when showing the currently
held locks, which may help when debugging incorrect locking.

Sample output:

ddb{0}> show all locks
Process 63836 (rm) thread 0xffff8000221e52c8 (435004)
exclusive rrwlock inode r = 0 (0xfffffd8119a092c0) locked @ /usr/src/sys/ufs/ufs/ufs_vnops.c:1547
#0  witness_lock+0x419
#1  _rw_enter+0x2bb
#2  _rrw_enter+0x42
#3  VOP_LOCK+0x3f
#4  vn_lock+0x36
#5  vfs_lookup+0xa1
#6  namei+0x2b3
#7  dounlinkat+0x85
#8  syscall+0x338
#9  Xsyscall+0x128
exclusive kernel_lock &kernel_lock r = 1 (0xffffffff81e6a5f0) locked @ /usr/src/sys/arch/amd64/amd64/intr.c:525
#0  witness_lock+0x419
#1  syscall+0x2b6
#2  Xsyscall+0x128

The saving adds overhead, so it is not enabled by default. It can be
taken into use by setting sysctl kern.witness.locktrace=1 at runtime
or by defining WITNESS_LOCKTRACE in the kernel configuration.

Feedback and OK anton@

Revision 1.28 / (download) - annotate - [select for diffs], Mon Feb 4 13:28:55 2019 UTC (5 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.27: +11 -11 lines
Diff to previous 1.27 (colored)

Make callers of witness_lock_list_{get,free}() responsible of raising
the system priority level to IPL_HIGH. This simplifies the code a bit
relative to calling from witness_lock() and witness_unlock().

OK mpi@

Revision 1.27 / (download) - annotate - [select for diffs], Tue Jan 29 14:07:15 2019 UTC (5 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.26: +22 -1 lines
Diff to previous 1.26 (colored)

Add a dedicated sysctl(2) node for witness(4).

The new node contains the subsystem's main control variable,
kern.witness.watch. It is aliased by the old name, kern.witnesswatch.
The alias will be removed in the future.

OK anton@ mpi@

Revision 1.26 / (download) - annotate - [select for diffs], Sun Jan 27 10:41:41 2019 UTC (5 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.25: +4 -4 lines
Diff to previous 1.25 (colored)

stop using capital letters in printf format strings; ok visa@

Revision 1.25 / (download) - annotate - [select for diffs], Sun Jan 27 10:34:45 2019 UTC (5 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.24: +11 -11 lines
Diff to previous 1.24 (colored)

consistency tweaks to panic format strings; ok visa@

Revision 1.24 / (download) - annotate - [select for diffs], Sat Jan 26 16:18:52 2019 UTC (5 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.23: +3 -3 lines
Diff to previous 1.23 (colored)

Use memset() instead of bzero().

Revision 1.23 / (download) - annotate - [select for diffs], Sat Jan 26 11:47:41 2019 UTC (5 years, 4 months ago) by visa
Branch: MAIN
Changes since 1.22: +18 -15 lines
Diff to previous 1.22 (colored)

Tag the start of witness(4) output with prefix "witness:".
This eases data extraction in syzkaller.

Prompted by and OK anton@

Revision 1.22 / (download) - annotate - [select for diffs], Tue Jun 26 14:45:16 2018 UTC (5 years, 11 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.21: +34 -2 lines
Diff to previous 1.21 (colored)

Make the system cache a small number of free lock list entries per CPU.
This reduces the contention of the `w_mtx' lock.

OK mpi@

Revision 1.21 / (download) - annotate - [select for diffs], Fri Jun 15 14:07:36 2018 UTC (5 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.20: +5 -23 lines
Diff to previous 1.20 (colored)

Remove the witness_skipspin setting to simplify the code.

OK mpi@

Revision 1.20 / (download) - annotate - [select for diffs], Thu Jun 14 17:00:35 2018 UTC (5 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.19: +19 -7 lines
Diff to previous 1.19 (colored)

Make possible to build uniprocessor WITNESS kernels without kernel_lock.

From Christian Ludwig
OK mpi@

Revision 1.19 / (download) - annotate - [select for diffs], Fri Jun 8 15:38:15 2018 UTC (6 years ago) by guenther
Branch: MAIN
Changes since 1.18: +9 -8 lines
Diff to previous 1.18 (colored)

Constipate all the struct lock_type's so they go into .rodata

ok visa@

Revision 1.18 / (download) - annotate - [select for diffs], Fri Jun 1 15:48:19 2018 UTC (6 years ago) by visa
Branch: MAIN
Changes since 1.17: +23 -23 lines
Diff to previous 1.17 (colored)

Consistently use printf() instead of db_printf() when not running
in ddb. This avoids invoking the output pager by accident and keeps
the output somewhat readable in case multiple cores trigger a warning
simultaneously.

Revision 1.17 / (download) - annotate - [select for diffs], Thu May 31 14:52:26 2018 UTC (6 years ago) by visa
Branch: MAIN
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

Make witness(4) watch locks and print error stack traces by default.

Requested by deraadt@

Revision 1.16 / (download) - annotate - [select for diffs], Wed May 16 14:57:22 2018 UTC (6 years ago) by visa
Branch: MAIN
Changes since 1.15: +2 -2 lines
Diff to previous 1.15 (colored)

Fix misleading indentation.

Revision 1.15 / (download) - annotate - [select for diffs], Wed May 16 14:55:44 2018 UTC (6 years ago) by visa
Branch: MAIN
Changes since 1.14: +35 -0 lines
Diff to previous 1.14 (colored)

Print stack traces on lock order conflict.

OK mpi@

Revision 1.14 / (download) - annotate - [select for diffs], Wed May 16 14:53:43 2018 UTC (6 years ago) by visa
Branch: MAIN
Changes since 1.13: +52 -13 lines
Diff to previous 1.13 (colored)

Add kern.witnesswatch sysctl for controlling witness(4). By default,
lock order checking is disabled but it can be enabled at runtime.

Suggested by deraadt@ / mpi@
OK mpi@

Revision 1.13 / (download) - annotate - [select for diffs], Wed May 9 03:43:45 2018 UTC (6 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.12: +25 -71 lines
Diff to previous 1.12 (colored)

Remove witness_channel and always use console output
to simplify the code.

OK mpi@

Revision 1.12 / (download) - annotate - [select for diffs], Mon May 7 15:54:03 2018 UTC (6 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.11: +1 -4 lines
Diff to previous 1.11 (colored)

Zap two unused variables.

Revision 1.11 / (download) - annotate - [select for diffs], Mon May 7 15:52:47 2018 UTC (6 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.10: +5 -3 lines
Diff to previous 1.10 (colored)

Make the print function of db_print_stack_trace() configurable,
and indicate if a saved stack trace is empty.

OK guenther@

Revision 1.10 / (download) - annotate - [select for diffs], Wed May 2 01:59:34 2018 UTC (6 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.9: +5 -3 lines
Diff to previous 1.9 (colored)

Record lock type even if witness is disabled. The value will be needed
if the lock becomes watched later.

Revision 1.9 / (download) - annotate - [select for diffs], Mon Apr 30 11:29:16 2018 UTC (6 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.8: +11 -11 lines
Diff to previous 1.8 (colored)

Treat all negative values of witness_watch equally for robustness.

Revision 1.8 / (download) - annotate - [select for diffs], Thu Apr 12 14:59:08 2018 UTC (6 years, 2 months ago) by visa
Branch: MAIN
Changes since 1.7: +3 -3 lines
Diff to previous 1.7 (colored)

Restore the original BSDI $Id$ strings. Those were mangled by CVS
by my mistake.

Pointed out by Christian Ludwig. Thank you!

Revision 1.7 / (download) - annotate - [select for diffs], Tue Apr 3 08:43:02 2018 UTC (6 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.6: +24 -17 lines
Diff to previous 1.6 (colored)

Deactivate witness(4) checks if we are in ddb(4), when `db_active' is set.

Prevents witness(4) from panic'ing the kernel now that mutexes and rwlock
are always "taken" while in ddb(4).

ok visa@

Revision 1.6 / (download) - annotate - [select for diffs], Tue Feb 20 14:46:22 2018 UTC (6 years, 3 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.5: +14 -3 lines
Diff to previous 1.5 (colored)

Make ddb's "show all locks" command show spinlocks in addition
to sleeplocks.

OK mpi@

Revision 1.5 / (download) - annotate - [select for diffs], Tue Nov 14 14:43:39 2017 UTC (6 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.4: +7 -7 lines
Diff to previous 1.4 (colored)

Fix the initial check of the checkorder and lock operations
so that statically initialized locks get properly enrolled
to the validator.

OK mpi@

Revision 1.4 / (download) - annotate - [select for diffs], Sat Aug 12 03:13:23 2017 UTC (6 years, 10 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.3: +5 -7 lines
Diff to previous 1.3 (colored)

Silence clang warnings: remove unused variables and s/%hx/%x/g

ok mpi@ deraadt@

Revision 1.3 / (download) - annotate - [select for diffs], Mon May 22 13:54:14 2017 UTC (7 years ago) by visa
Branch: MAIN
Changes since 1.2: +4 -31 lines
Diff to previous 1.2 (colored)

Drop kernel trace points. The trace facility does not exist on OpenBSD.

Revision 1.2 / (download) - annotate - [select for diffs], Sun Apr 30 16:45:46 2017 UTC (7 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.1: +4 -4 lines
Diff to previous 1.1 (colored)

Rename Debugger() into db_enter().

Using a name with the 'db_' prefix makes it invisible from the dynamic
profiler.

ok deraadt@, kettenis@, visa@

Revision 1.1 / (download) - annotate - [select for diffs], Thu Apr 20 12:59:36 2017 UTC (7 years, 1 month ago) by visa
Branch: MAIN

Add a port of witness(4) lock validation tool from FreeBSD.

Go-ahead from kettenis@, guenther@, deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.