mirror of
https://github.com/golang/go
synced 2024-11-23 20:40:07 -07:00
runtime: fix freed page accounting in mHeap_ReclaimList
mHeap_ReclaimList is asked to reclaim at least npages pages, but it counts the number of spans reclaimed, not the number of pages reclaimed. The number of spans reclaimed is strictly larger than the number of pages, so this is not strictly wrong, but it is forcing more reclamation than was intended by the caller, which delays large allocations. Fix this by increasing the count by the number of pages in the swept span, rather than just increasing it by 1. Fixes #9048. Change-Id: I5ae364a9837a6012e68fcd431bba000340cfd50c Reviewed-on: https://go-review.googlesource.com/8920 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
bedb6f8aef
commit
69001e404e
@ -286,15 +286,9 @@ retry:
|
||||
// swept spans are at the end of the list
|
||||
mSpanList_InsertBack(list, s)
|
||||
unlock(&h.lock)
|
||||
snpages := s.npages
|
||||
if mSpan_Sweep(s, false) {
|
||||
// TODO(rsc,dvyukov): This is probably wrong.
|
||||
// It is undercounting the number of pages reclaimed.
|
||||
// See golang.org/issue/9048.
|
||||
// Note that if we want to add the true count of s's pages,
|
||||
// we must record that before calling mSpan_Sweep,
|
||||
// because if mSpan_Sweep returns true the span has
|
||||
// been
|
||||
n++
|
||||
n += snpages
|
||||
}
|
||||
lock(&h.lock)
|
||||
if n >= npages {
|
||||
|
Loading…
Reference in New Issue
Block a user