7086226: UseNUMA fails on old versions of windows
authoriveresov
Wed, 07 Sep 2011 18:58:33 -0700
changeset 10527 fedb7f148e85
parent 10526 3e92f211533f
child 10528 06fab03478df
7086226: UseNUMA fails on old versions of windows Summary: Return correct answers from os::numa_*() for UMA machines or if NUMA API is not supported Reviewed-by: johnc
hotspot/src/os/windows/vm/os_windows.cpp
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Wed Sep 07 13:55:42 2011 -0700
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Wed Sep 07 18:58:33 2011 -0700
@@ -2706,11 +2706,10 @@
 
 static bool numa_interleaving_init() {
   bool success = false;
-  bool use_numa_specified = !FLAG_IS_DEFAULT(UseNUMA);
   bool use_numa_interleaving_specified = !FLAG_IS_DEFAULT(UseNUMAInterleaving);
 
-  // print a warning if UseNUMA or UseNUMAInterleaving flag is specified on command line
-  bool warn_on_failure =  use_numa_specified || use_numa_interleaving_specified;
+  // print a warning if UseNUMAInterleaving flag is specified on command line
+  bool warn_on_failure = use_numa_interleaving_specified;
 # define WARN(msg) if (warn_on_failure) { warning(msg); }
 
   // NUMAInterleaveGranularity cannot be less than vm_allocation_granularity (or _large_page_size if using large pages)
@@ -2720,7 +2719,7 @@
   if (os::Kernel32Dll::NumaCallsAvailable()) {
     if (numa_node_list_holder.build()) {
       if (PrintMiscellaneous && Verbose) {
-        tty->print("NUMA UsedNodeCount=%d, namely ", os::numa_get_groups_num());
+        tty->print("NUMA UsedNodeCount=%d, namely ", numa_node_list_holder.get_count());
         for (int i = 0; i < numa_node_list_holder.get_count(); i++) {
           tty->print("%d ", numa_node_list_holder.get_node_list_entry(i));
         }
@@ -2734,7 +2733,6 @@
     WARN("NUMA Interleaving is not supported by the operating system.");
   }
   if (!success) {
-    if (use_numa_specified) WARN("...Ignoring UseNUMA flag.");
     if (use_numa_interleaving_specified) WARN("...Ignoring UseNUMAInterleaving flag.");
   }
   return success;
@@ -2816,7 +2814,8 @@
                                       prot);
       } else {
         // get the next node to use from the used_node_list
-        DWORD node = numa_node_list_holder.get_node_list_entry(count % os::numa_get_groups_num());
+        assert(numa_node_list_holder.get_count() > 0, "Multiple NUMA nodes expected");
+        DWORD node = numa_node_list_holder.get_node_list_entry(count % numa_node_list_holder.get_count());
         p_new = (char *)os::Kernel32Dll::VirtualAllocExNuma(hProc,
                                                             next_alloc_addr,
                                                             bytes_to_rq,
@@ -3132,15 +3131,21 @@
 void os::numa_make_global(char *addr, size_t bytes)    { }
 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint)    { }
 bool os::numa_topology_changed()                       { return false; }
-size_t os::numa_get_groups_num()                       { return numa_node_list_holder.get_count(); }
+size_t os::numa_get_groups_num()                       { return MAX2(numa_node_list_holder.get_count(), 1); }
 int os::numa_get_group_id()                            { return 0; }
 size_t os::numa_get_leaf_groups(int *ids, size_t size) {
-  // check for size bigger than actual groups_num
-  size = MIN2(size, numa_get_groups_num());
-  for (int i = 0; i < (int)size; i++) {
-    ids[i] = numa_node_list_holder.get_node_list_entry(i);
-  }
-  return size;
+  if (numa_node_list_holder.get_count() == 0 && size > 0) {
+    // Provide an answer for UMA systems
+    ids[0] = 0;
+    return 1;
+  } else {
+    // check for size bigger than actual groups_num
+    size = MIN2(size, numa_get_groups_num());
+    for (int i = 0; i < (int)size; i++) {
+      ids[i] = numa_node_list_holder.get_node_list_entry(i);
+    }
+    return size;
+  }
 }
 
 bool os::get_page_info(char *start, page_info* info) {
@@ -3768,6 +3773,10 @@
   // initialize thread priority policy
   prio_init();
 
+  if (UseNUMA && !ForceNUMA) {
+    UseNUMA = false; // We don't fully support this yet
+  }
+
   if (UseNUMAInterleaving) {
     // first check whether this Windows OS supports VirtualAllocExNuma, if not ignore this flag
     bool success = numa_interleaving_init();