mirror of
https://github.com/golang/go
synced 2024-11-12 09:50:21 -07:00
runtime: split minit() to mpreinit() and minit()
mpreinit() is called on the parent thread and with mcache (can allocate memory), minit() is called on the child thread and can not allocate memory. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7389043
This commit is contained in:
parent
c53fab969c
commit
a0955a2aa2
@ -370,6 +370,8 @@ mcommoninit(M *mp)
|
||||
|
||||
runtime·callers(1, mp->createstack, nelem(mp->createstack));
|
||||
|
||||
runtime·mpreinit(mp);
|
||||
|
||||
// Add to runtime·allm so garbage collector doesn't free m
|
||||
// when it is just in a register or thread-local storage.
|
||||
mp->alllink = runtime·allm;
|
||||
|
@ -660,6 +660,7 @@ int32 runtime·atoi(byte*);
|
||||
void runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void));
|
||||
G* runtime·malg(int32);
|
||||
void runtime·asminit(void);
|
||||
void runtime·mpreinit(M*);
|
||||
void runtime·minit(void);
|
||||
void runtime·unminit(void);
|
||||
void runtime·signalstack(byte*, int32);
|
||||
|
@ -109,12 +109,19 @@ runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
mp->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
// Initialize signal handling.
|
||||
if(m->gsignal == nil)
|
||||
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
|
||||
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
|
||||
|
||||
runtime·sigprocmask(SIG_SETMASK, &sigset_none, nil);
|
||||
|
@ -121,11 +121,19 @@ runtime·goenvs(void)
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
mp->gsignal = runtime·malg(32*1024);
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
// Initialize signal handling
|
||||
m->gsignal = runtime·malg(32*1024);
|
||||
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
|
||||
runtime·sigprocmask(&sigset_none, nil);
|
||||
}
|
||||
|
@ -171,12 +171,19 @@ runtime·goenvs(void)
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
mp->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
// Initialize signal handling.
|
||||
if(m->gsignal == nil)
|
||||
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
|
||||
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
|
||||
runtime·rtsigprocmask(SIG_SETMASK, &sigset_none, nil, sizeof(Sigset));
|
||||
}
|
||||
|
@ -187,14 +187,21 @@ runtime·goenvs(void)
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
mp->gsignal = runtime·malg(32*1024);
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
m->procid = runtime·lwp_self();
|
||||
|
||||
// Initialize signal handling
|
||||
if(m->gsignal == nil)
|
||||
m->gsignal = runtime·malg(32*1024);
|
||||
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
|
||||
runtime·sigprocmask(SIG_SETMASK, &sigset_none, nil);
|
||||
}
|
||||
|
@ -166,12 +166,19 @@ runtime·goenvs(void)
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
mp->gsignal = runtime·malg(32*1024);
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
// Initialize signal handling
|
||||
if(m->gsignal == nil)
|
||||
m->gsignal = runtime·malg(32*1024);
|
||||
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
|
||||
runtime·sigprocmask(SIG_SETMASK, sigset_none);
|
||||
}
|
||||
|
@ -11,13 +11,21 @@ extern SigTab runtime·sigtab[];
|
||||
|
||||
int32 runtime·postnote(int32, int8*);
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
// Initialize stack and goroutine for note handling.
|
||||
mp->gsignal = runtime·malg(32*1024);
|
||||
mp->notesig = (int8*)runtime·malloc(ERRMAX*sizeof(int8));
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
// Initialize stack and goroutine for note handling.
|
||||
m->gsignal = runtime·malg(32*1024);
|
||||
m->notesig = (int8*)runtime·malloc(ERRMAX*sizeof(int8));
|
||||
|
||||
// Mask all SSE floating-point exceptions
|
||||
// when running on the 64-bit kernel.
|
||||
runtime·setfpmasks();
|
||||
|
@ -206,6 +206,15 @@ runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||
void
|
||||
runtime·mpreinit(M *mp)
|
||||
{
|
||||
USED(mp);
|
||||
}
|
||||
|
||||
// Called to initialize a new m (including the bootstrap m).
|
||||
// Called on the new thread, can not allocate memory.
|
||||
void
|
||||
runtime·minit(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user