8277946: NMT: Deprecate and remove VM.native_memory shutdown jcmd command option

Reviewed-by: stuefe, shade, dholmes
This commit is contained in:
Zhengyu Gu 2021-12-01 13:14:09 +00:00
parent 37ff7f3b66
commit abaa073bcb
5 changed files with 2 additions and 133 deletions

View File

@ -50,9 +50,6 @@ NMTDCmd::NMTDCmd(outputStream* output,
"comparison against previous baseline, which shows the memory " \
"allocation activities at different callsites.",
"BOOLEAN", false, "false"),
_shutdown("shutdown", "request runtime to shutdown itself and free the " \
"memory used by runtime.",
"BOOLEAN", false, "false"),
_statistics("statistics", "print tracker statistics for tuning purpose.", \
"BOOLEAN", false, "false"),
_scale("scale", "Memory usage in which scale, KB, MB or GB",
@ -62,7 +59,6 @@ NMTDCmd::NMTDCmd(outputStream* output,
_dcmdparser.add_dcmd_option(&_baseline);
_dcmdparser.add_dcmd_option(&_summary_diff);
_dcmdparser.add_dcmd_option(&_detail_diff);
_dcmdparser.add_dcmd_option(&_shutdown);
_dcmdparser.add_dcmd_option(&_statistics);
_dcmdparser.add_dcmd_option(&_scale);
}
@ -79,9 +75,6 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) {
if (MemTracker::tracking_level() == NMT_off) {
output()->print_cr("Native memory tracking is not enabled");
return;
} else if (MemTracker::tracking_level() == NMT_minimal) {
output()->print_cr("Native memory tracking has been shutdown");
return;
}
const char* scale_value = _scale.value();
@ -97,12 +90,11 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) {
if (_baseline.is_set() && _baseline.value()) { ++nopt; }
if (_summary_diff.is_set() && _summary_diff.value()) { ++nopt; }
if (_detail_diff.is_set() && _detail_diff.value()) { ++nopt; }
if (_shutdown.is_set() && _shutdown.value()) { ++nopt; }
if (_statistics.is_set() && _statistics.value()) { ++nopt; }
if (nopt > 1) {
output()->print_cr("At most one of the following option can be specified: " \
"summary, detail, metadata, baseline, summary.diff, detail.diff, shutdown");
"summary, detail, metadata, baseline, summary.diff, detail.diff");
return;
} else if (nopt == 0) {
if (_summary.is_set()) {
@ -147,9 +139,6 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) {
} else {
output()->print_cr("No detail baseline for comparison");
}
} else if (_shutdown.value()) {
MemTracker::shutdown();
output()->print_cr("Native memory tracking has been turned off");
} else if (_statistics.value()) {
if (check_detail_tracking_level(output())) {
MemTracker::tuning_statistics(output());

View File

@ -42,7 +42,6 @@ class NMTDCmd: public DCmdWithParser {
DCmdArgument<bool> _baseline;
DCmdArgument<bool> _summary_diff;
DCmdArgument<bool> _detail_diff;
DCmdArgument<bool> _shutdown;
DCmdArgument<bool> _statistics;
DCmdArgument<char*> _scale;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, 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
@ -69,7 +69,6 @@ public class JcmdWithNMTDisabled {
jcmdCommand("summary.diff");
jcmdCommand("detail.diff");
jcmdCommand("scale=GB");
jcmdCommand("shutdown");
}
// Helper method for invoking different jcmd calls, all should fail with the same message saying NMT is not enabled

View File

@ -1,59 +0,0 @@
/*
* Copyright (c) 2013, 2020, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @summary Run shutdown twice
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run main/othervm -XX:NativeMemoryTracking=detail ShutdownTwice
*/
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.JDKToolFinder;
public class ShutdownTwice {
public static void main(String args[]) throws Exception {
// Grab my own PID
String pid = Long.toString(ProcessTools.getProcessId());
OutputAnalyzer output;
ProcessBuilder pb = new ProcessBuilder();
// Run 'jcmd <pid> VM.native_memory shutdown'
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "shutdown"});
output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT is shutting down
output.shouldContain("Native memory tracking has been turned off");
// Run shutdown again
output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT has been shutdown already
output.shouldContain("Native memory tracking has been shutdown");
}
}

View File

@ -1,59 +0,0 @@
/*
* Copyright (c) 2013, 2020, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @summary Verify that jcmd correctly reports that NMT is not enabled after a shutdown
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run main/othervm -XX:NativeMemoryTracking=detail SummaryAfterShutdown
*/
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.JDKToolFinder;
public class SummaryAfterShutdown {
public static void main(String args[]) throws Exception {
OutputAnalyzer output;
// Grab my own PID
String pid = Long.toString(ProcessTools.getProcessId());
ProcessBuilder pb = new ProcessBuilder();
// Run 'jcmd <pid> VM.native_memory shutdown'
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "shutdown"});
output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT is shutting down
output.shouldContain("Native memory tracking has been turned off");
// Run 'jcmd <pid> VM.native_memory summary'
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
output = new OutputAnalyzer(pb.start());
// Verify that jcmd reports that NMT has been shutdown
output.shouldContain("Native memory tracking has been shutdown");
}
}