diff --git a/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp b/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp index 3cd9338f1d66d..ac723483637f0 100644 --- a/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp +++ b/src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp @@ -26,10 +26,7 @@ void ZNUMA::pd_initialize() { _enabled = false; -} - -uint32_t ZNUMA::count() { - return 1; + _count = 1; } uint32_t ZNUMA::id() { diff --git a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp index 3ae0c6ab71902..5a5db42854839 100644 --- a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp +++ b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, 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 @@ -32,15 +32,9 @@ void ZNUMA::pd_initialize() { _enabled = UseNUMA; -} - -uint32_t ZNUMA::count() { - if (!_enabled) { - // NUMA support not enabled - return 1; - } - - return os::Linux::numa_max_node() + 1; + _count = UseNUMA + ? os::Linux::numa_max_node() + 1 + : 1; } uint32_t ZNUMA::id() { @@ -65,7 +59,7 @@ uint32_t ZNUMA::memory_id(uintptr_t addr) { fatal("Failed to get NUMA id for memory at " PTR_FORMAT " (%s)", addr, err.to_string()); } - assert(id < count(), "Invalid NUMA id"); + assert(id < _count, "Invalid NUMA id"); return id; } diff --git a/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp b/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp index 8a93b66f38902..afe8f18c3927c 100644 --- a/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp +++ b/src/hotspot/os/windows/gc/z/zNUMA_windows.cpp @@ -25,10 +25,7 @@ void ZNUMA::pd_initialize() { _enabled = false; -} - -uint32_t ZNUMA::count() { - return 1; + _count = 1; } uint32_t ZNUMA::id() { diff --git a/src/hotspot/share/gc/z/zNUMA.cpp b/src/hotspot/share/gc/z/zNUMA.cpp index 2c37b25f87bb9..a302a1843bb41 100644 --- a/src/hotspot/share/gc/z/zNUMA.cpp +++ b/src/hotspot/share/gc/z/zNUMA.cpp @@ -25,13 +25,14 @@ #include "gc/z/zNUMA.hpp" bool ZNUMA::_enabled; +uint32_t ZNUMA::_count; void ZNUMA::initialize() { pd_initialize(); log_info_p(gc, init)("NUMA Support: %s", to_string()); if (_enabled) { - log_info_p(gc, init)("NUMA Nodes: %u", count()); + log_info_p(gc, init)("NUMA Nodes: %u", _count); } } diff --git a/src/hotspot/share/gc/z/zNUMA.hpp b/src/hotspot/share/gc/z/zNUMA.hpp index fb29e1faaa733..ac6142475226d 100644 --- a/src/hotspot/share/gc/z/zNUMA.hpp +++ b/src/hotspot/share/gc/z/zNUMA.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, 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 @@ -29,7 +29,8 @@ class ZNUMA : public AllStatic { private: - static bool _enabled; + static bool _enabled; + static uint32_t _count; 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 65fbd1040dc12..4596c8f090bfd 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, 2025, 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 @@ -30,4 +30,8 @@ inline bool ZNUMA::is_enabled() { return _enabled; } +inline uint32_t ZNUMA::count() { + return _count; +} + #endif // SHARE_GC_Z_ZNUMA_INLINE_HPP diff --git a/src/hotspot/share/gc/z/zPageCache.cpp b/src/hotspot/share/gc/z/zPageCache.cpp index b689a274de06c..c8e8ec9bdbdb7 100644 --- a/src/hotspot/share/gc/z/zPageCache.cpp +++ b/src/hotspot/share/gc/z/zPageCache.cpp @@ -23,7 +23,7 @@ #include "gc/z/zGlobals.hpp" #include "gc/z/zList.inline.hpp" -#include "gc/z/zNUMA.hpp" +#include "gc/z/zNUMA.inline.hpp" #include "gc/z/zPage.inline.hpp" #include "gc/z/zPageCache.hpp" #include "gc/z/zStat.hpp"