changeset 50048:c47b934e3d6f

ZGC: UPSTREAM: Disable NUMA if process is bound to a subset of CPUs
author duke
date Tue, 24 Apr 2018 08:27:59 +0200
parents d38ec67d4ebf
children 5b5dcfd2281e
files src/hotspot/os/linux/os_linux.cpp src/hotspot/os/linux/os_linux.hpp
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/os/linux/os_linux.cpp	Tue Apr 24 08:27:59 2018 +0200
+++ b/src/hotspot/os/linux/os_linux.cpp	Tue Apr 24 08:27:59 2018 +0200
@@ -2916,6 +2916,10 @@
                                        libnuma_dlsym(handle, "numa_max_node")));
       set_numa_num_configured_nodes(CAST_TO_FN_PTR(numa_num_configured_nodes_func_t,
                                                    libnuma_dlsym(handle, "numa_num_configured_nodes")));
+      set_numa_num_configured_cpus(CAST_TO_FN_PTR(numa_num_configured_cpus_func_t,
+                                                  libnuma_dlsym(handle, "numa_num_configured_cpus")));
+      set_numa_num_task_cpus(CAST_TO_FN_PTR(numa_num_task_cpus_func_t,
+                                            libnuma_dlsym(handle, "numa_num_task_cpus")));
       set_numa_available(CAST_TO_FN_PTR(numa_available_func_t,
                                         libnuma_dlsym(handle, "numa_available")));
       set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t,
@@ -3047,6 +3051,8 @@
 os::Linux::numa_node_to_cpus_func_t os::Linux::_numa_node_to_cpus;
 os::Linux::numa_max_node_func_t os::Linux::_numa_max_node;
 os::Linux::numa_num_configured_nodes_func_t os::Linux::_numa_num_configured_nodes;
+os::Linux::numa_num_configured_cpus_func_t os::Linux::_numa_num_configured_cpus;
+os::Linux::numa_num_task_cpus_func_t os::Linux::_numa_num_task_cpus;
 os::Linux::numa_available_func_t os::Linux::_numa_available;
 os::Linux::numa_tonode_memory_func_t os::Linux::_numa_tonode_memory;
 os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory;
@@ -4965,6 +4971,13 @@
       if ((Linux::numa_max_node() < 1)) {
         // There's only one node(they start from 0), disable NUMA.
         UseNUMA = false;
+      } else if (FLAG_IS_DEFAULT(UseNUMA) &&
+                 Linux::numa_num_configured_cpus() != Linux::numa_num_task_cpus()) {
+        // Unless explicitly enabled by the user, disable NUMA if this process is
+        // restricted to execute on a subset of the CPUs on the machine. Memory
+        // interleaving might otherwise not work well, since we might get memory
+        // from nodes we never execute on.
+        UseNUMA = false;
       }
     }
 
--- a/src/hotspot/os/linux/os_linux.hpp	Tue Apr 24 08:27:59 2018 +0200
+++ b/src/hotspot/os/linux/os_linux.hpp	Tue Apr 24 08:27:59 2018 +0200
@@ -224,6 +224,8 @@
   typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
   typedef int (*numa_max_node_func_t)(void);
   typedef int (*numa_num_configured_nodes_func_t)(void);
+  typedef int (*numa_num_configured_cpus_func_t)(void);
+  typedef int (*numa_num_task_cpus_func_t)(void);
   typedef int (*numa_available_func_t)(void);
   typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
   typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
@@ -237,6 +239,8 @@
   static numa_node_to_cpus_func_t _numa_node_to_cpus;
   static numa_max_node_func_t _numa_max_node;
   static numa_num_configured_nodes_func_t _numa_num_configured_nodes;
+  static numa_num_configured_cpus_func_t _numa_num_configured_cpus;
+  static numa_num_task_cpus_func_t _numa_num_task_cpus;
   static numa_available_func_t _numa_available;
   static numa_tonode_memory_func_t _numa_tonode_memory;
   static numa_interleave_memory_func_t _numa_interleave_memory;
@@ -252,6 +256,8 @@
   static void set_numa_node_to_cpus(numa_node_to_cpus_func_t func) { _numa_node_to_cpus = func; }
   static void set_numa_max_node(numa_max_node_func_t func) { _numa_max_node = func; }
   static void set_numa_num_configured_nodes(numa_num_configured_nodes_func_t func) { _numa_num_configured_nodes = func; }
+  static void set_numa_num_configured_cpus(numa_num_configured_cpus_func_t func) { _numa_num_configured_cpus = func; }
+  static void set_numa_num_task_cpus(numa_num_task_cpus_func_t func) { _numa_num_task_cpus = func; }
   static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
   static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
   static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
@@ -272,6 +278,12 @@
   static int numa_num_configured_nodes() {
     return _numa_num_configured_nodes != NULL ? _numa_num_configured_nodes() : -1;
   }
+  static int numa_num_configured_cpus() {
+    return _numa_num_configured_cpus != NULL ? _numa_num_configured_cpus() : -1;
+  }
+  static int numa_num_task_cpus() {
+    return _numa_num_task_cpus != NULL ? _numa_num_task_cpus() : -1;
+  }
   static int numa_available() { return _numa_available != NULL ? _numa_available() : -1; }
   static int numa_tonode_memory(void *start, size_t size, int node) {
     return _numa_tonode_memory != NULL ? _numa_tonode_memory(start, size, node) : -1;