Commit 858c57f5 authored by Russ Cox's avatar Russ Cox

runtime: make allp a static array

It is anyway, just an allocated one.
Giving it a sized type makes Go access nicer.

LGTM=iant
R=dvyukov, iant
CC=golang-codereviews
https://golang.org/cl/139960043
parent 3a7f6646
...@@ -62,10 +62,6 @@ struct Sched { ...@@ -62,10 +62,6 @@ struct Sched {
enum enum
{ {
// The max value of GOMAXPROCS.
// There are no fundamental restrictions on the value.
MaxGomaxprocs = 1<<8,
// Number of goroutine ids to grab from runtime·sched.goidgen to local per-P cache at once. // Number of goroutine ids to grab from runtime·sched.goidgen to local per-P cache at once.
// 16 seems to provide enough amortization, but other than that it's mostly arbitrary number. // 16 seems to provide enough amortization, but other than that it's mostly arbitrary number.
GoidCacheBatch = 16, GoidCacheBatch = 16,
...@@ -80,6 +76,7 @@ G runtime·g0; // idle goroutine for m0 ...@@ -80,6 +76,7 @@ G runtime·g0; // idle goroutine for m0
G* runtime·lastg; G* runtime·lastg;
M* runtime·allm; M* runtime·allm;
M* runtime·extram; M* runtime·extram;
P* runtime·allp[MaxGomaxprocs+1];
int8* runtime·goos; int8* runtime·goos;
int32 runtime·ncpu; int32 runtime·ncpu;
static int32 newprocs; static int32 newprocs;
...@@ -180,7 +177,6 @@ runtime·schedinit(void) ...@@ -180,7 +177,6 @@ runtime·schedinit(void)
n = MaxGomaxprocs; n = MaxGomaxprocs;
procs = n; procs = n;
} }
runtime·allp = runtime·mallocgc((MaxGomaxprocs+1)*sizeof(runtime·allp[0]), nil, 0);
procresize(procs); procresize(procs);
runtime·copystack = runtime·precisestack; runtime·copystack = runtime·precisestack;
......
...@@ -422,6 +422,12 @@ struct P ...@@ -422,6 +422,12 @@ struct P
byte pad[64]; byte pad[64];
}; };
enum {
// The max value of GOMAXPROCS.
// There are no fundamental restrictions on the value.
MaxGomaxprocs = 1<<8,
};
// The m->locked word holds two pieces of state counting active calls to LockOSThread/lockOSThread. // The m->locked word holds two pieces of state counting active calls to LockOSThread/lockOSThread.
// The low bit (LockExternal) is a boolean reporting whether any LockOSThread call is active. // The low bit (LockExternal) is a boolean reporting whether any LockOSThread call is active.
// External locks are not recursive; a second lock is silently ignored. // External locks are not recursive; a second lock is silently ignored.
...@@ -768,7 +774,7 @@ extern G** runtime·allg; ...@@ -768,7 +774,7 @@ extern G** runtime·allg;
extern uintptr runtime·allglen; extern uintptr runtime·allglen;
extern G* runtime·lastg; extern G* runtime·lastg;
extern M* runtime·allm; extern M* runtime·allm;
extern P** runtime·allp; extern P* runtime·allp[MaxGomaxprocs+1];
extern int32 runtime·gomaxprocs; extern int32 runtime·gomaxprocs;
extern uint32 runtime·needextram; extern uint32 runtime·needextram;
extern uint32 runtime·panicking; extern uint32 runtime·panicking;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment