The NetBSD Project

CVS log for src/common/lib/libc/arch/mips/atomic/membar_ops.S

[BACK] Up to [cvs.NetBSD.org] / src / common / lib / libc / arch / mips / atomic

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.13 / (download) - annotate - [select for diffs], Thu Apr 21 12:06:31 2022 UTC (9 months, 1 week ago) by riastradh
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10, HEAD
Changes since 1.12: +66 -30 lines
Diff to previous 1.12 (colored)

mips/cavium: Take advantage of Octeon's guaranteed r/rw ordering.

Revision 1.12 / (download) - annotate - [select for diffs], Sat Apr 9 23:32:51 2022 UTC (9 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.11: +24 -6 lines
Diff to previous 1.11 (colored)

Introduce membar_acquire/release.  Deprecate membar_enter/exit.

The names membar_enter/exit were unclear, and the documentation of
membar_enter has disagreed with the implementations on sparc,
powerpc, and even x86(!) for the entire time it has been in NetBSD.

The terms `acquire' and `release' are ubiquitous in the literature
today, and have been adopted in the C and C++ standards to mean
load-before-load/store and load/store-before-store, respectively,
which are exactly the orderings required by acquiring and releasing a
mutex, as well as other useful applications like decrementing a
reference count and then freeing the underlying object if it went to
zero.

Originally I proposed changing one word in the documentation for
membar_enter to make it load-before-load/store instead of
store-before-load/store, i.e., to make it an acquire barrier.  I
proposed this on the grounds that

(a) all implementations guarantee load-before-load/store,
(b) some implementations fail to guarantee store-before-load/store,
and
(c) all uses in-tree assume load-before-load/store.

I verified parts (a) and (b) (except, for (a), powerpc didn't even
guarantee load-before-load/store -- isync isn't necessarily enough;
need lwsync in general -- but it _almost_ did, and it certainly didn't
guarantee store-before-load/store).

Part (c) might not be correct, however: under the mistaken assumption
that atomic-r/m/w then membar-w/rw is equivalent to atomic-r/m/w then
membar-r/rw, I only audited the cases of membar_enter that _aren't_
immediately after an atomic-r/m/w.  All of those cases assume
load-before-load/store.  But my assumption was wrong -- there are
cases of atomic-r/m/w then membar-w/rw that would be broken by
changing to atomic-r/m/w then membar-r/rw:

https://mail-index.netbsd.org/tech-kern/2022/03/29/msg028044.html

Furthermore, the name membar_enter has been adopted in other places
like OpenBSD where it actually does follow the documentation and
guarantee store-before-load/store, even if that order is not useful.
So the name membar_enter currently lives in a bad place where it
means either of two things -- r/rw or w/rw.

With this change, we deprecate membar_enter/exit, introduce
membar_acquire/release as better names for the useful pair (r/rw and
rw/w), and make sure the implementation of membar_enter guarantees
both what was documented _and_ what was implemented, making it an
alias for membar_sync.

While here, rework all of the membar_* definitions and aliases.  The
new logic follows a rule to make it easier to audit:

	membar_X is defined as an alias for membar_Y iff membar_X is
	guaranteed by membar_Y.

The `no stronger than' relation is (the transitive closure of):

- membar_consumer (r/r) is guaranteed by membar_acquire (r/rw)
- membar_producer (w/w) is guaranteed by membar_release (rw/w)
- membar_acquire (r/rw) is guaranteed by membar_sync (rw/rw)
- membar_release (rw/w) is guaranteed by membar_sync (rw/rw)

And, for the deprecated membars:

- membar_enter (whether r/rw, w/rw, or rw/rw) is guaranteed by
  membar_sync (rw/rw)
- membar_exit (rw/w) is guaranteed by membar_release (rw/w)

(membar_exit is identical to membar_release, but the name is
deprecated.)

Finally, while here, annotate some of the instructions with their
semantics.  For powerpc, leave an essay with citations on the
unfortunate but -- as far as I can tell -- necessary decision to use
lwsync, not isync, for membar_acquire and membar_consumer.

Also add membar(3) and atomic(3) man page links.

Revision 1.11 / (download) - annotate - [select for diffs], Sat Feb 12 17:10:02 2022 UTC (11 months, 2 weeks ago) by riastradh
Branch: MAIN
Changes since 1.10: +1 -11 lines
Diff to previous 1.10 (colored)

mips: Brush up __cpu_simple_lock.

- Eradicate last vestiges of mb_* barriers.

- In __cpu_simple_lock_init, omit needless barrier.  It is the
  caller's responsibility to ensure __cpu_simple_lock_init happens
  before other operations on it anyway, so there was never any need
  for a barrier here.

- In __cpu_simple_lock_try, leave comments about memory ordering
  guarantees of the kernel's _atomic_cas_uint, which are inexplicably
  different from the non-underscored atomic_cas_uint.

- In __cpu_simple_unlock, use membar_exit instead of mb_memory, and do
  it unconditionally.

  This ensures that in __cpu_simple_lock/.../__cpu_simple_unlock, all
  memory operations in the ellipsis happen before the store that
  releases the lock.

  - On Octeon, the barrier was omitted altogether, which is a bug --
    it needs to be there or else there is no happens-before relation
    and whoever takes the lock next might see stale values stored or
    even stomp over the unlocking CPU's delayed loads.

  - On non-Octeon, the mb_memory was sync.  Using membar_exit
    preserves this.

  XXX On Octeon, membar_exit only issues syncw -- this seems wrong,
  only store-before-store and not load/store-before-store, unless the
  CNMIPS architecture guarantees it is sufficient here like
  SPARCv8/v9 PSO (`Partial Store Order').

- Leave an essay with citations about why we have an apparently
  pointless syncw _after_ releasing a lock, to work around a design
  bug^W^Wquirk in cnmips which sometimes buffers stores for hundreds
  of thousands of cycles for fun unless you issue syncw.

Revision 1.10 / (download) - annotate - [select for diffs], Mon Aug 10 14:37:38 2020 UTC (2 years, 5 months ago) by skrll
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.9: +2 -9 lines
Diff to previous 1.9 (colored)

More SYNC centralisation

Revision 1.9 / (download) - annotate - [select for diffs], Sat Aug 1 09:26:49 2020 UTC (2 years, 6 months ago) by skrll
Branch: MAIN
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (colored)

Trailing whitespace

Revision 1.8.16.2 / (download) - annotate - [select for diffs], Tue Apr 21 19:37:44 2020 UTC (2 years, 9 months ago) by martin
Branch: phil-wifi
Changes since 1.8.16.1: +0 -0 lines
Diff to previous 1.8.16.1 (colored) to branchpoint 1.8 (colored) next main 1.9 (colored)

Ooops, restore accidently removed files from merge mishap

Revision 1.8.16.1, Tue Apr 21 18:41:18 2020 UTC (2 years, 9 months ago) by martin
Branch: phil-wifi
Changes since 1.8: +1 -1 lines
FILE REMOVED

Sync with HEAD

Revision 1.8 / (download) - annotate - [select for diffs], Tue Jun 23 20:56:17 2015 UTC (7 years, 7 months ago) by matt
Branch: MAIN
CVS Tags: tls-maxphys-20171202, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, 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, 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, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, is-mlppp-base, is-mlppp, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, ad-namecache-base3, ad-namecache-base, ad-namecache
Branch point for: phil-wifi
Changes since 1.7: +6 -20 lines
Diff to previous 1.7 (colored)

Always use sync if mips3 or later or not using O32 ABI.  (A little redundant
since not using O32 means you are using mips3 or later.)

Revision 1.7 / (download) - annotate - [select for diffs], Mon Jun 22 06:06:02 2015 UTC (7 years, 7 months ago) by matt
Branch: MAIN
Changes since 1.6: +3 -4 lines
Diff to previous 1.6 (colored)

#include "assym.h"
Don't include "assym.h" with _RUMPKERNEL defined.

Revision 1.6 / (download) - annotate - [select for diffs], Mon Jun 1 23:16:54 2015 UTC (7 years, 8 months ago) by matt
Branch: MAIN
Changes since 1.5: +18 -1 lines
Diff to previous 1.5 (colored)

Include OCTEON support for syncw and saa/saad (Store Atomic Add).

Revision 1.4.6.1 / (download) - annotate - [select for diffs], Tue Oct 30 18:46:13 2012 UTC (10 years, 3 months ago) by yamt
Branch: yamt-pagecache
CVS Tags: yamt-pagecache-tag8
Changes since 1.4: +4 -3 lines
Diff to previous 1.4 (colored) next main 1.5 (colored)

sync with head

Revision 1.5 / (download) - annotate - [select for diffs], Fri Aug 3 06:06:44 2012 UTC (10 years, 6 months ago) by matt
Branch: MAIN
CVS Tags: yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, rmind-smpnet-nbase, rmind-smpnet-base, 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, 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, khorben-n900, agc-symver-base, agc-symver
Changes since 1.4: +4 -3 lines
Diff to previous 1.4 (colored)

Add a missing .set noreorder

Revision 1.3.10.3 / (download) - annotate - [select for diffs], Fri Aug 3 05:35:13 2012 UTC (10 years, 6 months ago) by matt
Branch: matt-nb5-mips64
Changes since 1.3.10.2: +2 -1 lines
Diff to previous 1.3.10.2 (colored) to branchpoint 1.3 (colored) next main 1.4 (colored)

Add missing .set noreorder

Revision 1.4 / (download) - annotate - [select for diffs], Mon Dec 14 00:39:00 2009 UTC (13 years, 1 month ago) by matt
Branch: MAIN
CVS Tags: yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-nfs-mp-base9, yamt-nfs-mp-base11, yamt-nfs-mp-base10, rmind-uvmplock-base, 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-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2
Branch point for: yamt-pagecache
Changes since 1.3: +17 -10 lines
Diff to previous 1.3 (colored)

Merge from matt-nb5-mips64

Revision 1.3.10.2 / (download) - annotate - [select for diffs], Sat Sep 5 18:52:32 2009 UTC (13 years, 4 months ago) by matt
Branch: matt-nb5-mips64
CVS Tags: matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb4-mips64-k7-u2a-k9b
Changes since 1.3.10.1: +11 -4 lines
Diff to previous 1.3.10.1 (colored) to branchpoint 1.3 (colored)

Resolve some conflicts.

Revision 1.3.10.1 / (download) - annotate - [select for diffs], Sat Sep 5 04:03:01 2009 UTC (13 years, 4 months ago) by matt
Branch: matt-nb5-mips64
Changes since 1.3: +9 -9 lines
Diff to previous 1.3 (colored)

Only allow to null on o32

Revision 1.2.2.1 / (download) - annotate - [select for diffs], Mon Jun 23 04:26:45 2008 UTC (14 years, 7 months ago) by wrstuden
Branch: wrstuden-revivesa
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored) next main 1.3 (colored)

Sync w/ -current. 34 merge conflicts to follow.

Revision 1.1.8.2 / (download) - annotate - [select for diffs], Wed Jun 4 02:02:58 2008 UTC (14 years, 8 months ago) by yamt
Branch: yamt-pf42
Changes since 1.1.8.1: +2 -2 lines
Diff to previous 1.1.8.1 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

sync with head

Revision 1.3 / (download) - annotate - [select for diffs], Sun May 25 15:56:12 2008 UTC (14 years, 8 months ago) by chs
Branch: MAIN
CVS Tags: yamt-pf42-base4, yamt-pf42-base3, yamt-nfs-mp-base8, yamt-nfs-mp-base7, yamt-nfs-mp-base6, yamt-nfs-mp-base5, yamt-nfs-mp-base4, yamt-nfs-mp-base3, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, matt-premerge-20091211, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u1-k1-k5, matt-mips64-base2, jymxensuspend-base, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend
Branch point for: matt-nb5-mips64
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored)

enable profiling of assembly functions.

Revision 1.1.8.1 / (download) - annotate - [select for diffs], Sun May 18 12:28:45 2008 UTC (14 years, 8 months ago) by yamt
Branch: yamt-pf42
Changes since 1.1: +1 -8 lines
Diff to previous 1.1 (colored)

sync with head.

Revision 1.2 / (download) - annotate - [select for diffs], Mon Apr 28 20:22:52 2008 UTC (14 years, 9 months ago) by martin
Branch: MAIN
CVS Tags: yamt-pf42-base2, yamt-nfs-mp-base2, hpcarm-cleanup-nbase
Branch point for: wrstuden-revivesa
Changes since 1.1: +1 -8 lines
Diff to previous 1.1 (colored)

Remove clause 3 and 4 from TNF licenses

Revision 1.1.4.2 / (download) - annotate - [select for diffs], Wed Jan 9 01:20:59 2008 UTC (15 years ago) by matt
Branch: matt-armv6
Changes since 1.1.4.1: +77 -0 lines
Diff to previous 1.1.4.1 (colored) to branchpoint 1.1 (colored) next main 1.2 (colored)

sync with HEAD

Revision 1.1.4.1, Fri Nov 30 22:50:44 2007 UTC (15 years, 2 months ago) by matt
Branch: matt-armv6
Changes since 1.1: +0 -77 lines
FILE REMOVED

file membar_ops.S was added on branch matt-armv6 on 2008-01-09 01:20:59 +0000

Revision 1.1 / (download) - annotate - [select for diffs], Fri Nov 30 22:50:44 2007 UTC (15 years, 2 months ago) by ad
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base, yamt-nfs-mp-base, yamt-lazymbuf-base15, yamt-lazymbuf-base14, yamt-kmem-base3, yamt-kmem-base2, yamt-kmem-base, reinoud-bufcleanup-nbase, reinoud-bufcleanup-base, matt-armv6-nbase, matt-armv6-base, keiichi-mipv6-base, keiichi-mipv6, hpcarm-cleanup-base, cube-autoconf-base, cube-autoconf
Branch point for: yamt-pf42, matt-armv6

Memory barriers for MIPS.

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>