The NetBSD Project

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

[BACK] Up to [cvs.NetBSD.org] / src / sys / kern

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.13: download - view: text, markup, annotated - select for diffs
Mon Oct 2 21:03:55 2023 UTC (14 months, 1 week ago) by ad
Branches: MAIN
CVS tags: thorpej-ifq-base, thorpej-ifq, thorpej-altq-separation-base, thorpej-altq-separation, perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, HEAD
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +5 -5 lines
Use kmem_intr_*() variants for lock objects since aiodoned was done away
with and we process these I/Os in soft interrupt context now.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Sat Sep 23 18:21:11 2023 UTC (14 months, 2 weeks ago) by ad
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +13 -40 lines
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.

Revision 1.11: download - view: text, markup, annotated - select for diffs
Tue Sep 12 16:17:21 2023 UTC (14 months, 4 weeks ago) by ad
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +40 -13 lines
Back out recent change to replace pool_cache with then general allocator.
Will return to this when I have time again.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Sun Sep 10 14:45:52 2023 UTC (14 months, 4 weeks ago) by ad
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +13 -40 lines
- 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.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Fri Feb 24 11:02:27 2023 UTC (21 months, 2 weeks ago) by riastradh
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +2 -6 lines
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

Revision 1.8: download - view: text, markup, annotated - select for diffs
Wed Oct 26 23:22:22 2022 UTC (2 years, 1 month ago) by riastradh
Branches: MAIN
CVS tags: netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +2 -4 lines
rwlock(9): Nix extern _rw_init in .c; use sys/rwlock.h.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sat Apr 9 23:38:33 2022 UTC (2 years, 8 months ago) by riastradh
Branches: MAIN
CVS tags: bouyer-sunxi-drm-base, bouyer-sunxi-drm
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +4 -4 lines
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.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Sat Mar 12 15:32:32 2022 UTC (2 years, 8 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +8 -2 lines
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.

Revision 1.4.4.1: download - view: text, markup, annotated - select for diffs
Wed Apr 8 14:08:51 2020 UTC (4 years, 8 months ago) by martin
Branches: phil-wifi
Diff to: previous 1.4: preferred, colored; next MAIN 1.5: preferred, colored
Changes since revision 1.4: +37 -4 lines
Merge changes from current as of 20200406

Revision 1.5: download - view: text, markup, annotated - select for diffs
Wed Jan 1 21:34:39 2020 UTC (4 years, 11 months ago) by ad
Branches: MAIN
CVS tags: thorpej-i2c-spi-conf2-base, thorpej-i2c-spi-conf2, thorpej-i2c-spi-conf-base, thorpej-i2c-spi-conf, thorpej-futex2-base, thorpej-futex2, thorpej-futex-base, thorpej-futex, thorpej-cfargs2-base, thorpej-cfargs2, thorpej-cfargs-base, thorpej-cfargs, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, ad-namecache-base3, ad-namecache-base2, ad-namecache-base1, ad-namecache-base, ad-namecache
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +37 -4 lines
Add some new functions for lock objects:

mutex_obj_refcnt(), mutex_obj_tryalloc()
rw_obj_refcnt(), rw_obj_tryalloc()

Revision 1.3.48.1: download - view: text, markup, annotated - select for diffs
Mon Apr 2 09:07:52 2018 UTC (6 years, 8 months ago) by martin
Branches: netbsd-8
CVS tags: netbsd-8-3-RELEASE, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1
Diff to: previous 1.3: preferred, colored; next MAIN 1.4: preferred, colored
Changes since revision 1.3: +4 -3 lines
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@

Revision 1.4: download - view: text, markup, annotated - select for diffs
Mon Feb 5 04:25:04 2018 UTC (6 years, 10 months ago) by ozaki-r
Branches: MAIN
CVS tags: phil-wifi-base, phil-wifi-20191119, phil-wifi-20190609, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, netbsd-9-base, netbsd-9-4-RELEASE, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, isaki-audio2-base, isaki-audio2
Branch point for: phil-wifi
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +4 -3 lines
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.

Revision 1.2.2.1: download - view: text, markup, annotated - select for diffs
Mon Jun 6 09:09:31 2011 UTC (13 years, 6 months ago) by jruoho
Branches: jruoho-x86intr
Diff to: previous 1.2: preferred, colored; next MAIN 1.3: preferred, colored
Changes since revision 1.2: +3 -3 lines
Sync with HEAD.

Revision 1.1.6.2: download - view: text, markup, annotated - select for diffs
Tue May 31 03:05:01 2011 UTC (13 years, 6 months ago) by rmind
Branches: rmind-uvmplock
Diff to: previous 1.1.6.1: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.6.1: +3 -3 lines
sync with head

Revision 1.3: download - view: text, markup, annotated - select for diffs
Fri May 13 22:16:43 2011 UTC (13 years, 7 months ago) by rmind
Branches: MAIN
CVS tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base-20171202, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, rmind-uvmplock-nbase, rmind-uvmplock-base, rmind-smpnet-nbase, rmind-smpnet-base, rmind-smpnet, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606, nick-nhusb-base-20150406, nick-nhusb-base, nick-nhusb, netbsd-8-base, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, localcount-20160914, khorben-n900, jmcneill-usbmp-pre-base2, jmcneill-usbmp-base9, jmcneill-usbmp-base8, jmcneill-usbmp-base7, jmcneill-usbmp-base6, jmcneill-usbmp-base5, jmcneill-usbmp-base4, jmcneill-usbmp-base3, jmcneill-usbmp-base2, jmcneill-usbmp-base10, jmcneill-usbmp-base, jmcneill-usbmp, jmcneill-audiomp3-base, jmcneill-audiomp3, jdolecek-ncq-base, jdolecek-ncq, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, agc-symver-base, agc-symver
Branch point for: netbsd-8
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +3 -3 lines
Sprinkle __cacheline_aligned and __read_mostly.

Revision 1.1.4.3: download - view: text, markup, annotated - select for diffs
Wed Aug 11 22:54:40 2010 UTC (14 years, 4 months ago) by yamt
Branches: yamt-nfs-mp
Diff to: previous 1.1.4.2: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.4.2: +4 -4 lines
sync with head.

Revision 1.1.6.1: download - view: text, markup, annotated - select for diffs
Sun May 30 05:17:57 2010 UTC (14 years, 6 months ago) by rmind
Branches: rmind-uvmplock
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +4 -4 lines
sync with head

Revision 1.1.2.1: download - view: text, markup, annotated - select for diffs
Fri Apr 30 14:44:10 2010 UTC (14 years, 7 months ago) by uebayasi
Branches: uebayasi-xip
Diff to: previous 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1: +2 -2 lines
Sync with HEAD.

Revision 1.2: download - view: text, markup, annotated - select for diffs
Wed Mar 31 19:59:39 2010 UTC (14 years, 8 months ago) by ad
Branches: MAIN
CVS tags: yamt-nfs-mp-base11, yamt-nfs-mp-base10, uebayasi-xip-base4, uebayasi-xip-base3, uebayasi-xip-base2, uebayasi-xip-base1, matt-mips64-premerge-20101231, jruoho-x86intr-base, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2
Branch point for: jruoho-x86intr
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +4 -4 lines
Fix copyrights.

Revision 1.1.4.2: download - view: text, markup, annotated - select for diffs
Thu Mar 11 15:04:17 2010 UTC (14 years, 9 months ago) by yamt
Branches: yamt-nfs-mp
Diff to: previous 1.1.4.1: preferred, colored; branchpoint 1.1: preferred, colored
Changes since revision 1.1.4.1: +135 -0 lines
sync with head

Revision 1.1.4.1
Wed Nov 4 13:29:45 2009 UTC (15 years, 1 month ago) by yamt
Branches: yamt-nfs-mp
FILE REMOVED
Changes since revision 1.1: +0 -135 lines
file kern_rwlock_obj.c was added on branch yamt-nfs-mp on 2010-03-11 15:04:17 +0000

Revision 1.1: download - view: text, markup, annotated - select for diffs
Wed Nov 4 13:29:45 2009 UTC (15 years, 1 month ago) by pooka
Branches: MAIN
CVS tags: yamt-nfs-mp-base9, uebayasi-xip-base, matt-premerge-20091211
Branch point for: yamt-nfs-mp, uebayasi-xip, rmind-uvmplock
Heave-ho mutex/rwlock object routines into separate modules -- they
don't have anything to do with the lock internals.

Diff request

This form allows you to request diffs 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.

Log view options

CVSweb <webmaster@jp.NetBSD.org>