History log of /src/sys/kern/kern_mutex_obj.c |
Revision | | Date | Author | Comments |
1.15 |
| 02-Oct-2023 |
ad | Use kmem_intr_*() variants for lock objects since aiodoned was done away with and we process these I/Os in soft interrupt context now.
|
1.14 |
| 23-Sep-2023 |
ad | Repply this change with a couple of bugs fixed:
- Do away with separate pool_cache for some kernel objects that have no special requirements and use the general purpose allocator instead. On one of my test systems this makes for a small (~1%) but repeatable reduction in system time during builds presumably because it decreases the kernel's cache / memory bandwidth footprint a little. - vfs_lockf: cache a pointer to the uidinfo and put mutex in the data segment.
|
1.13 |
| 12-Sep-2023 |
ad | Back out recent change to replace pool_cache with then general allocator. Will return to this when I have time again.
|
1.12 |
| 10-Sep-2023 |
ad | - Do away with separate pool_cache for some kernel objects that have no special requirements and use the general purpose allocator instead. On one of my test systems this makes for a small (~1%) but repeatable reduction in system time during builds presumably because it decreases the kernel's cache / memory bandwidth footprint a little. - vfs_lockf: cache a pointer to the uidinfo and put mutex in the data segment.
|
1.11 |
| 24-Feb-2023 |
riastradh | kern: Eliminate most __HAVE_ATOMIC_AS_MEMBAR conditionals.
I'm leaving in the conditional around the legacy membar_enters (store-before-load, store-before-store) in kern_mutex.c and in kern_lock.c because they may still matter: store-before-load barriers tend to be the most expensive kind, so eliding them is probably worthwhile on x86. (It also may not matter; I just don't care to do measurements right now, and it's a single valid and potentially justifiable use case in the whole tree.)
However, membar_release/acquire can be mere instruction barriers on all TSO platforms including x86, so there's no need to go out of our way with a bad API to conditionalize them. If the procedure call overhead is measurable we just could change them to be macros on x86 that expand into __insn_barrier.
Discussed on tech-kern: https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html
|
1.10 |
| 26-Oct-2022 |
riastradh | mutex(9): Properly declare _mutex_init in sys/mutex.h.
|
1.9 |
| 09-Apr-2022 |
riastradh | sys: Use membar_release/acquire around reference drop.
This just goes through my recent reference count membar audit and changes membar_exit to membar_release and membar_enter to membar_acquire -- this should make everything cheaper on most CPUs without hurting correctness, because membar_acquire is generally cheaper than membar_enter.
|
1.8 |
| 12-Mar-2022 |
riastradh | sys: Membar audit around reference count releases.
If two threads are using an object that is freed when the reference count goes to zero, we need to ensure that all memory operations related to the object happen before freeing the object.
Using an atomic_dec_uint_nv(&refcnt) == 0 ensures that only one thread takes responsibility for freeing, but it's not enough to ensure that the other thread's memory operations happen before the freeing.
Consider:
Thread A Thread B obj->foo = 42; obj->baz = 73; mumble(&obj->bar); grumble(&obj->quux); /* membar_exit(); */ /* membar_exit(); */ atomic_dec -- not last atomic_dec -- last /* membar_enter(); */ KASSERT(invariant(obj->foo, obj->bar)); free_stuff(obj);
The memory barriers ensure that
obj->foo = 42; mumble(&obj->bar);
in thread A happens before
KASSERT(invariant(obj->foo, obj->bar)); free_stuff(obj);
in thread B. Without them, this ordering is not guaranteed.
So in general it is necessary to do
membar_exit(); if (atomic_dec_uint_nv(&obj->refcnt) != 0) return; membar_enter();
to release a reference, for the `last one out hit the lights' style of reference counting. (This is in contrast to the style where one thread blocks new references and then waits under a lock for existing ones to drain with a condvar -- no membar needed thanks to mutex(9).)
I searched for atomic_dec to find all these. Obviously we ought to have a better abstraction for this because there's so much copypasta. This is a stop-gap measure to fix actual bugs until we have that. It would be nice if an abstraction could gracefully handle the different styles of reference counting in use -- some years ago I drafted an API for this, but making it cover everything got a little out of hand (particularly with struct vnode::v_usecount) and I ended up setting it aside to work on psref/localcount instead for better scalability.
I got bored of adding #ifdef __HAVE_ATOMIC_AS_MEMBAR everywhere, so I only put it on things that look performance-critical on 5sec review. We should really adopt membar_enter_preatomic/membar_exit_postatomic or something (except they are applicable only to atomic r/m/w, not to atomic_load/store_*, making the naming annoying) and get rid of all the ifdefs.
|
1.7 |
| 01-Jan-2020 |
ad | Add some new functions for lock objects:
mutex_obj_refcnt(), mutex_obj_tryalloc() rw_obj_refcnt(), rw_obj_tryalloc()
|
1.6 |
| 05-Feb-2018 |
ozaki-r | branches: 1.6.4; Obtain proper initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc
Initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc were not useful because the addresses were mutex_obj_alloc or rw_obj_alloc itself. What we want to know are callers of them.
|
1.5 |
| 27-Sep-2011 |
jym | branches: 1.5.2; 1.5.46; Modify *ASSERTMSG() so they are now used as variadic macros. The main goal is to provide routines that do as KASSERT(9) says: append a message to the panic format string when the assertion triggers, with optional arguments.
Fix call sites to reflect the new definition.
Discussed on tech-kern@. See http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
|
1.4 |
| 11-Jun-2011 |
matt | Use KASSERTMSG so if these trigger, we can see what exactly caused them to fire.
|
1.3 |
| 13-May-2011 |
rmind | branches: 1.3.2; Sprinkle __cacheline_aligned and __read_mostly.
|
1.2 |
| 31-Mar-2010 |
ad | branches: 1.2.2; Fix copyrights.
|
1.1 |
| 04-Nov-2009 |
pooka | branches: 1.1.2; 1.1.4; 1.1.6; Heave-ho mutex/rwlock object routines into separate modules -- they don't have anything to do with the lock internals.
|
1.1.6.3 |
| 12-Jun-2011 |
rmind | sync with head
|
1.1.6.2 |
| 31-May-2011 |
rmind | sync with head
|
1.1.6.1 |
| 30-May-2010 |
rmind | sync with head
|
1.1.4.3 |
| 11-Aug-2010 |
yamt | sync with head.
|
1.1.4.2 |
| 11-Mar-2010 |
yamt | sync with head
|
1.1.4.1 |
| 04-Nov-2009 |
yamt | file kern_mutex_obj.c was added on branch yamt-nfs-mp on 2010-03-11 15:04:17 +0000
|
1.1.2.1 |
| 30-Apr-2010 |
uebayasi | Sync with HEAD.
|
1.2.2.1 |
| 06-Jun-2011 |
jruoho | Sync with HEAD.
|
1.3.2.1 |
| 23-Jun-2011 |
cherry | Catchup with rmind-uvmplock merge.
|
1.5.46.1 |
| 02-Apr-2018 |
martin | Pull up following revision(s) (requested by ozaki-r in ticket #687): sys/kern/kern_rwlock_obj.c: revision 1.4 sys/rump/librump/rumpkern/locks.c: revision 1.80 sys/kern/kern_rwlock.c: revision 1.50 sys/arch/x86/x86/db_memrw.c: revision 1.5,1.6 sys/ddb/db_command.c: revision 1.150-1.153 share/man/man4/ddb.4: revision 1.175 (via patch),1.176-1.178 sys/kern/kern_mutex_obj.c: revision 1.6 sys/kern/subr_lockdebug.c: revision 1.61-1.64 sys/sys/lockdebug.h: revision 1.17 sys/kern/kern_mutex.c: revision 1.71 sys/sys/lockdebug.h: revision 1.18,1.19 sys/kern/subr_xcall.c: revision 1.26
Obtain proper initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc
Initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc were not useful because the addresses were mutex_obj_alloc or rw_obj_alloc itself. What we want to know are callers of them.
Spinkle ASSERT_SLEEPABLE to xcall functions
Use db_printf instead of printf in ddb
Add a new command, show lockstat, which shows statistics of locks Currently the command shows the number of allocated locks. The command is useful only if LOCKDEBUG is enabled.
Add a new command, show all locks, which shows information of active locks
The command shows information of all active (i.e., being held) locks that are tracked through either of LWPs or CPUs by the LOCKDEBUG facility. The /t modifier additionally shows a backtrace for each LWP additionally. This feature is useful for debugging especially to analyze deadlocks. The command is useful only if LOCKDEBUG is enabled.
Don't pass a unset address to lockdebug_lock_print
x86: avoid accessing invalid addresses in ddb like arm32 This avoids that a command stops in the middle of an execution if a fault occurs due to an access to an invalid address.
Get rid of a redundant output
Improve wording. Fix a Cm argument.
ddb: rename "show lockstat" to "show lockstats" to avoid conflicting with lockstat(8) Requested by mrg@
|
1.5.2.2 |
| 26-Dec-2011 |
yamt | - use O->A loan to serve read(2). based on a patch from Chuck Silvers - associated O->A loan fixes.
|
1.5.2.1 |
| 18-Nov-2011 |
yamt | - use mutex obj for pageable object - add a function to wait for a mutex obj being available - replace some "livelock" kpauses with it
|
1.6.4.1 |
| 08-Apr-2020 |
martin | Merge changes from current as of 20200406
|