mirror of
https://github.com/golang/go
synced 2024-11-18 14:14:46 -07:00
undo CL 12167043 / 475e11851fc1
Submitted with some unrelated changes that were not intended to go in. ««« original CL description runtime: do not park sysmon thread if any goroutines are running Sysmon thread parks if no goroutines are running (runtime.sched.npidle == runtime.gomaxprocs). Currently it's unparked when a goroutine enters syscall, it was enough to retake P's from blocking syscalls. But it's not enough for reliable goroutine preemption. We need to ensure that sysmon runs if any goroutines are running. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/12167043 »»» R=rsc CC=golang-dev https://golang.org/cl/12171044
This commit is contained in:
parent
8679d5f2b5
commit
6ee69a9726
@ -1536,10 +1536,6 @@ exitsyscallfast(void)
|
|||||||
if(runtime·sched.pidle) {
|
if(runtime·sched.pidle) {
|
||||||
runtime·lock(&runtime·sched);
|
runtime·lock(&runtime·sched);
|
||||||
p = pidleget();
|
p = pidleget();
|
||||||
if(p && runtime·atomicload(&runtime·sched.sysmonwait)) {
|
|
||||||
runtime·atomicstore(&runtime·sched.sysmonwait, 0);
|
|
||||||
runtime·notewakeup(&runtime·sched.sysmonnote);
|
|
||||||
}
|
|
||||||
runtime·unlock(&runtime·sched);
|
runtime·unlock(&runtime·sched);
|
||||||
if(p) {
|
if(p) {
|
||||||
acquirep(p);
|
acquirep(p);
|
||||||
@ -1563,10 +1559,6 @@ exitsyscall0(G *gp)
|
|||||||
p = pidleget();
|
p = pidleget();
|
||||||
if(p == nil)
|
if(p == nil)
|
||||||
globrunqput(gp);
|
globrunqput(gp);
|
||||||
else if(runtime·atomicload(&runtime·sched.sysmonwait)) {
|
|
||||||
runtime·atomicstore(&runtime·sched.sysmonwait, 0);
|
|
||||||
runtime·notewakeup(&runtime·sched.sysmonnote);
|
|
||||||
}
|
|
||||||
runtime·unlock(&runtime·sched);
|
runtime·unlock(&runtime·sched);
|
||||||
if(p) {
|
if(p) {
|
||||||
acquirep(p);
|
acquirep(p);
|
||||||
@ -1932,38 +1924,24 @@ static struct {
|
|||||||
uintptr pcbuf[100];
|
uintptr pcbuf[100];
|
||||||
} prof;
|
} prof;
|
||||||
|
|
||||||
static void
|
|
||||||
System(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called if we receive a SIGPROF signal.
|
// Called if we receive a SIGPROF signal.
|
||||||
void
|
void
|
||||||
runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp)
|
runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp)
|
||||||
{
|
{
|
||||||
int32 n;
|
int32 n;
|
||||||
bool traceback;
|
|
||||||
|
|
||||||
if(prof.fn == nil || prof.hz == 0)
|
|
||||||
return;
|
|
||||||
traceback = true;
|
|
||||||
// Windows does profiling in a dedicated thread w/o m.
|
// Windows does profiling in a dedicated thread w/o m.
|
||||||
if(!Windows && (m == nil || m->mcache == nil))
|
if(!Windows && (m == nil || m->mcache == nil))
|
||||||
traceback = false;
|
return;
|
||||||
if(gp == m->g0 || gp == m->gsignal)
|
if(prof.fn == nil || prof.hz == 0)
|
||||||
traceback = false;
|
return;
|
||||||
if(m != nil && m->racecall)
|
|
||||||
traceback = false;
|
|
||||||
|
|
||||||
runtime·lock(&prof);
|
runtime·lock(&prof);
|
||||||
if(prof.fn == nil) {
|
if(prof.fn == nil) {
|
||||||
runtime·unlock(&prof);
|
runtime·unlock(&prof);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n = 1;
|
n = runtime·gentraceback((uintptr)pc, (uintptr)sp, (uintptr)lr, gp, 0, prof.pcbuf, nelem(prof.pcbuf), nil, nil, false);
|
||||||
prof.pcbuf[0] = (uintptr)pc;
|
|
||||||
if(traceback)
|
|
||||||
n = runtime·gentraceback((uintptr)pc, (uintptr)sp, (uintptr)lr, gp, 0, prof.pcbuf, nelem(prof.pcbuf), nil, nil, false);
|
|
||||||
if(n > 0)
|
if(n > 0)
|
||||||
prof.fn(prof.pcbuf, n);
|
prof.fn(prof.pcbuf, n);
|
||||||
runtime·unlock(&prof);
|
runtime·unlock(&prof);
|
||||||
|
Loading…
Reference in New Issue
Block a user