comparison src/share/vm/services/memoryService.cpp @ 9038:4b8584c24ff4

8215934: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results Summary: Memory pools can now be optional collection participants, e.g., G1 Old Gen in an incremental collection. Reviewed-by: tschatzl, jcbeyler, andrew
author phh
date Mon, 28 Jan 2019 17:51:10 +0000
parents 55fb97c4c58d
children
comparison
equal deleted inserted replaced
19:a398d8b09369 20:ab6e6d07a766
1 /* 1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
185 _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager(); 185 _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
186 _managers_list->append(_minor_gc_manager); 186 _managers_list->append(_minor_gc_manager);
187 _managers_list->append(_major_gc_manager); 187 _managers_list->append(_major_gc_manager);
188 188
189 add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager); 189 add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
190 add_g1OldGen_memory_pool(g1h, _major_gc_manager); 190 add_g1OldGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
191 } 191 }
192 #endif // INCLUDE_ALL_GCS 192 #endif // INCLUDE_ALL_GCS
193 193
194 MemoryPool* MemoryService::add_gen(Generation* gen, 194 MemoryPool* MemoryService::add_gen(Generation* gen,
195 const char* name, 195 const char* name,
239 } 239 }
240 #endif // INCLUDE_ALL_GCS 240 #endif // INCLUDE_ALL_GCS
241 241
242 // Add memory pool(s) for one generation 242 // Add memory pool(s) for one generation
243 void MemoryService::add_generation_memory_pool(Generation* gen, 243 void MemoryService::add_generation_memory_pool(Generation* gen,
244 MemoryManager* major_mgr, 244 GCMemoryManager* major_mgr,
245 MemoryManager* minor_mgr) { 245 GCMemoryManager* minor_mgr) {
246 guarantee(gen != NULL, "No generation for memory pool"); 246 guarantee(gen != NULL, "No generation for memory pool");
247 Generation::Name kind = gen->kind(); 247 Generation::Name kind = gen->kind();
248 int index = _pools_list->length(); 248 int index = _pools_list->length();
249 249
250 switch (kind) { 250 switch (kind) {
330 } 330 }
331 } 331 }
332 332
333 333
334 #if INCLUDE_ALL_GCS 334 #if INCLUDE_ALL_GCS
335 void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) { 335 void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen,
336 GCMemoryManager* major_mgr,
337 GCMemoryManager* minor_mgr) {
336 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers"); 338 assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
337 339
338 // Add a memory pool for each space and young gen doesn't 340 // Add a memory pool for each space and young gen doesn't
339 // support low memory detection as it is expected to get filled up. 341 // support low memory detection as it is expected to get filled up.
340 EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen, 342 EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen,
354 minor_mgr->add_pool(survivor); 356 minor_mgr->add_pool(survivor);
355 _pools_list->append(eden); 357 _pools_list->append(eden);
356 _pools_list->append(survivor); 358 _pools_list->append(survivor);
357 } 359 }
358 360
359 void MemoryService::add_psOld_memory_pool(PSOldGen* gen, MemoryManager* mgr) { 361 void MemoryService::add_psOld_memory_pool(PSOldGen* gen, GCMemoryManager* mgr) {
360 PSGenerationPool* old_gen = new PSGenerationPool(gen, 362 PSGenerationPool* old_gen = new PSGenerationPool(gen,
361 "PS Old Gen", 363 "PS Old Gen",
362 MemoryPool::Heap, 364 MemoryPool::Heap,
363 true /* support_usage_threshold */); 365 true /* support_usage_threshold */);
364 mgr->add_pool(old_gen); 366 mgr->add_pool(old_gen);
365 _pools_list->append(old_gen); 367 _pools_list->append(old_gen);
366 } 368 }
367 369
368 void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h, 370 void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
369 MemoryManager* major_mgr, 371 GCMemoryManager* major_mgr,
370 MemoryManager* minor_mgr) { 372 GCMemoryManager* minor_mgr) {
371 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers"); 373 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
372 374
373 G1EdenPool* eden = new G1EdenPool(g1h); 375 G1EdenPool* eden = new G1EdenPool(g1h);
374 G1SurvivorPool* survivor = new G1SurvivorPool(g1h); 376 G1SurvivorPool* survivor = new G1SurvivorPool(g1h);
375 377
380 _pools_list->append(eden); 382 _pools_list->append(eden);
381 _pools_list->append(survivor); 383 _pools_list->append(survivor);
382 } 384 }
383 385
384 void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h, 386 void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
385 MemoryManager* mgr) { 387 GCMemoryManager* major_mgr,
386 assert(mgr != NULL, "should have one manager"); 388 GCMemoryManager* minor_mgr) {
389 assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
387 390
388 G1OldGenPool* old_gen = new G1OldGenPool(g1h); 391 G1OldGenPool* old_gen = new G1OldGenPool(g1h);
389 mgr->add_pool(old_gen); 392 major_mgr->add_pool(old_gen);
393 minor_mgr->add_pool(old_gen, false /* always_affected_by_gc */);
390 _pools_list->append(old_gen); 394 _pools_list->append(old_gen);
391 } 395 }
392 #endif // INCLUDE_ALL_GCS 396 #endif // INCLUDE_ALL_GCS
393 397
394 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) { 398 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) {
482 } 486 }
483 487
484 void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage, 488 void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage,
485 bool recordAccumulatedGCTime, 489 bool recordAccumulatedGCTime,
486 bool recordGCEndTime, bool countCollection, 490 bool recordGCEndTime, bool countCollection,
487 GCCause::Cause cause) { 491 GCCause::Cause cause,
492 bool allMemoryPoolsAffected) {
488 493
489 GCMemoryManager* mgr; 494 GCMemoryManager* mgr;
490 if (fullGC) { 495 if (fullGC) {
491 mgr = (GCMemoryManager*) _major_gc_manager; 496 mgr = (GCMemoryManager*) _major_gc_manager;
492 } else { 497 } else {
494 } 499 }
495 assert(mgr->is_gc_memory_manager(), "Sanity check"); 500 assert(mgr->is_gc_memory_manager(), "Sanity check");
496 501
497 // register the GC end statistics and memory usage 502 // register the GC end statistics and memory usage
498 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, 503 mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
499 countCollection, cause); 504 countCollection, cause, allMemoryPoolsAffected);
500 } 505 }
501 506
502 void MemoryService::oops_do(OopClosure* f) { 507 void MemoryService::oops_do(OopClosure* f) {
503 int i; 508 int i;
504 509
571 default: 576 default:
572 assert(false, "Unrecognized gc generation kind."); 577 assert(false, "Unrecognized gc generation kind.");
573 } 578 }
574 // this has to be called in a stop the world pause and represent 579 // this has to be called in a stop the world pause and represent
575 // an entire gc pause, start to finish: 580 // an entire gc pause, start to finish:
576 initialize(_fullGC, cause,true, true, true, true, true, true, true); 581 initialize(_fullGC, cause, true, true, true, true, true, true, true, true);
577 } 582 }
578 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC, 583 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
579 GCCause::Cause cause, 584 GCCause::Cause cause,
585 bool allMemoryPoolsAffected,
580 bool recordGCBeginTime, 586 bool recordGCBeginTime,
581 bool recordPreGCUsage, 587 bool recordPreGCUsage,
582 bool recordPeakUsage, 588 bool recordPeakUsage,
583 bool recordPostGCUsage, 589 bool recordPostGCUsage,
584 bool recordAccumulatedGCTime, 590 bool recordAccumulatedGCTime,
585 bool recordGCEndTime, 591 bool recordGCEndTime,
586 bool countCollection) { 592 bool countCollection) {
587 initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, 593 initialize(fullGC, cause, allMemoryPoolsAffected,
594 recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
588 recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, 595 recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
589 countCollection); 596 countCollection);
590 } 597 }
591 598
592 // for a subclass to create then initialize an instance before invoking 599 // for a subclass to create then initialize an instance before invoking
593 // the MemoryService 600 // the MemoryService
594 void TraceMemoryManagerStats::initialize(bool fullGC, 601 void TraceMemoryManagerStats::initialize(bool fullGC,
595 GCCause::Cause cause, 602 GCCause::Cause cause,
603 bool allMemoryPoolsAffected,
596 bool recordGCBeginTime, 604 bool recordGCBeginTime,
597 bool recordPreGCUsage, 605 bool recordPreGCUsage,
598 bool recordPeakUsage, 606 bool recordPeakUsage,
599 bool recordPostGCUsage, 607 bool recordPostGCUsage,
600 bool recordAccumulatedGCTime, 608 bool recordAccumulatedGCTime,
601 bool recordGCEndTime, 609 bool recordGCEndTime,
602 bool countCollection) { 610 bool countCollection) {
603 _fullGC = fullGC; 611 _fullGC = fullGC;
612 _allMemoryPoolsAffected = allMemoryPoolsAffected;
604 _recordGCBeginTime = recordGCBeginTime; 613 _recordGCBeginTime = recordGCBeginTime;
605 _recordPreGCUsage = recordPreGCUsage; 614 _recordPreGCUsage = recordPreGCUsage;
606 _recordPeakUsage = recordPeakUsage; 615 _recordPeakUsage = recordPeakUsage;
607 _recordPostGCUsage = recordPostGCUsage; 616 _recordPostGCUsage = recordPostGCUsage;
608 _recordAccumulatedGCTime = recordAccumulatedGCTime; 617 _recordAccumulatedGCTime = recordAccumulatedGCTime;
614 _recordPreGCUsage, _recordPeakUsage); 623 _recordPreGCUsage, _recordPeakUsage);
615 } 624 }
616 625
617 TraceMemoryManagerStats::~TraceMemoryManagerStats() { 626 TraceMemoryManagerStats::~TraceMemoryManagerStats() {
618 MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime, 627 MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
619 _recordGCEndTime, _countCollection, _cause); 628 _recordGCEndTime, _countCollection, _cause, _allMemoryPoolsAffected);
620 } 629 }