/hg/icedtea8-forest/hotspot: 5 new changesets

andrew at icedtea.classpath.org andrew at icedtea.classpath.org
Thu Jul 12 04:28:54 UTC 2018


changeset 533473c67de6 in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=533473c67de6
author: thartmann
date: Fri Jun 20 08:14:30 2014 +0200

	8008321, PR3599: compile.cpp verify_graph_edges uses bool as int
	Summary: The dead_nodes counter in verify_graph_edges(..) has the type bool but is used as int.
	Reviewed-by: roland, anoll


changeset 30520d5018b5 in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=30520d5018b5
author: goetz
date: Thu Nov 13 11:14:01 2014 +0100

	8064786, PR3601: Fix debug build after 8062808: Turn on the -Wreturn-type warning
	Reviewed-by: stefank, tschatzl


changeset f6341f4635da in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=f6341f4635da
author: andrew
date: Wed Jun 20 07:10:43 2018 +0100

	PR3601: Fix additional -Wreturn-type issues introduced by 8061651


changeset 95b72537801c in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=95b72537801c
author: aph
date: Mon Jul 09 15:35:45 2018 +0100

	8206406, PR3610, RH1597825: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
	Reviewed-by: dholmes


changeset 2f2d2af6fa5c in /hg/icedtea8-forest/hotspot
details: http://icedtea.classpath.org/hg/icedtea8-forest/hotspot?cmd=changeset;node=2f2d2af6fa5c
author: poonam
date: Fri Jul 06 18:50:13 2018 +0000

	8146115, PR3508, RH1463098: Improve docker container detection and resource configuration usage
	Reviewed-by: bobv, dbuck


diffstat:

 src/os/aix/vm/os_aix.cpp                   |   10 +
 src/os/bsd/vm/os_bsd.cpp                   |   10 +
 src/os/linux/vm/globals_linux.hpp          |   11 +-
 src/os/linux/vm/osContainer_linux.cpp      |  680 +++++++++++++++++++++++++++++
 src/os/linux/vm/osContainer_linux.hpp      |   68 ++
 src/os/linux/vm/os_linux.cpp               |  155 ++++++-
 src/os/linux/vm/os_linux.hpp               |    5 +
 src/os/solaris/vm/os_solaris.cpp           |   10 +
 src/os/windows/vm/os_windows.cpp           |   10 +
 src/share/vm/opto/compile.cpp              |    8 +-
 src/share/vm/prims/jni.cpp                 |    2 +
 src/share/vm/prims/jvm.cpp                 |    6 +-
 src/share/vm/runtime/arguments.cpp         |  219 +++++----
 src/share/vm/runtime/arguments.hpp         |    4 +-
 src/share/vm/runtime/globals.hpp           |   27 +-
 src/share/vm/runtime/os.hpp                |    8 +
 src/share/vm/runtime/stubCodeGenerator.cpp |    8 +-
 src/share/vm/runtime/stubCodeGenerator.hpp |    6 +-
 src/share/vm/runtime/thread.cpp            |    1 +
 19 files changed, 1130 insertions(+), 118 deletions(-)

diffs (truncated from 1619 to 500 lines):

diff -r 8cde8f606e3f -r 2f2d2af6fa5c src/os/aix/vm/os_aix.cpp
--- a/src/os/aix/vm/os_aix.cpp	Wed May 30 07:19:21 2018 +0100
+++ b/src/os/aix/vm/os_aix.cpp	Fri Jul 06 18:50:13 2018 +0000
@@ -4008,6 +4008,16 @@
 };
 
 int os::active_processor_count() {
+  // User has overridden the number of active processors
+  if (ActiveProcessorCount > 0) {
+    if (PrintActiveCpus) {
+      tty->print_cr("active_processor_count: "
+                    "active processor count set by user : %d",
+                     ActiveProcessorCount);
+    }
+    return ActiveProcessorCount;
+  }
+
   int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
   assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
   return online_cpus;
diff -r 8cde8f606e3f -r 2f2d2af6fa5c src/os/bsd/vm/os_bsd.cpp
--- a/src/os/bsd/vm/os_bsd.cpp	Wed May 30 07:19:21 2018 +0100
+++ b/src/os/bsd/vm/os_bsd.cpp	Fri Jul 06 18:50:13 2018 +0000
@@ -3770,6 +3770,16 @@
 };
 
 int os::active_processor_count() {
+  // User has overridden the number of active processors
+  if (ActiveProcessorCount > 0) {
+    if (PrintActiveCpus) {
+      tty->print_cr("active_processor_count: "
+                    "active processor count set by user : %d",
+                     ActiveProcessorCount);
+    }
+    return ActiveProcessorCount;
+  }
+
   return _processor_count;
 }
 
diff -r 8cde8f606e3f -r 2f2d2af6fa5c src/os/linux/vm/globals_linux.hpp
--- a/src/os/linux/vm/globals_linux.hpp	Wed May 30 07:19:21 2018 +0100
+++ b/src/os/linux/vm/globals_linux.hpp	Fri Jul 06 18:50:13 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -49,8 +49,13 @@
   product(bool, UseSHM, false,                                          \
           "Use SYSV shared memory for large pages")                     \
                                                                         \
-  diagnostic(bool, PrintActiveCpus, false,                              \
-          "Print the number of CPUs detected in os::active_processor_count")
+  product(bool, UseContainerSupport, true,                              \
+          "Enable detection and runtime container configuration support") \
+                                                                        \
+  product(bool, PreferContainerQuotaForCPUCount, true,                  \
+          "Calculate the container CPU availability based on the value" \
+          " of quotas (if set), when true. Otherwise, use the CPU"      \
+          " shares value, provided it is less than quota.")
 
 //
 // Defines Linux-specific default values. The flags are available on all
diff -r 8cde8f606e3f -r 2f2d2af6fa5c src/os/linux/vm/osContainer_linux.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/os/linux/vm/osContainer_linux.cpp	Fri Jul 06 18:50:13 2018 +0000
@@ -0,0 +1,680 @@
+/*
+ * Copyright (c) 2017, 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
+ * 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.
+ *
+ */
+
+#include <string.h>
+#include <math.h>
+#include <errno.h>
+#include "utilities/globalDefinitions.hpp"
+#include "memory/allocation.hpp"
+#include "runtime/os.hpp"
+#include "osContainer_linux.hpp"
+
+#define PER_CPU_SHARES 1024
+
+bool  OSContainer::_is_initialized   = false;
+bool  OSContainer::_is_containerized = false;
+julong _unlimited_memory;
+
+class CgroupSubsystem: CHeapObj<mtInternal> {
+ friend class OSContainer;
+
+ private:
+    /* mountinfo contents */
+    char *_root;
+    char *_mount_point;
+
+    /* Constructed subsystem directory */
+    char *_path;
+
+ public:
+    CgroupSubsystem(char *root, char *mountpoint) {
+      _root = os::strdup(root);
+      _mount_point = os::strdup(mountpoint);
+      _path = NULL;
+    }
+
+    /*
+     * Set directory to subsystem specific files based
+     * on the contents of the mountinfo and cgroup files.
+     */
+    void set_subsystem_path(char *cgroup_path) {
+      char buf[MAXPATHLEN+1];
+      if (_root != NULL && cgroup_path != NULL) {
+        if (strcmp(_root, "/") == 0) {
+          int buflen;
+          strncpy(buf, _mount_point, MAXPATHLEN);
+          buf[MAXPATHLEN-1] = '\0';
+          if (strcmp(cgroup_path,"/") != 0) {
+            buflen = strlen(buf);
+            if ((buflen + strlen(cgroup_path)) > (MAXPATHLEN-1)) {
+              return;
+            }
+            strncat(buf, cgroup_path, MAXPATHLEN-buflen);
+            buf[MAXPATHLEN-1] = '\0';
+          }
+          _path = os::strdup(buf);
+        } else {
+          if (strcmp(_root, cgroup_path) == 0) {
+            strncpy(buf, _mount_point, MAXPATHLEN);
+            buf[MAXPATHLEN-1] = '\0';
+            _path = os::strdup(buf);
+          } else {
+            char *p = strstr(_root, cgroup_path);
+            if (p != NULL && p == _root) {
+              if (strlen(cgroup_path) > strlen(_root)) {
+                int buflen;
+                strncpy(buf, _mount_point, MAXPATHLEN);
+                buf[MAXPATHLEN-1] = '\0';
+                buflen = strlen(buf);
+                if ((buflen + strlen(cgroup_path)) > (MAXPATHLEN-1)) {
+                  return;
+                }
+                strncat(buf, cgroup_path + strlen(_root), MAXPATHLEN-buflen);
+                buf[MAXPATHLEN-1] = '\0';
+                _path = os::strdup(buf);
+              }
+            }
+          }
+        }
+      }
+    }
+
+    char *subsystem_path() { return _path; }
+};
+
+CgroupSubsystem* memory = NULL;
+CgroupSubsystem* cpuset = NULL;
+CgroupSubsystem* cpu = NULL;
+CgroupSubsystem* cpuacct = NULL;
+
+typedef char * cptr;
+
+PRAGMA_DIAG_PUSH
+PRAGMA_FORMAT_NONLITERAL_IGNORED
+template <typename T> int subsystem_file_contents(CgroupSubsystem* c,
+                                              const char *filename,
+                                              const char *scan_fmt,
+                                              T returnval) {
+  FILE *fp = NULL;
+  char *p;
+  char file[MAXPATHLEN+1];
+  char buf[MAXPATHLEN+1];
+
+  if (c == NULL) {
+    if (PrintContainerInfo) {
+      tty->print_cr("subsystem_file_contents: CgroupSubsytem* is NULL");
+    }
+    return OSCONTAINER_ERROR;
+  }
+  if (c->subsystem_path() == NULL) {
+    if (PrintContainerInfo) {
+      tty->print_cr("subsystem_file_contents: subsystem path is NULL");
+    }
+    return OSCONTAINER_ERROR;
+  }
+
+  strncpy(file, c->subsystem_path(), MAXPATHLEN);
+  file[MAXPATHLEN-1] = '\0';
+  int filelen = strlen(file);
+  if ((filelen + strlen(filename)) > (MAXPATHLEN-1)) {
+    if (PrintContainerInfo) {
+      tty->print_cr("File path too long %s, %s", file, filename);
+    }
+    return OSCONTAINER_ERROR;
+  }
+  strncat(file, filename, MAXPATHLEN-filelen);
+  if (PrintContainerInfo) {
+    tty->print_cr("Path to %s is %s", filename, file);
+  }
+  fp = fopen(file, "r");
+  if (fp != NULL) {
+    p = fgets(buf, MAXPATHLEN, fp);
+    if (p != NULL) {
+      int matched = sscanf(p, scan_fmt, returnval);
+      if (matched == 1) {
+        fclose(fp);
+        return 0;
+      } else {
+        if (PrintContainerInfo) {
+          tty->print_cr("Type %s not found in file %s", scan_fmt, file);
+        }
+      }
+    } else {
+      if (PrintContainerInfo) {
+        tty->print_cr("Empty file %s", file);
+      }
+    }
+  } else {
+    if (PrintContainerInfo) {
+      tty->print_cr("Open of file %s failed, %s", file, strerror(errno));
+    }
+  }
+  if (fp != NULL)
+    fclose(fp);
+  return OSCONTAINER_ERROR;
+}
+PRAGMA_DIAG_POP
+
+#define GET_CONTAINER_INFO(return_type, subsystem, filename,              \
+                           logstring, scan_fmt, variable)                 \
+  return_type variable;                                                   \
+{                                                                         \
+  int err;                                                                \
+  err = subsystem_file_contents(subsystem,                                \
+                                filename,                                 \
+                                scan_fmt,                                 \
+                                &variable);                               \
+  if (err != 0)                                                           \
+    return (return_type) OSCONTAINER_ERROR;                               \
+                                                                          \
+  if (PrintContainerInfo)                                                 \
+    tty->print_cr(logstring, variable);                                   \
+}
+
+#define GET_CONTAINER_INFO_CPTR(return_type, subsystem, filename,         \
+                               logstring, scan_fmt, variable, bufsize)    \
+  char variable[bufsize];                                                 \
+{                                                                         \
+  int err;                                                                \
+  err = subsystem_file_contents(subsystem,                                \
+                                filename,                                 \
+                                scan_fmt,                                 \
+                                variable);                                \
+  if (err != 0)                                                           \
+    return (return_type) NULL;                                            \
+                                                                          \
+  if (PrintContainerInfo)                                                 \
+    tty->print_cr(logstring, variable);                                   \
+}
+
+/* init
+ *
+ * Initialize the container support and determine if
+ * we are running under cgroup control.
+ */
+void OSContainer::init() {
+  int mountid;
+  int parentid;
+  int major;
+  int minor;
+  FILE *mntinfo = NULL;
+  FILE *cgroup = NULL;
+  char buf[MAXPATHLEN+1];
+  char tmproot[MAXPATHLEN+1];
+  char tmpmount[MAXPATHLEN+1];
+  char tmpbase[MAXPATHLEN+1];
+  char *p;
+  jlong mem_limit;
+
+  assert(!_is_initialized, "Initializing OSContainer more than once");
+
+  _is_initialized = true;
+  _is_containerized = false;
+
+  _unlimited_memory = (LONG_MAX / os::vm_page_size()) * os::vm_page_size();
+
+  if (PrintContainerInfo) {
+    tty->print_cr("OSContainer::init: Initializing Container Support");
+  }
+  if (!UseContainerSupport) {
+    if (PrintContainerInfo) {
+      tty->print_cr("Container Support not enabled");
+    }
+    return;
+  }
+
+  /*
+   * Find the cgroup mount point for memory and cpuset
+   * by reading /proc/self/mountinfo
+   *
+   * Example for docker:
+   * 219 214 0:29 /docker/7208cebd00fa5f2e342b1094f7bed87fa25661471a4637118e65f1c995be8a34 /sys/fs/cgroup/memory ro,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory
+   *
+   * Example for host:
+   * 34 28 0:29 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,memory
+   */
+  mntinfo = fopen("/proc/self/mountinfo", "r");
+  if (mntinfo == NULL) {
+      if (PrintContainerInfo) {
+        tty->print_cr("Can't open /proc/self/mountinfo, %s",
+                       strerror(errno));
+      }
+      return;
+  }
+
+  while ( (p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
+    // Look for the filesystem type and see if it's cgroup
+    char fstype[MAXPATHLEN+1];
+    fstype[0] = '\0';
+    char *s =  strstr(p, " - ");
+    if (s != NULL &&
+        sscanf(s, " - %s", fstype) == 1 &&
+        strcmp(fstype, "cgroup") == 0) {
+
+      if (strstr(p, "memory") != NULL) {
+        int matched = sscanf(p, "%d %d %d:%d %s %s",
+                             &mountid,
+                             &parentid,
+                             &major,
+                             &minor,
+                             tmproot,
+                             tmpmount);
+        if (matched == 6) {
+          memory = new CgroupSubsystem(tmproot, tmpmount);
+        }
+        else
+          if (PrintContainerInfo) {
+            tty->print_cr("Incompatible str containing cgroup and memory: %s", p);
+          }
+      } else if (strstr(p, "cpuset") != NULL) {
+        int matched = sscanf(p, "%d %d %d:%d %s %s",
+                             &mountid,
+                             &parentid,
+                             &major,
+                             &minor,
+                             tmproot,
+                             tmpmount);
+        if (matched == 6) {
+          cpuset = new CgroupSubsystem(tmproot, tmpmount);
+        }
+        else {
+          if (PrintContainerInfo) {
+            tty->print_cr("Incompatible str containing cgroup and cpuset: %s", p);
+          }
+        }
+      } else if (strstr(p, "cpu,cpuacct") != NULL || strstr(p, "cpuacct,cpu") != NULL) {
+        int matched = sscanf(p, "%d %d %d:%d %s %s",
+                             &mountid,
+                             &parentid,
+                             &major,
+                             &minor,
+                             tmproot,
+                             tmpmount);
+        if (matched == 6) {
+          cpu = new CgroupSubsystem(tmproot, tmpmount);
+          cpuacct = new CgroupSubsystem(tmproot, tmpmount);
+        }
+        else {
+          if (PrintContainerInfo) {
+            tty->print_cr("Incompatible str containing cgroup and cpu,cpuacct: %s", p);
+          }
+        }
+      } else if (strstr(p, "cpuacct") != NULL) {
+        int matched = sscanf(p, "%d %d %d:%d %s %s",
+                             &mountid,
+                             &parentid,
+                             &major,
+                             &minor,
+                             tmproot,
+                             tmpmount);
+        if (matched == 6) {
+          cpuacct = new CgroupSubsystem(tmproot, tmpmount);
+        }
+        else {
+          if (PrintContainerInfo) {
+            tty->print_cr("Incompatible str containing cgroup and cpuacct: %s", p);
+          }
+        }
+      } else if (strstr(p, "cpu") != NULL) {
+        int matched = sscanf(p, "%d %d %d:%d %s %s",
+                             &mountid,
+                             &parentid,
+                             &major,
+                             &minor,
+                             tmproot,
+                             tmpmount);
+        if (matched == 6) {
+          cpu = new CgroupSubsystem(tmproot, tmpmount);
+        }
+        else {
+          if (PrintContainerInfo) {
+            tty->print_cr("Incompatible str containing cgroup and cpu: %s", p);
+          }
+        }
+      }
+    }
+  }
+
+  fclose(mntinfo);
+
+  if (memory == NULL) {
+    if (PrintContainerInfo) {
+      tty->print_cr("Required cgroup memory subsystem not found");
+    }
+    return;
+  }
+  if (cpuset == NULL) {
+    if (PrintContainerInfo) {
+      tty->print_cr("Required cgroup cpuset subsystem not found");
+    }
+    return;
+  }
+  if (cpu == NULL) {
+    if (PrintContainerInfo) {
+      tty->print_cr("Required cgroup cpu subsystem not found");
+    }
+    return;
+  }
+  if (cpuacct == NULL) {
+    if (PrintContainerInfo) {
+      tty->print_cr("Required cgroup cpuacct subsystem not found");
+    }
+    return;
+  }
+
+  /*
+   * Read /proc/self/cgroup and map host mount point to
+   * local one via /proc/self/mountinfo content above
+   *
+   * Docker example:
+   * 5:memory:/docker/6558aed8fc662b194323ceab5b964f69cf36b3e8af877a14b80256e93aecb044
+   *
+   * Host example:
+   * 5:memory:/user.slice
+   *
+   * Construct a path to the process specific memory and cpuset
+   * cgroup directory.
+   *
+   * For a container running under Docker from memory example above
+   * the paths would be:
+   *
+   * /sys/fs/cgroup/memory
+   *
+   * For a Host from memory example above the path would be:
+   *
+   * /sys/fs/cgroup/memory/user.slice
+   *
+   */
+  cgroup = fopen("/proc/self/cgroup", "r");
+  if (cgroup == NULL) {
+    if (PrintContainerInfo) {
+      tty->print_cr("Can't open /proc/self/cgroup, %s",
+                     strerror(errno));
+      }
+    return;
+  }
+
+  while ( (p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
+    int cgno;
+    int matched;
+    char *controller;
+    char *base;
+
+    /* Skip cgroup number */
+    strsep(&p, ":");
+    /* Get controller and base */
+    controller = strsep(&p, ":");
+    base = strsep(&p, "\n");
+
+    if (controller != NULL) {


More information about the distro-pkg-dev mailing list