OpenBSD CVS

CVS log for src/sys/sys/mutex.h


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.22 / (download) - annotate - [select for diffs], Thu May 16 09:30:03 2024 UTC (2 weeks, 3 days ago) by kettenis
Branch: MAIN
CVS Tags: HEAD
Changes since 1.21: +15 -15 lines
Diff to previous 1.21 (colored)

Stop treating IPL_NONE mutexes special in MULTIPROCESSOR kernels.  While
in theory these are safe to use in code that runs under the kernel lock
they are nasty trips when converting code to run without the kernel lock.

ok mpi@, claudio@

Revision 1.21 / (download) - annotate - [select for diffs], Tue Mar 26 18:18:30 2024 UTC (2 months ago) by bluhm
Branch: MAIN
Changes since 1.20: +2 -2 lines
Diff to previous 1.20 (colored)

Improve spinning in mtx_enter().

Instead of calling mtx_enter_try() in each spinning loop, do it
only if the result of a lockless read indicates that the mutex has
been released.  This avoids some expensive atomic compare-and-swap
operations.  Up to 5% reduction of spinning time during kernel build
can been seen on a 8 core amd64 machine.  On other machines there
was no visible effect.

Test on powerpc64 has revealed a bug in mtx_owner declaration.  Not
the variable was volatile, but the object it points to.  Move the
volatile declaration in struct mutex to avoid a hang when going to
multiuser.

from Mateusz Guzik; input kettenis@ jca@; OK mpi@

Revision 1.20 / (download) - annotate - [select for diffs], Sat Feb 3 22:50:09 2024 UTC (3 months, 4 weeks ago) by mvs
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.19: +4 -1 lines
Diff to previous 1.19 (colored)

Rework socket buffers locking for shared netlock.

Shared netlock is not sufficient to call so{r,w}wakeup(). The following
sowakeup() modifies `sb_flags' and knote(9) stuff. Unfortunately, we
can't call so{r,w}wakeup() with `inp_mtx' mutex(9) because sowakeup()
also calls pgsigio() which grabs kernel lock.

However, `so*_filtops' callbacks only perform read-only access to the
socket stuff, so it is enough to hold shared netlock only, but the klist
stuff needs to be protected.

This diff introduces `sb_mtx' mutex(9) to protect sockbuf. This time
`sb_mtx' used to protect only `sb_flags' and `sb_klist'.

Now we have soassertlocked_readonly() and soassertlocked(). The first
one is happy if only shared netlock is held, meanwhile the second wants
`so_lock' or pru_lock() be held together with shared netlock.

To keep soassertlocked*() assertions soft, we need to know mutex(9)
state, so new mtx_owned() macro was introduces. Also, the new optional
(*pru_locked)() handler brings the state of pru_lock().

Tests and ok from bluhm.

Revision 1.19 / (download) - annotate - [select for diffs], Fri Dec 1 14:37:22 2023 UTC (6 months ago) by bluhm
Branch: MAIN
Changes since 1.18: +3 -3 lines
Diff to previous 1.18 (colored)

Cast mtx to void in dummy MUTEX_ASSERT_LOCKED().

To avoid unsued variable in ramdisk kernel, use the argument of
MUTEX_ASSERT_LOCKED() also in non DIAGNOSTIC builds.

OK sashan@ mvs@

Revision 1.18 / (download) - annotate - [select for diffs], Tue Apr 23 13:35:12 2019 UTC (5 years, 1 month ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.17: +4 -14 lines
Diff to previous 1.17 (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.17 / (download) - annotate - [select for diffs], Sat Mar 23 05:30:16 2019 UTC (5 years, 2 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.16: +15 -1 lines
Diff to previous 1.16 (colored)

Add a simple spinning mutex for ddb. Unlike mutex(9), this lock keeps
on spinning even if `db_active' or `panicstr' has been set. The new
mutex also disables IPIs in the critical section.

OK mpi@ patrick@

Revision 1.16 / (download) - annotate - [select for diffs], Wed Jan 23 22:39:47 2019 UTC (5 years, 4 months ago) by tedu
Branch: MAIN
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (colored)

eliminate a ?: in witness mtx initializer by pushing the default one
level up.
ok guenther mpi visa

Revision 1.15 / (download) - annotate - [select for diffs], Fri Jun 8 15:38:15 2018 UTC (5 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.14: +4 -4 lines
Diff to previous 1.14 (colored)

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

ok visa@

Revision 1.14 / (download) - annotate - [select for diffs], Tue Mar 27 08:32:29 2018 UTC (6 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (colored)

Try harder to execute code protected by mutexes after entering ddb(4).

Should prevent a panic after panic reported by mlarkin@.

ok mlarkin@, visa@

Revision 1.13 / (download) - annotate - [select for diffs], Sat Feb 10 12:53:22 2018 UTC (6 years, 3 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.12: +12 -21 lines
Diff to previous 1.12 (colored)

Artur Grabowski agreed to relicense his C mutex implementation under ISC.

This will prevent a copyright-o-rama in kern_lock.c

Revision 1.12 / (download) - annotate - [select for diffs], Thu Jan 25 15:06:29 2018 UTC (6 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.11: +60 -1 lines
Diff to previous 1.11 (colored)

Move common mutex implementations to a MI place.

Archs not yet converted can to the jump by defining __USE_MI_MUTEX.

ok visa@

Revision 1.11 / (download) - annotate - [select for diffs], Wed Nov 29 15:12:52 2017 UTC (6 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

Show line number correctly in synthetic mutex names.

OK jca@

Revision 1.10 / (download) - annotate - [select for diffs], Sat Aug 12 16:28:01 2017 UTC (6 years, 9 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.9: +10 -11 lines
Diff to previous 1.9 (colored)

Always provide _mtx_* APIs, the use those to simplify the WITNESS wrappers
elsewhere

ok visa@ kettenis@

Revision 1.9 / (download) - annotate - [select for diffs], Tue May 16 13:30:48 2017 UTC (7 years ago) by dlg
Branch: MAIN
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

use _mtx_init instead of __mtx_init inside mtx_init on !WITNESS kernels

_mtx_init uses __MUTEX_IPL to wrap the ipl argument to __mtx_init.
without this, mutexes were initted below the mp floor, which allowed
deadlocks with the kernel lock to occur.

reported by hrvoje popovski and pinpointed by mikeb@
tweaks from phessler@
ok mpi@ visa@

Revision 1.8 / (download) - annotate - [select for diffs], Thu Apr 20 13:57:30 2017 UTC (7 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.7: +61 -6 lines
Diff to previous 1.7 (colored)

Hook up mutex(9) to witness(4).

Revision 1.7 / (download) - annotate - [select for diffs], Thu Aug 13 13:24:55 2009 UTC (14 years, 9 months ago) by weingart
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9, OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.6: +2 -1 lines
Diff to previous 1.6 (colored)

A new(er) mtx_enter_try().

Ok oga@, "the time is now" deraadt@.

Revision 1.6 / (download) - annotate - [select for diffs], Mon Apr 27 21:48:56 2009 UTC (15 years, 1 month ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.5: +0 -1 lines
Diff to previous 1.5 (colored)

Revert mtx_enter_try.  It didn't compile on hppa, it doesn't compile on
landisk, and the sparc implementation is obviously wrong.  That's where I
stopped looking, so who knows what else was broken.  A simple comparison of
the existing mtx_enter with the new mtx_enter_try would have told anybody.

Revision 1.5 / (download) - annotate - [select for diffs], Sat Apr 25 20:14:43 2009 UTC (15 years, 1 month ago) by weingart
Branch: MAIN
Changes since 1.4: +2 -1 lines
Diff to previous 1.4 (colored)

Enter mtx_enter_try.  In part for completeness, things may start
using this soon(ish).  Ok oga@, sorta yes kettenis@.

Revision 1.4 / (download) - annotate - [select for diffs], Tue May 15 15:23:36 2007 UTC (17 years ago) by art
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4, OPENBSD_4_3_BASE, OPENBSD_4_3, OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.3: +1 -56 lines
Diff to previous 1.3 (colored)

Remove the MI implementation of mutexes and remove the __HAVE_MUTEX
option. Every architecture implements mutexes now.

Revision 1.3 / (download) - annotate - [select for diffs], Mon Jul 18 02:43:27 2005 UTC (18 years, 10 months ago) by fgsch
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.2: +3 -3 lines
Diff to previous 1.2 (colored)

remove trailing newline in panic(9); ok millert@ and deraadt@

Revision 1.2 / (download) - annotate - [select for diffs], Fri Oct 1 04:08:46 2004 UTC (19 years, 8 months ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.1: +2 -0 lines
Diff to previous 1.1 (colored)

add some missing $, ok djm@ 'That looks fine to me' millert@

Revision 1.1 / (download) - annotate - [select for diffs], Tue Jul 20 20:15:13 2004 UTC (19 years, 10 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6

Introducing mutexes - cpu-owned spinning locks with spl semantics.

This is the MI (slightly inefficient and not MP safe) implementation.

deraadt@ ok Tested by many. (this and following commits)

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.