Skip to content
This repository was archived by the owner on Sep 29, 2021. It is now read-only.

Commit d724e8a

Browse files
author
brutisso
committed
8145092: Use Unified Logging for the GC logging
Summary: JEP-271. VM changes contributed by brutisso, test changes contributed by david. Reviewed-by: sjohanss, david, brutisso Contributed-by: bengt.rutisson@oracle.com, david.lindholm@oralce.com
1 parent 23a3999 commit d724e8a

200 files changed

Lines changed: 3326 additions & 6142 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

hotspot/src/os/windows/vm/os_windows.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5719,7 +5719,7 @@ char* os::build_agent_function_name(const char *sym_name, const char *lib_name,
57195719
void TestReserveMemorySpecial_test() {
57205720
if (!UseLargePages) {
57215721
if (VerboseInternalVMTests) {
5722-
gclog_or_tty->print("Skipping test because large pages are disabled");
5722+
tty->print("Skipping test because large pages are disabled");
57235723
}
57245724
return;
57255725
}
@@ -5735,7 +5735,7 @@ void TestReserveMemorySpecial_test() {
57355735
char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
57365736
if (result == NULL) {
57375737
if (VerboseInternalVMTests) {
5738-
gclog_or_tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.",
5738+
tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.",
57395739
large_allocation_size);
57405740
}
57415741
} else {
@@ -5748,7 +5748,7 @@ void TestReserveMemorySpecial_test() {
57485748
char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false);
57495749
if (actual_location == NULL) {
57505750
if (VerboseInternalVMTests) {
5751-
gclog_or_tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
5751+
tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
57525752
expected_location, large_allocation_size);
57535753
}
57545754
} else {

hotspot/src/share/vm/Xusage.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
prepend in front of bootstrap class path
99
-Xnoclassgc disable class garbage collection
1010
-Xlog:<opts> control JVM logging, use -Xlog:help for details
11-
-Xloggc:<file> log GC status to a file with time stamps
1211
-Xbatch disable background compilation
1312
-Xms<size> set initial Java heap size
1413
-Xmx<size> set maximum Java heap size

hotspot/src/share/vm/gc/cms/allocationStats.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define SHARE_VM_GC_CMS_ALLOCATIONSTATS_HPP
2727

2828
#include "gc/shared/gcUtil.hpp"
29+
#include "logging/log.hpp"
2930
#include "memory/allocation.hpp"
3031
#include "utilities/globalDefinitions.hpp"
3132
#include "utilities/macros.hpp"
@@ -119,11 +120,9 @@ class AllocationStats VALUE_OBJ_CLASS_SPEC {
119120
ssize_t old_desired = _desired;
120121
float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
121122
_desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
122-
if (PrintFLSStatistics > 1) {
123-
gclog_or_tty->print_cr("demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, "
124-
"new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
125-
demand, old_rate, rate, new_rate, old_desired, _desired);
126-
}
123+
log_trace(gc, freelist)("demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, "
124+
"new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
125+
demand, old_rate, rate, new_rate, old_desired, _desired);
127126
}
128127
}
129128

hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.cpp

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,16 @@ void CompactibleFreeListSpace::print_on(outputStream* st) const {
400400

401401
void CompactibleFreeListSpace::print_indexed_free_lists(outputStream* st)
402402
const {
403-
reportIndexedFreeListStatistics();
404-
gclog_or_tty->print_cr("Layout of Indexed Freelists");
405-
gclog_or_tty->print_cr("---------------------------");
403+
reportIndexedFreeListStatistics(st);
404+
st->print_cr("Layout of Indexed Freelists");
405+
st->print_cr("---------------------------");
406406
AdaptiveFreeList<FreeChunk>::print_labels_on(st, "size");
407407
for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
408-
_indexedFreeList[i].print_on(gclog_or_tty);
409-
for (FreeChunk* fc = _indexedFreeList[i].head(); fc != NULL;
410-
fc = fc->next()) {
411-
gclog_or_tty->print_cr("\t[" PTR_FORMAT "," PTR_FORMAT ") %s",
412-
p2i(fc), p2i((HeapWord*)fc + i),
413-
fc->cantCoalesce() ? "\t CC" : "");
408+
_indexedFreeList[i].print_on(st);
409+
for (FreeChunk* fc = _indexedFreeList[i].head(); fc != NULL; fc = fc->next()) {
410+
st->print_cr("\t[" PTR_FORMAT "," PTR_FORMAT ") %s",
411+
p2i(fc), p2i((HeapWord*)fc + i),
412+
fc->cantCoalesce() ? "\t CC" : "");
414413
}
415414
}
416415
}
@@ -422,7 +421,7 @@ const {
422421

423422
void CompactibleFreeListSpace::print_dictionary_free_lists(outputStream* st)
424423
const {
425-
_dictionary->report_statistics();
424+
_dictionary->report_statistics(st);
426425
st->print_cr("Layout of Freelists in Tree");
427426
st->print_cr("---------------------------");
428427
_dictionary->print_free_lists(st);
@@ -472,54 +471,58 @@ size_t BlkPrintingClosure::do_blk(HeapWord* addr) {
472471
return sz;
473472
}
474473

475-
void CompactibleFreeListSpace::dump_at_safepoint_with_locks(CMSCollector* c,
476-
outputStream* st) {
477-
st->print_cr("\n=========================");
474+
void CompactibleFreeListSpace::dump_at_safepoint_with_locks(CMSCollector* c, outputStream* st) {
475+
st->print_cr("=========================");
478476
st->print_cr("Block layout in CMS Heap:");
479477
st->print_cr("=========================");
480478
BlkPrintingClosure bpcl(c, this, c->markBitMap(), st);
481479
blk_iterate(&bpcl);
482480

483-
st->print_cr("\n=======================================");
481+
st->print_cr("=======================================");
484482
st->print_cr("Order & Layout of Promotion Info Blocks");
485483
st->print_cr("=======================================");
486484
print_promo_info_blocks(st);
487485

488-
st->print_cr("\n===========================");
486+
st->print_cr("===========================");
489487
st->print_cr("Order of Indexed Free Lists");
490488
st->print_cr("=========================");
491489
print_indexed_free_lists(st);
492490

493-
st->print_cr("\n=================================");
491+
st->print_cr("=================================");
494492
st->print_cr("Order of Free Lists in Dictionary");
495493
st->print_cr("=================================");
496494
print_dictionary_free_lists(st);
497495
}
498496

499497

500-
void CompactibleFreeListSpace::reportFreeListStatistics() const {
498+
void CompactibleFreeListSpace::reportFreeListStatistics(const char* title) const {
501499
assert_lock_strong(&_freelistLock);
502-
assert(PrintFLSStatistics != 0, "Reporting error");
503-
_dictionary->report_statistics();
504-
if (PrintFLSStatistics > 1) {
505-
reportIndexedFreeListStatistics();
500+
LogHandle(gc, freelist, stats) log;
501+
if (!log.is_debug()) {
502+
return;
503+
}
504+
log.debug("%s", title);
505+
_dictionary->report_statistics(log.debug_stream());
506+
if (log.is_trace()) {
507+
ResourceMark rm;
508+
reportIndexedFreeListStatistics(log.trace_stream());
506509
size_t total_size = totalSizeInIndexedFreeLists() +
507510
_dictionary->total_chunk_size(DEBUG_ONLY(freelistLock()));
508-
gclog_or_tty->print(" free=" SIZE_FORMAT " frag=%1.4f\n", total_size, flsFrag());
511+
log.trace(" free=" SIZE_FORMAT " frag=%1.4f", total_size, flsFrag());
509512
}
510513
}
511514

512-
void CompactibleFreeListSpace::reportIndexedFreeListStatistics() const {
515+
void CompactibleFreeListSpace::reportIndexedFreeListStatistics(outputStream* st) const {
513516
assert_lock_strong(&_freelistLock);
514-
gclog_or_tty->print("Statistics for IndexedFreeLists:\n"
515-
"--------------------------------\n");
517+
st->print_cr("Statistics for IndexedFreeLists:");
518+
st->print_cr("--------------------------------");
516519
size_t total_size = totalSizeInIndexedFreeLists();
517-
size_t free_blocks = numFreeBlocksInIndexedFreeLists();
518-
gclog_or_tty->print("Total Free Space: " SIZE_FORMAT "\n", total_size);
519-
gclog_or_tty->print("Max Chunk Size: " SIZE_FORMAT "\n", maxChunkSizeInIndexedFreeLists());
520-
gclog_or_tty->print("Number of Blocks: " SIZE_FORMAT "\n", free_blocks);
520+
size_t free_blocks = numFreeBlocksInIndexedFreeLists();
521+
st->print_cr("Total Free Space: " SIZE_FORMAT, total_size);
522+
st->print_cr("Max Chunk Size: " SIZE_FORMAT, maxChunkSizeInIndexedFreeLists());
523+
st->print_cr("Number of Blocks: " SIZE_FORMAT, free_blocks);
521524
if (free_blocks != 0) {
522-
gclog_or_tty->print("Av. Block Size: " SIZE_FORMAT "\n", total_size/free_blocks);
525+
st->print_cr("Av. Block Size: " SIZE_FORMAT, total_size/free_blocks);
523526
}
524527
}
525528

@@ -1824,10 +1827,7 @@ CompactibleFreeListSpace::sweep_completed() {
18241827
void
18251828
CompactibleFreeListSpace::gc_prologue() {
18261829
assert_locked();
1827-
if (PrintFLSStatistics != 0) {
1828-
gclog_or_tty->print("Before GC:\n");
1829-
reportFreeListStatistics();
1830-
}
1830+
reportFreeListStatistics("Before GC:");
18311831
refillLinearAllocBlocksIfNeeded();
18321832
}
18331833

@@ -1837,11 +1837,7 @@ CompactibleFreeListSpace::gc_epilogue() {
18371837
assert(_promoInfo.noPromotions(), "_promoInfo inconsistency");
18381838
_promoInfo.stopTrackingPromotions();
18391839
repairLinearAllocationBlocks();
1840-
// Print Space's stats
1841-
if (PrintFLSStatistics != 0) {
1842-
gclog_or_tty->print("After GC:\n");
1843-
reportFreeListStatistics();
1844-
}
1840+
reportFreeListStatistics("After GC:");
18451841
}
18461842

18471843
// Iteration support, mostly delegated from a CMS generation
@@ -2014,9 +2010,7 @@ void CompactibleFreeListSpace::beginSweepFLCensus(
20142010
size_t i;
20152011
for (i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
20162012
AdaptiveFreeList<FreeChunk>* fl = &_indexedFreeList[i];
2017-
if (PrintFLSStatistics > 1) {
2018-
gclog_or_tty->print("size[" SIZE_FORMAT "] : ", i);
2019-
}
2013+
log_trace(gc, freelist)("size[" SIZE_FORMAT "] : ", i);
20202014
fl->compute_desired(inter_sweep_current, inter_sweep_estimate, intra_sweep_estimate);
20212015
fl->set_coal_desired((ssize_t)((double)fl->desired() * CMSSmallCoalSurplusPercent));
20222016
fl->set_before_sweep(fl->count());
@@ -2065,16 +2059,10 @@ void CompactibleFreeListSpace::clearFLCensus() {
20652059
}
20662060

20672061
void CompactibleFreeListSpace::endSweepFLCensus(size_t sweep_count) {
2068-
if (PrintFLSStatistics > 0) {
2069-
HeapWord* largestAddr = (HeapWord*) dictionary()->find_largest_dict();
2070-
gclog_or_tty->print_cr("CMS: Large block " PTR_FORMAT,
2071-
p2i(largestAddr));
2072-
}
2062+
log_debug(gc, freelist)("CMS: Large block " PTR_FORMAT, p2i(dictionary()->find_largest_dict()));
20732063
setFLSurplus();
20742064
setFLHints();
2075-
if (PrintGC && PrintFLSCensus > 0) {
2076-
printFLCensus(sweep_count);
2077-
}
2065+
printFLCensus(sweep_count);
20782066
clearFLCensus();
20792067
assert_locked();
20802068
_dictionary->end_sweep_dict_census(CMSLargeSplitSurplusPercent);
@@ -2213,14 +2201,15 @@ class VerifyAllBlksClosure: public BlkClosure {
22132201
}
22142202
}
22152203
if (res == 0) {
2216-
gclog_or_tty->print_cr("Livelock: no rank reduction!");
2217-
gclog_or_tty->print_cr(
2218-
" Current: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
2219-
" Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
2204+
LogHandle(gc, verify) log;
2205+
log.info("Livelock: no rank reduction!");
2206+
log.info(" Current: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
2207+
" Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
22202208
p2i(addr), res, was_obj ?"true":"false", was_live ?"true":"false",
22212209
p2i(_last_addr), _last_size, _last_was_obj?"true":"false", _last_was_live?"true":"false");
2222-
_sp->print_on(gclog_or_tty);
2223-
guarantee(false, "Seppuku!");
2210+
ResourceMark rm;
2211+
_sp->print_on(log.info_stream());
2212+
guarantee(false, "Verification failed.");
22242213
}
22252214
_last_addr = addr;
22262215
_last_size = res;
@@ -2386,17 +2375,23 @@ void CompactibleFreeListSpace::check_free_list_consistency() const {
23862375

23872376
void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
23882377
assert_lock_strong(&_freelistLock);
2378+
LogHandle(gc, freelist, census) log;
2379+
if (!log.is_debug()) {
2380+
return;
2381+
}
23892382
AdaptiveFreeList<FreeChunk> total;
2390-
gclog_or_tty->print("end sweep# " SIZE_FORMAT "\n", sweep_count);
2391-
AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, "size");
2383+
log.debug("end sweep# " SIZE_FORMAT, sweep_count);
2384+
ResourceMark rm;
2385+
outputStream* out = log.debug_stream();
2386+
AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
23922387
size_t total_free = 0;
23932388
for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
23942389
const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
23952390
total_free += fl->count() * fl->size();
23962391
if (i % (40*IndexSetStride) == 0) {
2397-
AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, "size");
2392+
AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
23982393
}
2399-
fl->print_on(gclog_or_tty);
2394+
fl->print_on(out);
24002395
total.set_bfr_surp( total.bfr_surp() + fl->bfr_surp() );
24012396
total.set_surplus( total.surplus() + fl->surplus() );
24022397
total.set_desired( total.desired() + fl->desired() );
@@ -2408,14 +2403,13 @@ void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
24082403
total.set_split_births(total.split_births() + fl->split_births());
24092404
total.set_split_deaths(total.split_deaths() + fl->split_deaths());
24102405
}
2411-
total.print_on(gclog_or_tty, "TOTAL");
2412-
gclog_or_tty->print_cr("Total free in indexed lists "
2413-
SIZE_FORMAT " words", total_free);
2414-
gclog_or_tty->print("growth: %8.5f deficit: %8.5f\n",
2415-
(double)(total.split_births()+total.coal_births()-total.split_deaths()-total.coal_deaths())/
2416-
(total.prev_sweep() != 0 ? (double)total.prev_sweep() : 1.0),
2417-
(double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0));
2418-
_dictionary->print_dict_census();
2406+
total.print_on(out, "TOTAL");
2407+
log.debug("Total free in indexed lists " SIZE_FORMAT " words", total_free);
2408+
log.debug("growth: %8.5f deficit: %8.5f",
2409+
(double)(total.split_births()+total.coal_births()-total.split_deaths()-total.coal_deaths())/
2410+
(total.prev_sweep() != 0 ? (double)total.prev_sweep() : 1.0),
2411+
(double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0));
2412+
_dictionary->print_dict_census(out);
24192413
}
24202414

24212415
///////////////////////////////////////////////////////////////////////////
@@ -2544,10 +2538,7 @@ void CFLS_LAB::compute_desired_plab_size() {
25442538
// Reset counters for next round
25452539
_global_num_workers[i] = 0;
25462540
_global_num_blocks[i] = 0;
2547-
if (PrintOldPLAB) {
2548-
gclog_or_tty->print_cr("[" SIZE_FORMAT "]: " SIZE_FORMAT,
2549-
i, (size_t)_blocks_to_claim[i].average());
2550-
}
2541+
log_trace(gc, plab)("[" SIZE_FORMAT "]: " SIZE_FORMAT, i, (size_t)_blocks_to_claim[i].average());
25512542
}
25522543
}
25532544
}
@@ -2584,10 +2575,8 @@ void CFLS_LAB::retire(int tid) {
25842575
_indexedFreeList[i].set_size(i);
25852576
}
25862577
}
2587-
if (PrintOldPLAB) {
2588-
gclog_or_tty->print_cr("%d[" SIZE_FORMAT "]: " SIZE_FORMAT "/" SIZE_FORMAT "/" SIZE_FORMAT,
2589-
tid, i, num_retire, _num_blocks[i], (size_t)_blocks_to_claim[i].average());
2590-
}
2578+
log_trace(gc, plab)("%d[" SIZE_FORMAT "]: " SIZE_FORMAT "/" SIZE_FORMAT "/" SIZE_FORMAT,
2579+
tid, i, num_retire, _num_blocks[i], (size_t)_blocks_to_claim[i].average());
25912580
// Reset stats for next round
25922581
_num_blocks[i] = 0;
25932582
}

hotspot/src/share/vm/gc/cms/compactibleFreeListSpace.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "gc/cms/promotionInfo.hpp"
3030
#include "gc/shared/blockOffsetTable.hpp"
3131
#include "gc/shared/space.hpp"
32+
#include "logging/log.hpp"
3233
#include "memory/binaryTreeDictionary.hpp"
3334
#include "memory/freeList.hpp"
3435

@@ -275,8 +276,8 @@ class CompactibleFreeListSpace: public CompactibleSpace {
275276
void verify_objects_initialized() const;
276277

277278
// Statistics reporting helper functions
278-
void reportFreeListStatistics() const;
279-
void reportIndexedFreeListStatistics() const;
279+
void reportFreeListStatistics(const char* title) const;
280+
void reportIndexedFreeListStatistics(outputStream* st) const;
280281
size_t maxChunkSizeInIndexedFreeLists() const;
281282
size_t numFreeBlocksInIndexedFreeLists() const;
282283
// Accessor
@@ -450,11 +451,9 @@ class CompactibleFreeListSpace: public CompactibleSpace {
450451
void save_sweep_limit() {
451452
_sweep_limit = BlockOffsetArrayUseUnallocatedBlock ?
452453
unallocated_block() : end();
453-
if (CMSTraceSweeper) {
454-
gclog_or_tty->print_cr(">>>>> Saving sweep limit " PTR_FORMAT
455-
" for space [" PTR_FORMAT "," PTR_FORMAT ") <<<<<<",
456-
p2i(_sweep_limit), p2i(bottom()), p2i(end()));
457-
}
454+
log_develop_trace(gc, sweep)(">>>>> Saving sweep limit " PTR_FORMAT
455+
" for space [" PTR_FORMAT "," PTR_FORMAT ") <<<<<<",
456+
p2i(_sweep_limit), p2i(bottom()), p2i(end()));
458457
}
459458
NOT_PRODUCT(
460459
void clear_sweep_limit() { _sweep_limit = NULL; }

0 commit comments

Comments
 (0)