From d67c3523b9f2f54698d7234f5e62774fa64ca060 Mon Sep 17 00:00:00 2001 From: ysr Date: Mon, 20 Jun 2011 09:42:26 -0700 Subject: [PATCH] 6916968: CMS: freeList.cpp:304 assert(_allocation_stats.prevSweep() + ..., "Conservation Principle") Summary: Fix assert and adjust demand volume computation by adding missing factor. Reviewed-by: jmasa, tonyp --- .../concurrentMarkSweep/freeList.cpp | 17 +++++++++++++++-- .../shared/allocationStats.hpp | 16 +++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/freeList.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/freeList.cpp index 495647542..192b05548 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/freeList.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/freeList.cpp @@ -300,8 +300,21 @@ void FreeList::verify_stats() const { // dictionary for example, this might be the first block and // in that case there would be no place that we could record // the stats (which are kept in the block itself). - assert(_allocation_stats.prevSweep() + _allocation_stats.splitBirths() + 1 // Total Stock + 1 - >= _allocation_stats.splitDeaths() + (ssize_t)count(), "Conservation Principle"); + assert((_allocation_stats.prevSweep() + _allocation_stats.splitBirths() + + _allocation_stats.coalBirths() + 1) // Total Production Stock + 1 + >= (_allocation_stats.splitDeaths() + _allocation_stats.coalDeaths() + + (ssize_t)count()), // Total Current Stock + depletion + err_msg("FreeList " PTR_FORMAT " of size " SIZE_FORMAT + " violates Conservation Principle: " + "prevSweep(" SIZE_FORMAT ")" + " + splitBirths(" SIZE_FORMAT ")" + " + coalBirths(" SIZE_FORMAT ") + 1 >= " + " splitDeaths(" SIZE_FORMAT ")" + " coalDeaths(" SIZE_FORMAT ")" + " + count(" SSIZE_FORMAT ")", + this, _size, _allocation_stats.prevSweep(), _allocation_stats.splitBirths(), + _allocation_stats.splitBirths(), _allocation_stats.splitDeaths(), + _allocation_stats.coalDeaths(), count())); } void FreeList::assert_proper_lock_protection_work() const { diff --git a/src/share/vm/gc_implementation/shared/allocationStats.hpp b/src/share/vm/gc_implementation/shared/allocationStats.hpp index b21823423..1c945388a 100644 --- a/src/share/vm/gc_implementation/shared/allocationStats.hpp +++ b/src/share/vm/gc_implementation/shared/allocationStats.hpp @@ -99,14 +99,16 @@ class AllocationStats VALUE_OBJ_CLASS_SPEC { // vulnerable to noisy glitches. In such cases, we // ignore the current sample and use currently available // historical estimates. - // XXX NEEDS TO BE FIXED - // assert(prevSweep() + splitBirths() >= splitDeaths() + (ssize_t)count, "Conservation Principle"); - // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - // "Total Stock" "Not used at this block size" + assert(prevSweep() + splitBirths() + coalBirths() // "Total Production Stock" + >= splitDeaths() + coalDeaths() + (ssize_t)count, // "Current stock + depletion" + "Conservation Principle"); if (inter_sweep_current > _threshold) { - ssize_t demand = prevSweep() - (ssize_t)count + splitBirths() - splitDeaths(); - // XXX NEEDS TO BE FIXED - // assert(demand >= 0, "Demand should be non-negative"); + ssize_t demand = prevSweep() - (ssize_t)count + splitBirths() + coalBirths() + - splitDeaths() - coalDeaths(); + assert(demand >= 0, + err_msg("Demand (" SSIZE_FORMAT ") should be non-negative for " + PTR_FORMAT " (size=" SIZE_FORMAT ")", + demand, this, count)); // Defensive: adjust for imprecision in event counting if (demand < 0) { demand = 0; -- GitLab