@@ -1917,11 +1917,6 @@ func oneNewExtraM() {
1917
1917
if raceenabled {
1918
1918
gp .racectx = racegostart (abi .FuncPCABIInternal (newextram ) + sys .PCQuantum )
1919
1919
}
1920
- if trace .enabled {
1921
- traceGoCreate (gp , 0 ) // no start pc
1922
- gp .traceseq ++
1923
- traceEvent (traceEvGoInSyscall , - 1 , uint64 (gp .goid ))
1924
- }
1925
1920
// put on allg for garbage collector
1926
1921
allgadd (gp )
1927
1922
@@ -2515,9 +2510,13 @@ func execute(gp *g, inheritTime bool) {
2515
2510
}
2516
2511
2517
2512
if trace .enabled {
2518
- // GoSysExit has to happen when we have a P, but before GoStart.
2519
- // So we emit it here.
2520
- if gp .syscallsp != 0 && gp .sysblocktraced {
2513
+ if gp .m .isextra && gp .m .cgolevel == 0 {
2514
+ // GoCreate happen in needm, but there is no P.
2515
+ // So we emit it here.
2516
+ traceGoCreate (gp , 0 ) // no start pc for locked g in extra M
2517
+ } else if gp .syscallsp != 0 && gp .sysblocktraced {
2518
+ // GoSysExit has to happen when we have a P, but before GoStart.
2519
+ // So we emit it here.
2521
2520
traceGoSysExit (gp .sysexitticks )
2522
2521
}
2523
2522
traceGoStart ()
@@ -3615,7 +3614,14 @@ func reentersyscall(pc, sp uintptr) {
3615
3614
}
3616
3615
3617
3616
if trace .enabled {
3618
- systemstack (traceGoSysCall )
3617
+ if _g_ .m .isextra && _g_ .m .cgolevel == 0 {
3618
+ systemstack (func () {
3619
+ traceGoEnd ()
3620
+ traceProcStop (_g_ .m .p .ptr ())
3621
+ })
3622
+ } else {
3623
+ systemstack (traceGoSysCall )
3624
+ }
3619
3625
// systemstack itself clobbers g.sched.{pc,sp} and we might
3620
3626
// need them later when the G is genuinely blocked in a
3621
3627
// syscall
@@ -3639,10 +3645,19 @@ func reentersyscall(pc, sp uintptr) {
3639
3645
pp .m = 0
3640
3646
_g_ .m .oldp .set (pp )
3641
3647
_g_ .m .p = 0
3642
- atomic .Store (& pp .status , _Psyscall )
3643
- if sched .gcwaiting != 0 {
3644
- systemstack (entersyscall_gcwait )
3648
+
3649
+ if _g_ .m .isextra && _g_ .m .cgolevel == 0 {
3650
+ atomic .Store (& pp .status , _Pidle )
3651
+ systemstack (func () {
3652
+ handoffp (pp )
3653
+ })
3645
3654
save (pc , sp )
3655
+ } else {
3656
+ atomic .Store (& pp .status , _Psyscall )
3657
+ if sched .gcwaiting != 0 {
3658
+ systemstack (entersyscall_gcwait )
3659
+ save (pc , sp )
3660
+ }
3646
3661
}
3647
3662
3648
3663
_g_ .m .locks --
@@ -3851,7 +3866,13 @@ func exitsyscallfast(oldp *p) bool {
3851
3866
osyield ()
3852
3867
}
3853
3868
}
3854
- traceGoSysExit (0 )
3869
+ if _g_ .m .isextra && _g_ .m .cgolevel == 0 {
3870
+ // GoCreate happen in needm, but there is no P.
3871
+ // So we emit it here.
3872
+ traceGoCreate (_g_ , 0 ) // no start pc for locked g in extra M
3873
+ } else {
3874
+ traceGoSysExit (0 )
3875
+ }
3855
3876
}
3856
3877
})
3857
3878
if ok {
@@ -3874,10 +3895,16 @@ func exitsyscallfast_reacquired() {
3874
3895
// traceGoSysBlock for this syscall was already emitted,
3875
3896
// but here we effectively retake the p from the new syscall running on the same p.
3876
3897
systemstack (func () {
3877
- // Denote blocking of the new syscall.
3878
- traceGoSysBlock (_g_ .m .p .ptr ())
3879
- // Denote completion of the current syscall.
3880
- traceGoSysExit (0 )
3898
+ if _g_ .m .isextra && _g_ .m .cgolevel == 0 {
3899
+ // GoCreate happen in needm, but there is no P.
3900
+ // So we emit it here.
3901
+ traceGoCreate (_g_ , 0 ) // no start pc for locked g in extra M
3902
+ } else {
3903
+ // Denote blocking of the new syscall.
3904
+ traceGoSysBlock (_g_ .m .p .ptr ())
3905
+ // Denote completion of the current syscall.
3906
+ traceGoSysExit (0 )
3907
+ }
3881
3908
})
3882
3909
}
3883
3910
_g_ .m .p .ptr ().syscalltick ++
0 commit comments