aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/crash_test.go2
-rw-r--r--src/runtime/crash_unix_test.go2
-rw-r--r--src/runtime/metrics/description.go18
-rw-r--r--src/runtime/metrics/doc.go11
-rw-r--r--src/runtime/mstats.go13
-rw-r--r--src/runtime/traceback.go1
6 files changed, 37 insertions, 10 deletions
diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go
index cd978cc34b..8f11333b46 100644
--- a/src/runtime/crash_test.go
+++ b/src/runtime/crash_test.go
@@ -534,7 +534,7 @@ func TestMemPprof(t *testing.T) {
got, err := testenv.CleanCmdEnv(exec.Command(exe, "MemProf")).CombinedOutput()
if err != nil {
- t.Fatal(err)
+ t.Fatalf("testprog failed: %s, output:\n%s", err, got)
}
fn := strings.TrimSpace(string(got))
defer os.Remove(fn)
diff --git a/src/runtime/crash_unix_test.go b/src/runtime/crash_unix_test.go
index 07060b8fab..6bca2ac66e 100644
--- a/src/runtime/crash_unix_test.go
+++ b/src/runtime/crash_unix_test.go
@@ -76,7 +76,7 @@ func TestCrashDumpsAllThreads(t *testing.T) {
testenv.MustHaveGoBuild(t)
- if strings.Contains(os.Getenv("GCFLAGS"), "mayMoreStackPreempt") {
+ if strings.Contains(os.Getenv("GOFLAGS"), "mayMoreStackPreempt") {
// This test occasionally times out in this debug mode. This is probably
// revealing a real bug in the scheduler, but since it seems to only
// affect this test and this is itself a test of a debug mode, it's not
diff --git a/src/runtime/metrics/description.go b/src/runtime/metrics/description.go
index aea51c7f75..745691b24f 100644
--- a/src/runtime/metrics/description.go
+++ b/src/runtime/metrics/description.go
@@ -339,9 +339,11 @@ var allDesc = []Description{
Kind: KindUint64,
},
{
- Name: "/memory/classes/heap/stacks:bytes",
- Description: "Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use.",
- Kind: KindUint64,
+ Name: "/memory/classes/heap/stacks:bytes",
+ Description: "Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use. " +
+ "Currently, this represents all stack memory for goroutines. It also includes all OS thread stacks in non-cgo programs. " +
+ "Note that stacks may be allocated differently in the future, and this may change.",
+ Kind: KindUint64,
},
{
Name: "/memory/classes/heap/unused:bytes",
@@ -374,9 +376,13 @@ var allDesc = []Description{
Kind: KindUint64,
},
{
- Name: "/memory/classes/os-stacks:bytes",
- Description: "Stack memory allocated by the underlying operating system.",
- Kind: KindUint64,
+ Name: "/memory/classes/os-stacks:bytes",
+ Description: "Stack memory allocated by the underlying operating system. " +
+ "In non-cgo programs this metric is currently zero. This may change in the future." +
+ "In cgo programs this metric includes OS thread stacks allocated directly from the OS. " +
+ "Currently, this only accounts for one stack in c-shared and c-archive build modes, " +
+ "and other sources of stacks from the OS are not measured. This too may change in the future.",
+ Kind: KindUint64,
},
{
Name: "/memory/classes/other:bytes",
diff --git a/src/runtime/metrics/doc.go b/src/runtime/metrics/doc.go
index 5238bcea8e..5c52f78477 100644
--- a/src/runtime/metrics/doc.go
+++ b/src/runtime/metrics/doc.go
@@ -318,7 +318,10 @@ Below is the full list of supported metrics, ordered lexicographically.
/memory/classes/heap/stacks:bytes
Memory allocated from the heap that is reserved for stack space,
- whether or not it is currently in-use.
+ whether or not it is currently in-use. Currently, this
+ represents all stack memory for goroutines. It also includes all
+ OS thread stacks in non-cgo programs. Note that stacks may be
+ allocated differently in the future, and this may change.
/memory/classes/heap/unused:bytes
Memory that is reserved for heap objects but is not currently
@@ -345,6 +348,12 @@ Below is the full list of supported metrics, ordered lexicographically.
/memory/classes/os-stacks:bytes
Stack memory allocated by the underlying operating system.
+ In non-cgo programs this metric is currently zero. This may
+ change in the future.In cgo programs this metric includes
+ OS thread stacks allocated directly from the OS. Currently,
+ this only accounts for one stack in c-shared and c-archive build
+ modes, and other sources of stacks from the OS are not measured.
+ This too may change in the future.
/memory/classes/other:bytes
Memory used by execution trace buffers, structures for debugging
diff --git a/src/runtime/mstats.go b/src/runtime/mstats.go
index ab383dd8e3..9cdc565137 100644
--- a/src/runtime/mstats.go
+++ b/src/runtime/mstats.go
@@ -199,7 +199,17 @@ type MemStats struct {
// StackSys is bytes of stack memory obtained from the OS.
//
// StackSys is StackInuse, plus any memory obtained directly
- // from the OS for OS thread stacks (which should be minimal).
+ // from the OS for OS thread stacks.
+ //
+ // In non-cgo programs this metric is currently equal to StackInuse
+ // (but this should not be relied upon, and the value may change in
+ // the future).
+ //
+ // In cgo programs this metric includes OS thread stacks allocated
+ // directly from the OS. Currently, this only accounts for one stack in
+ // c-shared and c-archive build modes and other sources of stacks from
+ // the OS (notably, any allocated by C code) are not currently measured.
+ // Note this too may change in the future.
StackSys uint64
// Off-heap memory statistics.
@@ -347,6 +357,7 @@ func init() {
// which is a snapshot as of the most recently completed garbage
// collection cycle.
func ReadMemStats(m *MemStats) {
+ _ = m.Alloc // nil check test before we switch stacks, see issue 61158
stopTheWorld(stwReadMemStats)
systemstack(func() {
diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go
index d6f89210a4..86df1155b5 100644
--- a/src/runtime/traceback.go
+++ b/src/runtime/traceback.go
@@ -1147,6 +1147,7 @@ func showfuncinfo(sf srcFunc, firstFrame bool, calleeID abi.FuncID) bool {
// isExportedRuntime reports whether name is an exported runtime function.
// It is only for runtime functions, so ASCII A-Z is fine.
+// TODO: this handles exported functions but not exported methods.
func isExportedRuntime(name string) bool {
const n = len("runtime.")
return len(name) > n && name[:n] == "runtime." && 'A' <= name[n] && name[n] <= 'Z'