Skip to content
Permalink
Browse files
8261230: GC tracing of page sizes are wrong in a few places
Reviewed-by: ayang, stuefe
  • Loading branch information
kstefanj committed Feb 12, 2021
1 parent 40ae993 commit 9f81ca8175a036027a3f5f19772c49bc4766411c
@@ -1497,8 +1497,8 @@ G1RegionToSpaceMapper* G1CollectedHeap::create_aux_memory_mapper(const char* des

os::trace_page_sizes_for_requested_size(description,
size,
preferred_page_size,
page_size,
preferred_page_size,
rs.base(),
rs.size());

@@ -50,7 +50,8 @@ ParMarkBitMap::initialize(MemRegion covered_region)
const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
MAX2(page_sz, granularity);
ReservedSpace rs(_reserved_byte_size, rs_align, rs_align > 0);
os::trace_page_sizes("Mark Bitmap", raw_bytes, raw_bytes, page_sz,
const size_t used_page_sz = ReservedSpace::actual_reserved_page_size(rs);
os::trace_page_sizes("Mark Bitmap", raw_bytes, raw_bytes, used_page_sz,
rs.base(), rs.size());

MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
@@ -172,11 +172,12 @@ ReservedHeapSpace GenCollectedHeap::allocate(size_t alignment) {
SIZE_FORMAT, total_reserved, alignment);

ReservedHeapSpace heap_rs = Universe::reserve_heap(total_reserved, alignment);
size_t used_page_size = ReservedSpace::actual_reserved_page_size(heap_rs);

os::trace_page_sizes("Heap",
MinHeapSize,
total_reserved,
alignment,
used_page_size,
heap_rs.base(),
heap_rs.size());

@@ -49,9 +49,40 @@
static long smallPageSize;
static long allocGranularity;

static boolean largePagesEnabled(OutputAnalyzer output) {
// The gc+init logging includes information about large pages.
String lp = output.firstMatch("Large Page Support: (\\w*)", 1);
return lp != null && lp.equals("Enabled");
}

static boolean largePagesAllocationFailure(OutputAnalyzer output, String pattern) {
// Check if there is a large page failure associated with the data structure
// being checked. In case of a large page allocation failure the output will
// include logs like this for the affected data structure:
// [0.048s][debug][gc,heap,coops] Reserve regular memory without large pages
// [0.048s][info ][pagesize ] Next Bitmap: ... page_size=4K ...
//
// The pattern passed in should match the second line.
String failureMatch = output.firstMatch("Reserve regular memory without large pages\\n.*" + pattern, 1);
if (failureMatch != null) {
return true;
}
return false;
}

static void checkSize(OutputAnalyzer output, long expectedSize, String pattern) {
String pageSizeStr = output.firstMatch(pattern, 1);
// First check the output for any large page allocation failure associated with
// the checked data structure. If we detect a failure then expect small pages.
if (largePagesAllocationFailure(output, pattern)) {
// This should only happen when we are expecting large pages
if (expectedSize == smallPageSize) {
throw new RuntimeException("Expected small page size when large page failure was detected");
}
expectedSize = smallPageSize;
}

// Now check what page size is traced.
String pageSizeStr = output.firstMatch(pattern, 1);
if (pageSizeStr == null) {
output.reportDiagnosticSummary();
throw new RuntimeException("Match from '" + pattern + "' got 'null' expected: " + expectedSize);
@@ -82,15 +113,21 @@ static void testVM(String what, long heapsize, boolean cardsShouldUseLargePages,
pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
"-XX:G1HeapRegionSize=" + HEAP_REGION_SIZE,
"-Xmx" + heapsize,
"-Xlog:pagesize",
"-Xlog:pagesize,gc+init,gc+heap+coops=debug",
"-XX:+UseLargePages",
"-XX:+IgnoreUnrecognizedVMOptions", // there is no ObjectAlignmentInBytes in 32 bit builds
"-XX:ObjectAlignmentInBytes=8",
"-version");

OutputAnalyzer output = new OutputAnalyzer(pb.start());
checkSmallTables(output, (cardsShouldUseLargePages ? largePageSize : smallPageSize));
checkBitmaps(output, (bitmapShouldUseLargePages ? largePageSize : smallPageSize));
// Only expect large page size if large pages are enabled.
if (largePagesEnabled(output)) {
checkSmallTables(output, (cardsShouldUseLargePages ? largePageSize : smallPageSize));
checkBitmaps(output, (bitmapShouldUseLargePages ? largePageSize : smallPageSize));
} else {
checkSmallTables(output, smallPageSize);
checkBitmaps(output, smallPageSize);
}
output.shouldHaveExitValue(0);

// Test with large page disabled.

1 comment on commit 9f81ca8

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 9f81ca8 Feb 12, 2021

Please sign in to comment.