changeset 54994:30c8a21ce002

8224119: Safepoint cleanup logging logs times for things it doesn't do Summary: test condition before reporting times for cleanup actions. Reviewed-by: rehn, hseigel
author coleenp
date Tue, 21 May 2019 09:53:16 -0400
parents e46fe26d7f77
children 1b28206dcbcb
files src/hotspot/share/classfile/classLoaderDataGraph.cpp src/hotspot/share/classfile/classLoaderDataGraph.hpp src/hotspot/share/runtime/safepoint.cpp test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java
diffstat 4 files changed, 29 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Tue May 21 15:51:35 2019 +0200
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Tue May 21 09:53:16 2019 -0400
@@ -596,14 +596,13 @@
   DependencyContext::purge_dependency_contexts();
 }
 
-int ClassLoaderDataGraph::resize_if_needed() {
+int ClassLoaderDataGraph::resize_dictionaries() {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
   int resized = 0;
-  if (Dictionary::does_any_dictionary_needs_resizing()) {
-    FOR_ALL_DICTIONARY(cld) {
-      if (cld->dictionary()->resize_if_needed()) {
-        resized++;
-      }
+  assert (Dictionary::does_any_dictionary_needs_resizing(), "some dictionary should need resizing");
+  FOR_ALL_DICTIONARY(cld) {
+    if (cld->dictionary()->resize_if_needed()) {
+      resized++;
     }
   }
   return resized;
--- a/src/hotspot/share/classfile/classLoaderDataGraph.hpp	Tue May 21 15:51:35 2019 +0200
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.hpp	Tue May 21 09:53:16 2019 -0400
@@ -119,16 +119,14 @@
   static GrowableArray<ClassLoaderData*>* new_clds();
 
   static void set_should_purge(bool b) { _should_purge = b; }
-  static void purge_if_needed() {
-    // Only purge the CLDG for CMS if concurrent sweep is complete.
-    if (_should_purge) {
-      purge();
-      // reset for next time.
-      set_should_purge(false);
-    }
+  static bool should_purge_and_reset() {
+    bool res = _should_purge;
+    // reset for next time.
+    set_should_purge(false);
+    return res;
   }
 
-  static int resize_if_needed();
+  static int resize_dictionaries();
 
   static bool has_metaspace_oom()           { return _metaspace_oom; }
   static void set_metaspace_oom(bool value) { _metaspace_oom = value; }
--- a/src/hotspot/share/runtime/safepoint.cpp	Tue May 21 15:51:35 2019 +0200
+++ b/src/hotspot/share/runtime/safepoint.cpp	Tue May 21 09:53:16 2019 -0400
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoaderDataGraph.inline.hpp"
+#include "classfile/dictionary.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
@@ -610,23 +611,27 @@
     }
 
     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_CLD_PURGE)) {
-      // CMS delays purging the CLDG until the beginning of the next safepoint and to
-      // make sure concurrent sweep is done
-      const char* name = "purging class loader data graph";
-      EventSafepointCleanupTask event;
-      TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
-      ClassLoaderDataGraph::purge_if_needed();
+      if (ClassLoaderDataGraph::should_purge_and_reset()) {
+        // CMS delays purging the CLDG until the beginning of the next safepoint and to
+        // make sure concurrent sweep is done
+        const char* name = "purging class loader data graph";
+        EventSafepointCleanupTask event;
+        TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
+        ClassLoaderDataGraph::purge();
 
-      post_safepoint_cleanup_task_event(event, safepoint_id, name);
+        post_safepoint_cleanup_task_event(event, safepoint_id, name);
+      }
     }
 
     if (_subtasks.try_claim_task(SafepointSynchronize::SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE)) {
-      const char* name = "resizing system dictionaries";
-      EventSafepointCleanupTask event;
-      TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
-      ClassLoaderDataGraph::resize_if_needed();
+      if (Dictionary::does_any_dictionary_needs_resizing()) {
+        const char* name = "resizing system dictionaries";
+        EventSafepointCleanupTask event;
+        TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup));
+        ClassLoaderDataGraph::resize_dictionaries();
 
-      post_safepoint_cleanup_task_event(event, safepoint_id, name);
+        post_safepoint_cleanup_task_event(event, safepoint_id, name);
+      }
     }
 
     _subtasks.all_tasks_completed(_num_workers);
--- a/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java	Tue May 21 15:51:35 2019 +0200
+++ b/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java	Tue May 21 09:53:16 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -43,7 +43,6 @@
         output.shouldContain("deflating per-thread idle monitors");
         output.shouldContain("updating inline caches");
         output.shouldContain("compilation policy safepoint handler");
-        output.shouldContain("purging class loader data graph");
         output.shouldHaveExitValue(0);
     }