From 137b926721608c7a6ffaee581c78efd2a7cae47f Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Tue, 23 Mar 2021 11:48:12 +0800 Subject: [PATCH 1/3] 8264008: Incorrect metaspace statistics after JEP 387 when UseCompressedClassPointers is off --- src/hotspot/share/memory/metaspace.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index 965b395ac983f..d5b46a6dc749b 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.cpp @@ -71,7 +71,7 @@ size_t MetaspaceUtils::used_words() { } size_t MetaspaceUtils::used_words(Metaspace::MetadataType mdtype) { - return Metaspace::is_class_space_allocation(mdtype) ? RunningCounters::used_words_class() : RunningCounters::used_words_nonclass(); + return mdtype == Metaspace::ClassType ? RunningCounters::used_words_class() : RunningCounters::used_words_nonclass(); } size_t MetaspaceUtils::reserved_words() { @@ -79,7 +79,7 @@ size_t MetaspaceUtils::reserved_words() { } size_t MetaspaceUtils::reserved_words(Metaspace::MetadataType mdtype) { - return Metaspace::is_class_space_allocation(mdtype) ? RunningCounters::reserved_words_class() : RunningCounters::reserved_words_nonclass(); + return mdtype == Metaspace::ClassType ? RunningCounters::reserved_words_class() : RunningCounters::reserved_words_nonclass(); } size_t MetaspaceUtils::committed_words() { @@ -87,7 +87,7 @@ size_t MetaspaceUtils::committed_words() { } size_t MetaspaceUtils::committed_words(Metaspace::MetadataType mdtype) { - return Metaspace::is_class_space_allocation(mdtype) ? RunningCounters::committed_words_class() : RunningCounters::committed_words_nonclass(); + return mdtype == Metaspace::ClassType ? RunningCounters::committed_words_class() : RunningCounters::committed_words_nonclass(); } void MetaspaceUtils::print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values) { From c72e91ec06762b614b12e97bf551e0c9c3af417d Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Tue, 23 Mar 2021 15:44:44 +0800 Subject: [PATCH 2/3] Add a test run to reproduce the bug --- .../TestHeapSummaryEventDefNewSerial.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java index 53d736e2045fc..547fe364b7ea1 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,17 @@ * @library /test/lib /test/jdk * @run main/othervm -XX:+UseSerialGC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial */ + +/** + * @test + * @bug 8264008 + * @key jfr + * @requires vm.hasJFR + * @requires vm.gc == "Serial" | vm.gc == null + * @library /test/lib /test/jdk + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseSerialGC -XX:-UseCompressedClassPointers + * jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial + */ public class TestHeapSummaryEventDefNewSerial { public static void main(String[] args) throws Exception { HeapSummaryEventAllGcs.test(GCHelper.gcDefNew, GCHelper.gcSerialOld); From 10c9ab14aef972333bc606a7f075420f80206a75 Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Wed, 24 Mar 2021 07:23:24 +0800 Subject: [PATCH 3/3] Exclude 32-bit vm --- .../gc/heapsummary/TestHeapSummaryEventDefNewSerial.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java index 547fe364b7ea1..348b024674326 100644 --- a/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java +++ b/test/jdk/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java @@ -39,10 +39,10 @@ * @test * @bug 8264008 * @key jfr - * @requires vm.hasJFR + * @requires vm.hasJFR & vm.bits == 64 * @requires vm.gc == "Serial" | vm.gc == null * @library /test/lib /test/jdk - * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseSerialGC -XX:-UseCompressedClassPointers + * @run main/othervm -XX:+UseSerialGC -XX:-UseCompressedClassPointers * jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial */ public class TestHeapSummaryEventDefNewSerial {