The NetBSD Project

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

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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.8 / (download) - annotate - [select for diffs], Sat Apr 9 23:38:33 2022 UTC (9 months, 3 weeks ago) by riastradh
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10, bouyer-sunxi-drm-base, bouyer-sunxi-drm, HEAD
Changes since 1.7: +4 -4 lines
Diff to previous 1.7 (colored)

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.7 / (download) - annotate - [select for diffs], Sat Mar 12 15:32:32 2022 UTC (10 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.6: +4 -2 lines
Diff to previous 1.6 (colored)

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.5.4.1 / (download) - annotate - [select for diffs], Sat Apr 25 11:24:06 2020 UTC (2 years, 9 months ago) by bouyer
Branch: bouyer-xenpvh
Changes since 1.5: +7 -124 lines
Diff to previous 1.5 (colored) next main 1.6 (colored)

Sync with bouyer-xenpvh-base2 (HEAD)

Revision 1.6 / (download) - annotate - [select for diffs], Tue Apr 21 21:42:47 2020 UTC (2 years, 9 months ago) by ad
Branch: 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, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-xenpvh-base2
Changes since 1.5: +7 -124 lines
Diff to previous 1.5 (colored)

Revert the changes made in February to make cwdinfo use mostly lockless,
which relied on taking extra vnode refs.

Having benchmarked various experimental changes over the past few months it
seems that it's better to avoid vnode refs as much as possible.  cwdi_lock
as a RW lock already did that to some extent for getcwd() and will permit
the same for namei() too.

Revision 1.4.56.1 / (download) - annotate - [select for diffs], Wed Apr 8 14:08:52 2020 UTC (2 years, 9 months ago) by martin
Branch: phil-wifi
Changes since 1.4: +125 -8 lines
Diff to previous 1.4 (colored) next main 1.5 (colored)

Merge changes from current as of 20200406

Revision 1.4.62.3 / (download) - annotate - [select for diffs], Sat Feb 29 20:21:03 2020 UTC (2 years, 11 months ago) by ad
Branch: ad-namecache
Changes since 1.4.62.2: +3 -5 lines
Diff to previous 1.4.62.2 (colored) to branchpoint 1.4 (colored) next main 1.5 (colored)

Sync with head.

Revision 1.5 / (download) - annotate - [select for diffs], Sun Feb 23 22:14:03 2020 UTC (2 years, 11 months ago) by ad
Branch: MAIN
CVS Tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, is-mlppp-base, is-mlppp, bouyer-xenpvh-base1, bouyer-xenpvh-base, ad-namecache-base3
Branch point for: bouyer-xenpvh
Changes since 1.4: +125 -8 lines
Diff to previous 1.4 (colored)

Merge from ad-namecache:

- Have a stab at clustering the members of vnode_t and vnode_impl_t in a
  more cache-conscious way.  With that done, go back to adjusting v_usecount
  with atomics and keep vi_lock directly in vnode_impl_t (saves KVA).

- Allow VOP_LOCK(LK_NONE) for the benefit of VFS_VGET() and VFS_ROOT().
  Make sure LK_UPGRADE always comes with LK_NOWAIT.

- Make cwdinfo use mostly lockless.

Revision 1.4.62.2 / (download) - annotate - [select for diffs], Sat Jan 25 18:42:24 2020 UTC (3 years ago) by ad
Branch: ad-namecache
Changes since 1.4.62.1: +5 -3 lines
Diff to previous 1.4.62.1 (colored) to branchpoint 1.4 (colored)

Add a missing membar to previous.

Revision 1.4.62.1 / (download) - annotate - [select for diffs], Sat Jan 25 15:54:03 2020 UTC (3 years ago) by ad
Branch: ad-namecache
Changes since 1.4: +125 -8 lines
Diff to previous 1.4 (colored)

Make cwdinfo use mostly lockless, and largely hide the details in vfs_cwd.c.

Revision 1.3.6.1 / (download) - annotate - [select for diffs], Mon Jun 6 09:09:40 2011 UTC (11 years, 7 months ago) by jruoho
Branch: jruoho-x86intr
Changes since 1.3: +13 -2 lines
Diff to previous 1.3 (colored) next main 1.4 (colored)

Sync with HEAD.

Revision 1.3.4.1 / (download) - annotate - [select for diffs], Sat Mar 5 20:55:25 2011 UTC (11 years, 11 months ago) by rmind
Branch: rmind-uvmplock
Changes since 1.3: +13 -2 lines
Diff to previous 1.3 (colored) next main 1.4 (colored)

sync with head

Revision 1.3.8.1 / (download) - annotate - [select for diffs], Thu Feb 17 12:00:44 2011 UTC (11 years, 11 months ago) by bouyer
Branch: bouyer-quota2
Changes since 1.3: +13 -2 lines
Diff to previous 1.3 (colored) next main 1.4 (colored)

Sync with HEAD

Revision 1.4 / (download) - annotate - [select for diffs], Tue Feb 15 15:54:28 2011 UTC (11 years, 11 months ago) by pooka
Branch: 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, phil-wifi-base, phil-wifi-20191119, phil-wifi-20190609, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, 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, 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-9-base, 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, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, 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, isaki-audio2-base, isaki-audio2, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, agc-symver-base, agc-symver, ad-namecache-base2, ad-namecache-base1, ad-namecache-base
Branch point for: phil-wifi, ad-namecache
Changes since 1.3: +13 -2 lines
Diff to previous 1.3 (colored)

Support FD_CLOEXEC in rump kernels.

Revision 1.1.12.3 / (download) - annotate - [select for diffs], Thu Mar 11 15:04:20 2010 UTC (12 years, 10 months ago) by yamt
Branch: yamt-nfs-mp
Changes since 1.1.12.2: +6 -6 lines
Diff to previous 1.1.12.2 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

sync with head

Revision 1.3 / (download) - annotate - [select for diffs], Fri Jan 8 11:35:10 2010 UTC (13 years ago) by pooka
Branch: MAIN
CVS Tags: yamt-nfs-mp-base9, yamt-nfs-mp-base11, yamt-nfs-mp-base10, uebayasi-xip-base4, uebayasi-xip-base3, uebayasi-xip-base2, uebayasi-xip-base1, uebayasi-xip-base, uebayasi-xip, matt-mips64-premerge-20101231, jruoho-x86intr-base
Branch point for: rmind-uvmplock, jruoho-x86intr, bouyer-quota2
Changes since 1.2: +5 -5 lines
Diff to previous 1.2 (colored)

The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase).  Plenty of mix'n match upper/lowercase has creeped
into the tree since then.  Nuke the macros and convert all callsites
to lowercase.

no functional change

Revision 1.2 / (download) - annotate - [select for diffs], Thu Sep 24 06:14:22 2009 UTC (13 years, 4 months ago) by yamt
Branch: MAIN
CVS Tags: matt-premerge-20091211, jym-xensuspend-nbase
Changes since 1.1: +3 -3 lines
Diff to previous 1.1 (colored)

cwdinit: whitespace fix.  no functional changes.

Revision 1.1.12.2 / (download) - annotate - [select for diffs], Mon May 4 08:13:49 2009 UTC (13 years, 9 months ago) by yamt
Branch: yamt-nfs-mp
Changes since 1.1.12.1: +150 -0 lines
Diff to previous 1.1.12.1 (colored) to branchpoint 1.1 (colored)

sync with head.

Revision 1.1.8.2 / (download) - annotate - [select for diffs], Mon Jan 19 13:19:40 2009 UTC (14 years ago) by skrll
Branch: nick-hppapmap
Changes since 1.1.8.1: +150 -0 lines
Diff to previous 1.1.8.1 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

Sync with HEAD.

Revision 1.1.6.2 / (download) - annotate - [select for diffs], Sat Jan 17 13:29:20 2009 UTC (14 years ago) by mjf
Branch: mjf-devfs2
Changes since 1.1.6.1: +150 -0 lines
Diff to previous 1.1.6.1 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

Sync with HEAD.

Revision 1.1.4.2 / (download) - annotate - [select for diffs], Sat Dec 13 01:15:09 2008 UTC (14 years, 1 month ago) by haad
Branch: haad-dm
Changes since 1.1.4.1: +150 -0 lines
Diff to previous 1.1.4.1 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

Update haad-dm branch to haad-dm-base2.

Revision 1.1.12.1, Tue Nov 18 11:36:58 2008 UTC (14 years, 2 months ago) by yamt
Branch: yamt-nfs-mp
Changes since 1.1: +0 -150 lines
FILE REMOVED

file vfs_cwd.c was added on branch yamt-nfs-mp on 2009-05-04 08:13:49 +0000

Revision 1.1.8.1, Tue Nov 18 11:36:58 2008 UTC (14 years, 2 months ago) by skrll
Branch: nick-hppapmap
Changes since 1.1: +0 -150 lines
FILE REMOVED

file vfs_cwd.c was added on branch nick-hppapmap on 2009-01-19 13:19:40 +0000

Revision 1.1.6.1, Tue Nov 18 11:36:58 2008 UTC (14 years, 2 months ago) by mjf
Branch: mjf-devfs2
Changes since 1.1: +0 -150 lines
FILE REMOVED

file vfs_cwd.c was added on branch mjf-devfs2 on 2009-01-17 13:29:20 +0000

Revision 1.1.4.1, Tue Nov 18 11:36:58 2008 UTC (14 years, 2 months ago) by haad
Branch: haad-dm
Changes since 1.1: +0 -150 lines
FILE REMOVED

file vfs_cwd.c was added on branch haad-dm on 2008-12-13 01:15:09 +0000

Revision 1.1 / (download) - annotate - [select for diffs], Tue Nov 18 11:36:58 2008 UTC (14 years, 2 months ago) by pooka
Branch: MAIN
CVS Tags: yamt-nfs-mp-base8, yamt-nfs-mp-base7, yamt-nfs-mp-base6, yamt-nfs-mp-base5, yamt-nfs-mp-base4, yamt-nfs-mp-base3, nick-hppapmap-base4, nick-hppapmap-base3, nick-hppapmap-base2, nick-hppapmap-base, mjf-devfs2-base, jymxensuspend-base, jym-xensuspend-base, jym-xensuspend, haad-nbase2, haad-dm-base2, haad-dm-base, ad-audiomp2-base, ad-audiomp2
Branch point for: yamt-nfs-mp, nick-hppapmap, mjf-devfs2, haad-dm

cwd is logically a vfs concept, so take it out from the bosom of
kern_descrip and into vfs_cwd.  No functional change.

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.




CVSweb <webmaster@jp.NetBSD.org>