mirror of https://github.com/golang/go.git
runtime/pprof, syscall: report MaxRSS on all unix platforms
All unix platforms currently supported by Go provide the getrusage syscall. On aix and solaris the Getrusage syscall wrapper is not available yet, so add and use it to report MaxRSS in memory profiles. Change-Id: Ie880a3058171031fd2e12ccf9adfb85ce18858b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/391434 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
fe75fe3c7a
commit
c1f22134f2
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !darwin && !linux
|
||||
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
|
||||
|
||||
package pprof
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin || linux
|
||||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
|
||||
package pprof
|
||||
|
||||
|
|
@ -17,10 +17,12 @@ import (
|
|||
func addMaxRSS(w io.Writer) {
|
||||
var rssToBytes uintptr
|
||||
switch runtime.GOOS {
|
||||
case "linux", "android":
|
||||
case "aix", "android", "dragonfly", "freebsd", "linux", "netbsd", "openbsd":
|
||||
rssToBytes = 1024
|
||||
case "darwin", "ios":
|
||||
rssToBytes = 1
|
||||
case "illumos", "solaris":
|
||||
rssToBytes = uintptr(syscall.Getpagesize())
|
||||
default:
|
||||
panic("unsupported OS")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin || freebsd || linux || netbsd || openbsd
|
||||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
|
||||
package pprof
|
||||
|
||||
|
|
|
|||
|
|
@ -594,6 +594,7 @@ func PtraceDetach(pid int) (err error) { return ptrace64(PT_DETACH, int64(pid),
|
|||
//sys Getppid() (ppid int)
|
||||
//sys Getpriority(which int, who int) (n int, err error)
|
||||
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sys Kill(pid int, signum Signal) (err error)
|
||||
//sys Lchown(path string, uid int, gid int) (err error)
|
||||
|
|
|
|||
|
|
@ -421,6 +421,7 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i
|
|||
//sys Getppid() (ppid int)
|
||||
//sys Getpriority(which int, who int) (n int, err error)
|
||||
//sysnb Getrlimit(which int, lim *Rlimit) (err error)
|
||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||
//sysnb Gettimeofday(tv *Timeval) (err error)
|
||||
//sysnb Getuid() (uid int)
|
||||
//sys Kill(pid int, signum Signal) (err error)
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ import "unsafe"
|
|||
//go:cgo_import_dynamic libc_Getppid getppid "libc.a/shr_64.o"
|
||||
//go:cgo_import_dynamic libc_Getpriority getpriority "libc.a/shr_64.o"
|
||||
//go:cgo_import_dynamic libc_Getrlimit getrlimit "libc.a/shr_64.o"
|
||||
//go:cgo_import_dynamic libc_Getrusage getrusage "libc.a/shr_64.o"
|
||||
//go:cgo_import_dynamic libc_Getuid getuid "libc.a/shr_64.o"
|
||||
//go:cgo_import_dynamic libc_Kill kill "libc.a/shr_64.o"
|
||||
//go:cgo_import_dynamic libc_Lchown lchown "libc.a/shr_64.o"
|
||||
|
|
@ -154,6 +155,7 @@ import "unsafe"
|
|||
//go:linkname libc_Getppid libc_Getppid
|
||||
//go:linkname libc_Getpriority libc_Getpriority
|
||||
//go:linkname libc_Getrlimit libc_Getrlimit
|
||||
//go:linkname libc_Getrusage libc_Getrusage
|
||||
//go:linkname libc_Getuid libc_Getuid
|
||||
//go:linkname libc_Kill libc_Kill
|
||||
//go:linkname libc_Lchown libc_Lchown
|
||||
|
|
@ -249,6 +251,7 @@ var (
|
|||
libc_Getppid,
|
||||
libc_Getpriority,
|
||||
libc_Getrlimit,
|
||||
libc_Getrusage,
|
||||
libc_Getuid,
|
||||
libc_Kill,
|
||||
libc_Lchown,
|
||||
|
|
@ -925,6 +928,16 @@ func Getrlimit(which int, lim *Rlimit) (err error) {
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Getrusage(who int, rusage *Rusage) (err error) {
|
||||
_, _, e1 := rawSyscall6(uintptr(unsafe.Pointer(&libc_Getrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Getuid() (uid int) {
|
||||
r0, _, _ := rawSyscall6(uintptr(unsafe.Pointer(&libc_Getuid)), 0, 0, 0, 0, 0, 0, 0)
|
||||
uid = int(r0)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import "unsafe"
|
|||
//go:cgo_import_dynamic libc_Getppid getppid "libc.so"
|
||||
//go:cgo_import_dynamic libc_Getpriority getpriority "libc.so"
|
||||
//go:cgo_import_dynamic libc_Getrlimit getrlimit "libc.so"
|
||||
//go:cgo_import_dynamic libc_Getrusage getrusage "libc.so"
|
||||
//go:cgo_import_dynamic libc_Gettimeofday gettimeofday "libc.so"
|
||||
//go:cgo_import_dynamic libc_Getuid getuid "libc.so"
|
||||
//go:cgo_import_dynamic libc_Kill kill "libc.so"
|
||||
|
|
@ -120,6 +121,7 @@ import "unsafe"
|
|||
//go:linkname libc_Getppid libc_Getppid
|
||||
//go:linkname libc_Getpriority libc_Getpriority
|
||||
//go:linkname libc_Getrlimit libc_Getrlimit
|
||||
//go:linkname libc_Getrusage libc_Getrusage
|
||||
//go:linkname libc_Gettimeofday libc_Gettimeofday
|
||||
//go:linkname libc_Getuid libc_Getuid
|
||||
//go:linkname libc_Kill libc_Kill
|
||||
|
|
@ -208,6 +210,7 @@ var (
|
|||
libc_Getppid,
|
||||
libc_Getpriority,
|
||||
libc_Getrlimit,
|
||||
libc_Getrusage,
|
||||
libc_Gettimeofday,
|
||||
libc_Getuid,
|
||||
libc_Kill,
|
||||
|
|
@ -580,6 +583,16 @@ func Getrlimit(which int, lim *Rlimit) (err error) {
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Getrusage(who int, rusage *Rusage) (err error) {
|
||||
_, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&libc_Getrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Gettimeofday(tv *Timeval) (err error) {
|
||||
_, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&libc_Gettimeofday)), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0)
|
||||
if e1 != 0 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue