Skip to content

Commit e6fb39a

Browse files
mknyszekbradfitz
authored andcommitted
runtime: make the test addresses for pageAlloc smaller on 32-bit
This change makes the test addresses start at 1 GiB instead of 2 GiB to support mips and mipsle, which only have 31-bit address spaces. It also changes some tests to use smaller offsets for the chunk index to avoid jumping too far ahead in the address space to support 31-bit address spaces. The tests don't require such large jumps for what they're testing anyway. Updates #35112. Fixes #35440. Change-Id: Ic68ff2b0a1f10ef37ac00d4bb5b910ddcdc76f2e Reviewed-on: https://go-review.googlesource.com/c/go/+/205938 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
1 parent 78d4560 commit e6fb39a

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/runtime/export_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,10 @@ func FreePageAlloc(pp *PageAlloc) {
830830
// BaseChunkIdx is a convenient chunkIdx value which works on both
831831
// 64 bit and 32 bit platforms, allowing the tests to share code
832832
// between the two.
833-
var BaseChunkIdx = ChunkIdx(chunkIndex((0xc000*pageAlloc64Bit + 0x200*pageAlloc32Bit) * pallocChunkBytes))
833+
//
834+
// This should not be higher than 0x100*pallocChunkBytes to support
835+
// mips and mipsle, which only have 31-bit address spaces.
836+
var BaseChunkIdx = ChunkIdx(chunkIndex((0xc000*pageAlloc64Bit + 0x100*pageAlloc32Bit) * pallocChunkBytes))
834837

835838
// PageBase returns an address given a chunk index and a page index
836839
// relative to that chunk.

src/runtime/mpagealloc_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -279,24 +279,24 @@ func TestPageAllocAlloc(t *testing.T) {
279279
},
280280
"NotContiguousPallocChunkPages*2": {
281281
before: map[ChunkIdx][]BitRange{
282-
BaseChunkIdx: {},
283-
BaseChunkIdx + 0x100: {},
284-
BaseChunkIdx + 0x101: {},
282+
BaseChunkIdx: {},
283+
BaseChunkIdx + 0x40: {},
284+
BaseChunkIdx + 0x41: {},
285285
},
286286
scav: map[ChunkIdx][]BitRange{
287-
BaseChunkIdx: {{0, PallocChunkPages}},
288-
BaseChunkIdx + 0x100: {},
289-
BaseChunkIdx + 0x101: {},
287+
BaseChunkIdx: {{0, PallocChunkPages}},
288+
BaseChunkIdx + 0x40: {},
289+
BaseChunkIdx + 0x41: {},
290290
},
291291
hits: []hit{
292-
{PallocChunkPages * 2, PageBase(BaseChunkIdx+0x100, 0), 0},
292+
{PallocChunkPages * 2, PageBase(BaseChunkIdx+0x40, 0), 0},
293293
{21, PageBase(BaseChunkIdx, 0), 21 * PageSize},
294294
{1, PageBase(BaseChunkIdx, 21), PageSize},
295295
},
296296
after: map[ChunkIdx][]BitRange{
297-
BaseChunkIdx: {{0, 22}},
298-
BaseChunkIdx + 0x100: {{0, PallocChunkPages}},
299-
BaseChunkIdx + 0x101: {{0, PallocChunkPages}},
297+
BaseChunkIdx: {{0, 22}},
298+
BaseChunkIdx + 0x40: {{0, PallocChunkPages}},
299+
BaseChunkIdx + 0x41: {{0, PallocChunkPages}},
300300
},
301301
},
302302
"StraddlePallocChunkPages*2": {

0 commit comments

Comments
 (0)