]> Cypherpunks repositories - gostls13.git/commit
runtime: scavenge memory on physical page-aligned boundaries
authorAustin Clements <austin@google.com>
Thu, 14 Apr 2016 17:41:36 +0000 (13:41 -0400)
committerAustin Clements <austin@google.com>
Sat, 16 Apr 2016 21:42:43 +0000 (21:42 +0000)
commit2cdcb6f8296b6528bb7d256a45e339c4aefb9109
treec4ff128c339bd03f313c0f9ab67b70eed94599da
parent1151473077fb03df798d4eb57a22fa820f9e41f8
runtime: scavenge memory on physical page-aligned boundaries

Currently the scavenger marks memory unused in multiples of the
allocator page size (8K). This is safe as long as the true physical
page size is 4K (or 8K), as it is on many platforms. However, on
ARM64, PPC64x, and MIPS64, the physical page size is larger than 8K,
so if we attempt to mark memory unused, the kernel will round the
boundaries of the region *out* to all pages covered by the requested
region, and we'll release a larger region of memory than intended. As
a result, the scavenger is currently disabled on these platforms.

Fix this by first rounding the region to be marked unused *in* to
multiples of the physical page size, so that when we ask the kernel to
mark it unused, it releases exactly the requested region.

Fixes #9993.

Change-Id: I96d5fdc2f77f9d69abadcea29bcfe55e68288cb1
Reviewed-on: https://go-review.googlesource.com/22066
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mheap.go