-
Bug
-
Resolution: Fixed
-
P3
-
9, 10, 11, 12, 13, 14, 15
-
b11
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8240817 | 14.0.2 | Rahul Raghavan | P3 | Resolved | Fixed | b01 |
JDK-8246700 | 13.0.4 | Rahul Raghavan | P3 | Resolved | Fixed | b04 |
JDK-8240066 | 11.0.8-oracle | Rahul Raghavan | P3 | Resolved | Fixed | b01 |
JDK-8240355 | 11.0.8 | Rahul Raghavan | P3 | Resolved | Fixed | b01 |
While working on JDK-8238247, I realized that CodeHeap::blob_count() miscalculates the blob count. If you look at the usages of CodeHeap::_blob_count field, it is only incremented, never decremented. Which is almost fine, but it leads to blob_count miscalculation: when block is freed and put on free list and re-acquired from the free list, it is counted as new blob all over again.
So, either way should be done:
a) Decrement _blob_count on addition to the free list, which would make CodeHeap::blob_count() report the number of alive blobs;
b) Stop incrementing blob_count on removal from the free list, which would make CodeHeap::blob_count() report the number of alive+free blobs.
Sample patch for option (a):
diff -r e4e6c1846d31 src/hotspot/share/memory/heap.cpp
--- a/src/hotspot/share/memory/heap.cpp Fri Jan 31 19:00:14 2020 +0100
+++ b/src/hotspot/share/memory/heap.cpp Fri Jan 31 19:00:17 2020 +0100
@@ -609,10 +609,13 @@
void CodeHeap::add_to_freelist(HeapBlock* a) {
FreeBlock* b = (FreeBlock*)a;
size_t bseg = segment_for(b);
_freelist_length++;
+ _blob_count--;
+ assert(_blob_count >= 0, "sanity");
+
assert(b != _freelist, "cannot be removed twice");
// Mark as free and update free space count
_freelist_segments += b->length();
b->set_free();
So, either way should be done:
a) Decrement _blob_count on addition to the free list, which would make CodeHeap::blob_count() report the number of alive blobs;
b) Stop incrementing blob_count on removal from the free list, which would make CodeHeap::blob_count() report the number of alive+free blobs.
Sample patch for option (a):
diff -r e4e6c1846d31 src/hotspot/share/memory/heap.cpp
--- a/src/hotspot/share/memory/heap.cpp Fri Jan 31 19:00:14 2020 +0100
+++ b/src/hotspot/share/memory/heap.cpp Fri Jan 31 19:00:17 2020 +0100
@@ -609,10 +609,13 @@
void CodeHeap::add_to_freelist(HeapBlock* a) {
FreeBlock* b = (FreeBlock*)a;
size_t bseg = segment_for(b);
_freelist_length++;
+ _blob_count--;
+ assert(_blob_count >= 0, "sanity");
+
assert(b != _freelist, "cannot be removed twice");
// Mark as free and update free space count
_freelist_segments += b->length();
b->set_free();
- backported by
-
JDK-8240066 CodeHeap::blob_count() overestimates the number of blobs
- Resolved
-
JDK-8240355 CodeHeap::blob_count() overestimates the number of blobs
- Resolved
-
JDK-8240817 CodeHeap::blob_count() overestimates the number of blobs
- Resolved
-
JDK-8246700 CodeHeap::blob_count() overestimates the number of blobs
- Resolved