8266217: ZGC: Improve the -Xlog:gc+init output for NUMA

Reviewed-by: stefank, tschatzl, pliden
diff --git a/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp b/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp
index a0fe34c..4dc46651 100644
--- a/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp
+++ b/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 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
@@ -25,7 +25,7 @@
 #include "gc/z/zNUMA.hpp"
 
 void ZNUMA::pd_initialize() {
-  _enabled = false;
+  _state = Disabled;
 }
 
 uint32_t ZNUMA::count() {
diff --git a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp
index 737e9b0..8239520 100644
--- a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp
+++ b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp
@@ -24,6 +24,7 @@
 #include "gc/z/zCPU.inline.hpp"
 #include "gc/z/zErrno.hpp"
 #include "gc/z/zNUMA.hpp"
+#include "gc/z/zNUMA.inline.hpp"
 #include "gc/z/zSyscall_linux.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
@@ -47,11 +48,15 @@
 }
 
 void ZNUMA::pd_initialize() {
-  _enabled = UseNUMA && is_numa_supported();
+  if (!UseNUMA) {
+    _state = Disabled;
+  } else {
+    _state = is_numa_supported() ? Enabled : Unsupported;
+  }
 }
 
 uint32_t ZNUMA::count() {
-  if (!_enabled) {
+  if (!is_enabled()) {
     // NUMA support not enabled
     return 1;
   }
@@ -60,7 +65,7 @@
 }
 
 uint32_t ZNUMA::id() {
-  if (!_enabled) {
+  if (!is_enabled()) {
     // NUMA support not enabled
     return 0;
   }
@@ -69,7 +74,7 @@
 }
 
 uint32_t ZNUMA::memory_id(uintptr_t addr) {
-  if (!_enabled) {
+  if (!is_enabled()) {
     // NUMA support not enabled, assume everything belongs to node zero
     return 0;
   }
diff --git a/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp b/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp
index a0fe34c..4dc46651 100644
--- a/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp
+++ b/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 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
@@ -25,7 +25,7 @@
 #include "gc/z/zNUMA.hpp"
 
 void ZNUMA::pd_initialize() {
-  _enabled = false;
+  _state = Disabled;
 }
 
 uint32_t ZNUMA::count() {
diff --git a/src/hotspot/share/gc/z/zNUMA.cpp b/src/hotspot/share/gc/z/zNUMA.cpp
index 2ee790e..05e9775 100644
--- a/src/hotspot/share/gc/z/zNUMA.cpp
+++ b/src/hotspot/share/gc/z/zNUMA.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -24,18 +24,28 @@
 #include "precompiled.hpp"
 #include "gc/shared/gcLogPrecious.hpp"
 #include "gc/z/zNUMA.hpp"
+#include "gc/z/zNUMA.inline.hpp"
 
-bool ZNUMA::_enabled;
+ZNUMA::State ZNUMA::_state;
 
 void ZNUMA::initialize() {
   pd_initialize();
 
   log_info_p(gc, init)("NUMA Support: %s", to_string());
-  if (_enabled) {
+  if (is_enabled()) {
     log_info_p(gc, init)("NUMA Nodes: %u", count());
   }
 }
 
 const char* ZNUMA::to_string() {
-  return _enabled ? "Enabled" : "Disabled";
+  switch (_state) {
+  case Enabled:
+    return "Enabled";
+
+  case Unsupported:
+    return "Unsupported";
+
+  default:
+    return "Disabled";
+  }
 }
diff --git a/src/hotspot/share/gc/z/zNUMA.hpp b/src/hotspot/share/gc/z/zNUMA.hpp
index 0dc4390..5caa5ce 100644
--- a/src/hotspot/share/gc/z/zNUMA.hpp
+++ b/src/hotspot/share/gc/z/zNUMA.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -28,7 +28,13 @@
 
 class ZNUMA : public AllStatic {
 private:
-  static bool _enabled;
+  enum State {
+    Disabled,
+    Enabled,
+    Unsupported
+  };
+
+  static State _state;
 
   static void pd_initialize();
 
diff --git a/src/hotspot/share/gc/z/zNUMA.inline.hpp b/src/hotspot/share/gc/z/zNUMA.inline.hpp
index 65fbd10..d16eada 100644
--- a/src/hotspot/share/gc/z/zNUMA.inline.hpp
+++ b/src/hotspot/share/gc/z/zNUMA.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 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
@@ -27,7 +27,7 @@
 #include "gc/z/zNUMA.hpp"
 
 inline bool ZNUMA::is_enabled() {
-  return _enabled;
+  return _state == Enabled;
 }
 
 #endif // SHARE_GC_Z_ZNUMA_INLINE_HPP