• Michael Anthony Knyszek's avatar
    runtime: turn off scavenger when there's <1 physical page of work · 08a72c85
    Michael Anthony Knyszek authored
    This change turns off the scavenger if there's less than one physical
    page of work to do. If there's less than one phyiscal page of work
    today, then the computed time for the work to be done will be zero,
    resulting in a floating point division by zero.
    
    This is bad on two accounts. On the one hand it could cause a fault on
    some systems. On the other hand, it could cause the pacing computations
    done by the scavenger to be nonsense. While this is generally harmless
    in the case where there's a very small amount of work to do anyway (the
    scavenger might just back off expontentially forever, or do some work
    and immediately sleep, because there's not much of it to do), it causes
    problems for the deadlock checker. On platforms with a larger physical
    page size, such as 64 KiB, we might hit this path in a deadlock
    scenario, in which case the deadlock checker will never fire and we'll
    just hang.
    
    Specifically, this happens on ppc64 trybot tests, which is where the
    issue was discovered.
    
    Fixes #34575.
    
    Change-Id: I8677db539447b2f0e75b8cfcbe33932244e1508c
    Reviewed-on: https://go-review.googlesource.com/c/go/+/203517
    Run-TryBot: Michael Knyszek <mknyszek@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarAustin Clements <austin@google.com>
    08a72c85
mgcscavenge.go 15.9 KB