src/java.base/share/classes/sun/launcher/LauncherHelper.java
changeset 50545 292a4a87c321
parent 48251 57148c79bd75
child 50546 52b866a1a63a
--- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Tue Jun 12 18:44:01 2018 -0400
+++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Tue Jun 12 18:51:45 2018 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, 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
@@ -91,6 +91,9 @@
 import jdk.internal.misc.VM;
 import jdk.internal.module.ModuleBootstrap;
 import jdk.internal.module.Modules;
+import jdk.internal.platform.Container;
+import jdk.internal.platform.Metrics;
+
 
 public final class LauncherHelper {
 
@@ -151,6 +154,7 @@
      *    this code determine this value, using a suitable method or omit the
      *    line entirely.
      */
+    @SuppressWarnings("fallthrough")
     static void showSettings(boolean printToStderr, String optionFlag,
             long initialHeapSize, long maxHeapSize, long stackSize) {
 
@@ -169,10 +173,18 @@
             case "locale":
                 printLocale();
                 break;
+            case "system":
+                if (System.getProperty("os.name").contains("Linux")) {
+                    printSystemMetrics();
+                    break;
+                }
             default:
                 printVmSettings(initialHeapSize, maxHeapSize, stackSize);
                 printProperties();
                 printLocale();
+                if (System.getProperty("os.name").contains("Linux")) {
+                    printSystemMetrics();
+                }
                 break;
         }
     }
@@ -307,6 +319,101 @@
         }
     }
 
+    public static void printSystemMetrics() {
+        Metrics c = Container.metrics();
+
+        ostream.println("Operating System Metrics:");
+
+        if (c == null) {
+            ostream.println(INDENT + "No metrics available for this platform");
+            return;
+        }
+
+        ostream.println(INDENT + "Provider: " + c.getProvider());
+        ostream.println(INDENT + "Effective CPU Count: " + c.getEffectiveCpuCount());
+        ostream.println(INDENT + "CPU Period: " + c.getCpuPeriod() +
+               (c.getCpuPeriod() == -1 ? "" : "us"));
+        ostream.println(INDENT + "CPU Quota: " + c.getCpuQuota() +
+               (c.getCpuQuota() == -1 ? "" : "us"));
+        ostream.println(INDENT + "CPU Shares: " + c.getCpuShares());
+
+        int cpus[] = c.getCpuSetCpus();
+        ostream.println(INDENT + "List of Processors, "
+                + cpus.length + " total: ");
+
+        ostream.print(INDENT);
+        for (int i = 0; i < cpus.length; i++) {
+            ostream.print(cpus[i] + " ");
+        }
+        if (cpus.length > 0) {
+            ostream.println("");
+        }
+
+        cpus = c.getEffectiveCpuSetCpus();
+        ostream.println(INDENT + "List of Effective Processors, "
+                + cpus.length + " total: ");
+
+        ostream.print(INDENT);
+        for (int i = 0; i < cpus.length; i++) {
+            ostream.print(cpus[i] + " ");
+        }
+        if (cpus.length > 0) {
+            ostream.println("");
+        }
+
+        int mems[] = c.getCpuSetMems();
+        ostream.println(INDENT + "List of Memory Nodes, "
+                + mems.length + " total: ");
+
+        ostream.print(INDENT);
+        for (int i = 0; i < mems.length; i++) {
+            ostream.print(mems[i] + " ");
+        }
+        if (mems.length > 0) {
+            ostream.println("");
+        }
+
+        mems = c.getEffectiveCpuSetMems();
+        ostream.println(INDENT + "List of Available Memory Nodes, "
+                + mems.length + " total: ");
+
+        ostream.print(INDENT);
+        for (int i = 0; i < mems.length; i++) {
+            ostream.print(mems[i] + " ");
+        }
+        if (mems.length > 0) {
+            ostream.println("");
+        }
+
+        ostream.println(INDENT + "CPUSet Memory Pressure Enabled: "
+                + c.isCpuSetMemoryPressureEnabled());
+
+        long limit = c.getMemoryLimit();
+        ostream.println(INDENT + "Memory Limit: " +
+                ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited"));
+
+        limit = c.getMemorySoftLimit();
+        ostream.println(INDENT + "Memory Soft Limit: " +
+                ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited"));
+
+        limit = c.getMemoryAndSwapLimit();
+        ostream.println(INDENT + "Memory & Swap Limit: " +
+                ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited"));
+
+        limit = c.getKernelMemoryLimit();
+        ostream.println(INDENT + "Kernel Memory Limit: " +
+                ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited"));
+
+        limit = c.getTcpMemoryLimit();
+        ostream.println(INDENT + "TCP Memory Limit: " +
+                ((limit >= 0) ? SizePrefix.scaleValue(limit) : "Unlimited"));
+
+        ostream.println(INDENT + "Out Of Memory Killer Enabled: "
+                + c.isMemoryOOMKillEnabled());
+
+        ostream.println("");
+    }
+
     private enum SizePrefix {
 
         KILO(1024, "K"),