diff options
author | Michael Matloob <matloob@golang.org> | 2015-11-02 14:09:24 -0500 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2015-11-10 17:38:04 +0000 |
commit | 67faca7d9c54b367aee5fdeef2d5dd609fcf99d0 (patch) | |
tree | 5c6e8b4e243286311bbc4743d6a8e86f16dda85f /src/runtime/mprof.go | |
parent | d33360571f46b46724b908a5603520dce1e8a81c (diff) | |
download | go-67faca7d9c54b367aee5fdeef2d5dd609fcf99d0.tar.gz go-67faca7d9c54b367aee5fdeef2d5dd609fcf99d0.zip |
runtime: break atomics out into package runtime/internal/atomic
This change breaks out most of the atomics functions in the runtime
into package runtime/internal/atomic. It adds some basic support
in the toolchain for runtime packages, and also modifies linux/arm
atomics to remove the dependency on the runtime's mutex. The mutexes
have been replaced with spinlocks.
all trybots are happy!
In addition to the trybots, I've tested on the darwin/arm64 builder,
on the darwin/arm builder, and on a ppc64le machine.
Change-Id: I6698c8e3cf3834f55ce5824059f44d00dc8e3c2f
Reviewed-on: https://go-review.googlesource.com/14204
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/mprof.go')
-rw-r--r-- | src/runtime/mprof.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index d4ffb3eafd..ff4b9e9103 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -8,6 +8,7 @@ package runtime import ( + "runtime/internal/atomic" "unsafe" ) @@ -280,14 +281,14 @@ func SetBlockProfileRate(rate int) { } } - atomicstore64(&blockprofilerate, uint64(r)) + atomic.Store64(&blockprofilerate, uint64(r)) } func blockevent(cycles int64, skip int) { if cycles <= 0 { cycles = 1 } - rate := int64(atomicload64(&blockprofilerate)) + rate := int64(atomic.Load64(&blockprofilerate)) if rate <= 0 || (rate > cycles && int64(fastrand1())%rate > cycles) { return } @@ -488,7 +489,7 @@ func BlockProfile(p []BlockProfileRecord) (n int, ok bool) { // Most clients should use the runtime/pprof package instead // of calling ThreadCreateProfile directly. func ThreadCreateProfile(p []StackRecord) (n int, ok bool) { - first := (*m)(atomicloadp(unsafe.Pointer(&allm))) + first := (*m)(atomic.Loadp(unsafe.Pointer(&allm))) for mp := first; mp != nil; mp = mp.alllink { n++ } |