diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-10-28 09:12:20 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-10-28 09:12:20 -0400 |
commit | a16e30d162c1c7408db7821e7b9513cefa09c6ca (patch) | |
tree | af752ba9ba44c547df39bb0af9bff79f610ba9d5 /src/runtime/mgcscavenge_test.go | |
parent | 91e4d2d57bc341dd82c98247117114c851380aef (diff) | |
parent | cf6cfba4d5358404dd890f6025e573a4b2156543 (diff) | |
download | go-dev.link.tar.gz go-dev.link.zip |
[dev.link] all: merge branch 'master' into dev.linkdev.link
Clean merge.
Change-Id: Ia7b2808bc649790198d34c226a61d9e569084dc5
Diffstat (limited to 'src/runtime/mgcscavenge_test.go')
-rw-r--r-- | src/runtime/mgcscavenge_test.go | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/src/runtime/mgcscavenge_test.go b/src/runtime/mgcscavenge_test.go index 7f619b1e7d..250343077f 100644 --- a/src/runtime/mgcscavenge_test.go +++ b/src/runtime/mgcscavenge_test.go @@ -235,26 +235,43 @@ func TestPallocDataFindScavengeCandidate(t *testing.T) { if PhysHugePageSize > uintptr(PageSize) { // Check hugepage preserving behavior. bits := uint(PhysHugePageSize / uintptr(PageSize)) - tests["PreserveHugePageBottom"] = test{ - alloc: []BitRange{{bits + 2, PallocChunkPages - (bits + 2)}}, - min: 1, - max: 3, // Make it so that max would have us try to break the huge page. - want: BitRange{0, bits + 2}, - } - if 3*bits < PallocChunkPages { - // We need at least 3 huge pages in a chunk for this test to make sense. - tests["PreserveHugePageMiddle"] = test{ - alloc: []BitRange{{0, bits - 10}, {2*bits + 10, PallocChunkPages - (2*bits + 10)}}, + if bits < PallocChunkPages { + tests["PreserveHugePageBottom"] = test{ + alloc: []BitRange{{bits + 2, PallocChunkPages - (bits + 2)}}, min: 1, - max: 12, // Make it so that max would have us try to break the huge page. - want: BitRange{bits, bits + 10}, + max: 3, // Make it so that max would have us try to break the huge page. + want: BitRange{0, bits + 2}, + } + if 3*bits < PallocChunkPages { + // We need at least 3 huge pages in a chunk for this test to make sense. + tests["PreserveHugePageMiddle"] = test{ + alloc: []BitRange{{0, bits - 10}, {2*bits + 10, PallocChunkPages - (2*bits + 10)}}, + min: 1, + max: 12, // Make it so that max would have us try to break the huge page. + want: BitRange{bits, bits + 10}, + } + } + tests["PreserveHugePageTop"] = test{ + alloc: []BitRange{{0, PallocChunkPages - bits}}, + min: 1, + max: 1, // Even one page would break a huge page in this case. + want: BitRange{PallocChunkPages - bits, bits}, + } + } else if bits == PallocChunkPages { + tests["PreserveHugePageAll"] = test{ + min: 1, + max: 1, // Even one page would break a huge page in this case. + want: BitRange{0, PallocChunkPages}, + } + } else { + // The huge page size is greater than pallocChunkPages, so it should + // be effectively disabled. There's no way we can possible scavenge + // a huge page out of this bitmap chunk. + tests["PreserveHugePageNone"] = test{ + min: 1, + max: 1, + want: BitRange{PallocChunkPages - 1, 1}, } - } - tests["PreserveHugePageTop"] = test{ - alloc: []BitRange{{0, PallocChunkPages - bits}}, - min: 1, - max: 1, // Even one page would break a huge page in this case. - want: BitRange{PallocChunkPages - bits, bits}, } } for name, v := range tests { |