1 /*
2 * Copyright (c) 2016, 2019, Red Hat, Inc. 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 */
24
25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP
27
28 #include "memory/allocation.hpp"
29
30 /**
31 * This provides the following in JVMStat:
32 *
33 * constants:
34 * - sun.gc.shenandoah.regions.timestamp the timestamp for this sample
35 * - sun.gc.shenandoah.regions.max_regions maximum number of regions
36 * - sun.gc.shenandoah.regions.region_size size per region, in kilobytes
37 *
38 * variables:
39 * - sun.gc.shenandoah.regions.status current GC status:
40 * - bit 0 set when marking in progress
41 * - bit 1 set when evacuation in progress
42 * - bit 2 set when update refs in progress
43 *
44 * two variable counters per region, with $max_regions (see above) counters:
45 * - sun.gc.shenandoah.regions.region.$i.data
46 * where $ is the region number from 0 <= i < $max_regions
47 *
48 * .data is in the following format:
49 * - bits 0-6 used memory in percent
50 * - bits 7-13 live memory in percent
51 * - bits 14-20 tlab allocated memory in percent
52 * - bits 21-27 gclab allocated memory in percent
53 * - bits 28-34 shared allocated memory in percent
54 * - bits 35-41 <reserved>
55 * - bits 42-50 <reserved>
56 * - bits 51-57 <reserved>
57 * - bits 58-63 status
58 * - bits describe the state as recorded in ShenandoahHeapRegion
59 */
60 class ShenandoahHeapRegionCounters : public CHeapObj<mtGC> {
61 private:
62 static const jlong PERCENT_MASK = 0x7f;
63 static const jlong STATUS_MASK = 0x3f;
64
65 static const jlong USED_SHIFT = 0;
66 static const jlong LIVE_SHIFT = 7;
67 static const jlong TLAB_SHIFT = 14;
68 static const jlong GCLAB_SHIFT = 21;
69 static const jlong SHARED_SHIFT = 28;
70
71 static const jlong STATUS_SHIFT = 58;
72
73 char* _name_space;
74 PerfLongVariable** _regions_data;
75 PerfLongVariable* _timestamp;
76 PerfLongVariable* _status;
77 volatile jlong _last_sample_millis;
78
79 public:
80 ShenandoahHeapRegionCounters();
81 ~ShenandoahHeapRegionCounters();
82 void update();
83 };
84
85 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP
|
1 /*
2 * Copyright (c) 2016, 2019, Red Hat, Inc. All rights reserved.
3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP
28
29 #include "memory/allocation.hpp"
30 #include "logging/logFileStreamOutput.hpp"
31
32 /**
33 * This provides the following in JVMStat:
34 *
35 * constants:
36 * - sun.gc.shenandoah.regions.timestamp the timestamp for this sample
37 * - sun.gc.shenandoah.regions.max_regions maximum number of regions
38 * - sun.gc.shenandoah.regions.region_size size per region, in kilobytes
39 *
40 * variables:
41 * - sun.gc.shenandoah.regions.status current GC status:
42 * | global | old | young | mode |
43 * | 0..1 | 2..3 | 4..5 | 6..7 |
44 *
45 * For each generation:
46 * 0 = idle, 1 = marking, 2 = evacuating, 3 = updating refs
47 *
48 * For mode:
49 * 0 = concurrent, 1 = degenerated, 2 = full
50 *
51 * two variable counters per region, with $max_regions (see above) counters:
52 * - sun.gc.shenandoah.regions.region.$i.data
53 * where $ is the region number from 0 <= i < $max_regions
54 *
55 * .data is in the following format:
56 * - bits 0-6 used memory in percent
57 * - bits 7-13 live memory in percent
58 * - bits 14-20 tlab allocated memory in percent
59 * - bits 21-27 gclab allocated memory in percent
60 * - bits 28-34 shared allocated memory in percent
61 * - bits 35-41 plab allocated memory in percent
62 * - bits 42-50 <reserved>
63 * - bits 51-55 age
64 * - bits 56-57 affiliation: 0 = free, young = 1, old = 2
65 * - bits 58-63 status
66 * - bits describe the state as recorded in ShenandoahHeapRegion
67 */
68 class ShenandoahHeapRegionCounters : public CHeapObj<mtGC> {
69 private:
70 static const jlong PERCENT_MASK = 0x7f;
71 static const jlong AGE_MASK = 0x1f;
72 static const jlong AFFILIATION_MASK = 0x03;
73 static const jlong STATUS_MASK = 0x3f;
74
75 static const jlong USED_SHIFT = 0;
76 static const jlong LIVE_SHIFT = 7;
77 static const jlong TLAB_SHIFT = 14;
78 static const jlong GCLAB_SHIFT = 21;
79 static const jlong SHARED_SHIFT = 28;
80 static const jlong PLAB_SHIFT = 35;
81 static const jlong AGE_SHIFT = 51;
82 static const jlong AFFILIATION_SHIFT = 56;
83 static const jlong STATUS_SHIFT = 58;
84
85 static const jlong VERSION_NUMBER = 2;
86
87 char* _name_space;
88 PerfLongVariable** _regions_data;
89 PerfLongVariable* _timestamp;
90 PerfLongVariable* _status;
91 volatile jlong _last_sample_millis;
92
93 void write_snapshot(PerfLongVariable** regions,
94 PerfLongVariable* ts,
95 PerfLongVariable* status,
96 size_t num_regions,
97 size_t region_size, size_t protocolVersion);
98
99 public:
100 ShenandoahHeapRegionCounters();
101 ~ShenandoahHeapRegionCounters();
102 void update();
103
104 private:
105 static jlong encode_heap_status(ShenandoahHeap* heap) ;
106 };
107
108 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGIONCOUNTERS_HPP
|