Skip to content

Commit 37715cc

Browse files
committed
runtime: relax TestAsyncPreempt
In TestAsyncPreempt, the function being tested for preemption, although still asynchronously preemptible, may have only samll ranges of PCs that are preemtible. In an unlucky run, it may take quite a while to have a signal that lands on a preemptible instruction. The test case is kind of an extreme. Relax it to make it more preemptible. In the original version, the first closure has more work to do, and it is not a leaf function, and the second test case is a frameless leaf function. In the current version, the first one is also a frameless leaf function (the atomic is intrinsified). Add some calls to it. It is still not preemptible without async preemption. Fixes #35608. Change-Id: Ia4f857f2afc55501c6568d7507b517e3b4db191c Reviewed-on: https://go-review.googlesource.com/c/go/+/208221 Run-TryBot: Cherry Zhang <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent c7e73ef commit 37715cc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/runtime/testdata/testprog/preempt.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ func AsyncPreempt() {
2626
go func() {
2727
for {
2828
atomic.StoreUint32(&ready, 1)
29+
dummy()
30+
dummy()
2931
}
3032
}()
3133
// Also start one with a frameless function.
@@ -53,8 +55,11 @@ func AsyncPreempt() {
5355
//go:noinline
5456
func frameless() {
5557
for i := int64(0); i < 1<<62; i++ {
56-
out += i
58+
out += i * i * i * i * i * 12345
5759
}
5860
}
5961

6062
var out int64
63+
64+
//go:noinline
65+
func dummy() {}

0 commit comments

Comments
 (0)