From c3ab26e8bb0c5bf1c20358d036f987a20734c9ad Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 16 Feb 2018 16:42:53 +0000 Subject: runtime: add some more preemption checks In particular this lets BenchmarkPingPongHog in runtime/proc_test.go complete. Reviewed-on: https://go-review.googlesource.com/94735 From-SVN: r257743 --- libgo/go/runtime/proc.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libgo/go/runtime/proc.go') diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index edf4140..1d95109 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -4084,8 +4084,9 @@ func preemptone(_p_ *p) bool { // setting a global variable and figuring out a way to efficiently // check that global variable. // - // For now we check gp.preempt in schedule and mallocgc, - // which is at least better than doing nothing at all. + // For now we check gp.preempt in schedule, mallocgc, selectgo, + // and a few other places, which is at least better than doing + // nothing at all. return true } -- cgit v1.1 From 911cef2e3ba7548ee13e761f88457c6bbe1fa7fe Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 20 Feb 2018 15:30:31 +0000 Subject: runtime: allow preemption in fast syscall return Let a fast syscall return be a preemption point. This helps with tight loops that make system calls, as in BenchmarkSyscallExcessWork. Reviewed-on: https://go-review.googlesource.com/94895 From-SVN: r257848 --- libgo/go/runtime/proc.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libgo/go/runtime/proc.go') diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index 1d95109..20fa0ad 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -2794,6 +2794,13 @@ func exitsyscall(dummy int32) { exitsyscallclear(_g_) _g_.m.locks-- _g_.throwsplit = false + + // Check preemption, since unlike gc we don't check on + // every call. + if getg().preempt { + checkPreempt() + } + return } -- cgit v1.1