Tue, 28 May 2013 09:32:06 +0200
8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
Summary: Fixed the output of G1SummarizeRSetStats: too small datatype for the number of concurrently processed cards, added concurrent remembered set thread time retrieval for Linux and Windows (BSD uses os::elapsedTime() now), and other cleanup. The information presented during VM operation is now relative to the previous output, not always cumulative if G1SummarizeRSetStatsPeriod > 0. At VM exit, the code prints a cumulative summary.
Reviewed-by: johnc, jwilhelm
1 /*
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
28 #include "gc_implementation/g1/heapRegionSet.hpp"
30 //////////////////// HeapRegionSetBase ////////////////////
32 inline void HeapRegionSetBase::update_for_addition(HeapRegion* hr) {
33 // Assumes the caller has already verified the region.
35 _length += 1;
36 _region_num += hr->region_num();
37 _total_used_bytes += hr->used();
38 }
40 inline void HeapRegionSetBase::add_internal(HeapRegion* hr) {
41 hrs_assert_region_ok(this, hr, NULL);
42 assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked"));
44 update_for_addition(hr);
45 hr->set_containing_set(this);
46 }
48 inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) {
49 // Assumes the caller has already verified the region.
50 assert(_length > 0, hrs_ext_msg(this, "pre-condition"));
51 _length -= 1;
53 uint region_num_diff = hr->region_num();
54 assert(region_num_diff <= _region_num,
55 hrs_err_msg("[%s] region's region num: %u "
56 "should be <= region num: %u",
57 name(), region_num_diff, _region_num));
58 _region_num -= region_num_diff;
60 size_t used_bytes = hr->used();
61 assert(used_bytes <= _total_used_bytes,
62 hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" "
63 "should be <= used bytes: "SIZE_FORMAT,
64 name(), used_bytes, _total_used_bytes));
65 _total_used_bytes -= used_bytes;
66 }
68 inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) {
69 hrs_assert_region_ok(this, hr, this);
70 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked"));
72 hr->set_containing_set(NULL);
73 update_for_removal(hr);
74 }
76 //////////////////// HeapRegionSet ////////////////////
78 inline void HeapRegionSet::add(HeapRegion* hr) {
79 hrs_assert_mt_safety_ok(this);
80 // add_internal() will verify the region.
81 add_internal(hr);
82 }
84 inline void HeapRegionSet::remove(HeapRegion* hr) {
85 hrs_assert_mt_safety_ok(this);
86 // remove_internal() will verify the region.
87 remove_internal(hr);
88 }
90 inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr,
91 HeapRegionSet* proxy_set) {
92 // No need to fo the MT safety check here given that this method
93 // does not update the contents of the set but instead accumulates
94 // the changes in proxy_set which is assumed to be thread-local.
95 hrs_assert_sets_match(this, proxy_set);
96 hrs_assert_region_ok(this, hr, this);
98 hr->set_containing_set(NULL);
99 proxy_set->update_for_addition(hr);
100 }
102 //////////////////// HeapRegionLinkedList ////////////////////
104 inline void HeapRegionLinkedList::add_as_head(HeapRegion* hr) {
105 hrs_assert_mt_safety_ok(this);
106 assert((length() == 0 && _head == NULL && _tail == NULL) ||
107 (length() > 0 && _head != NULL && _tail != NULL),
108 hrs_ext_msg(this, "invariant"));
109 // add_internal() will verify the region.
110 add_internal(hr);
112 // Now link the region.
113 if (_head != NULL) {
114 hr->set_next(_head);
115 } else {
116 _tail = hr;
117 }
118 _head = hr;
119 }
121 inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) {
122 hrs_assert_mt_safety_ok(this);
123 assert((length() == 0 && _head == NULL && _tail == NULL) ||
124 (length() > 0 && _head != NULL && _tail != NULL),
125 hrs_ext_msg(this, "invariant"));
126 // add_internal() will verify the region.
127 add_internal(hr);
129 // Now link the region.
130 if (_tail != NULL) {
131 _tail->set_next(hr);
132 } else {
133 _head = hr;
134 }
135 _tail = hr;
136 }
138 inline HeapRegion* HeapRegionLinkedList::remove_head() {
139 hrs_assert_mt_safety_ok(this);
140 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty"));
141 assert(length() > 0 && _head != NULL && _tail != NULL,
142 hrs_ext_msg(this, "invariant"));
144 // We need to unlink it first.
145 HeapRegion* hr = _head;
146 _head = hr->next();
147 if (_head == NULL) {
148 _tail = NULL;
149 }
150 hr->set_next(NULL);
152 // remove_internal() will verify the region.
153 remove_internal(hr);
154 return hr;
155 }
157 inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() {
158 hrs_assert_mt_safety_ok(this);
160 if (!is_empty()) {
161 return remove_head();
162 } else {
163 return NULL;
164 }
165 }
167 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP