From a2acf21aaff7e99d4708893269548b1d03de2916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Sikstr=C3=B6m?= Date: Tue, 4 Mar 2025 22:25:48 +0100 Subject: [PATCH 1/3] 8351216: Store NUMA node count --- src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp | 5 +---- src/hotspot/os/linux/gc/z/zNUMA_linux.cpp | 13 ++++--------- src/hotspot/os/windows/gc/z/zNUMA_windows.cpp | 5 +---- src/hotspot/share/gc/z/zNUMA.cpp | 3 ++- src/hotspot/share/gc/z/zNUMA.hpp | 3 ++- src/hotspot/share/gc/z/zNUMA.inline.hpp | 4 ++++ src/hotspot/share/gc/z/zPageCache.cpp | 2 +- 7 files changed, 15 insertions(+), 20 deletions(-) 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..9245bf7329e67 100644 --- a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp +++ b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp @@ -32,15 +32,10 @@ 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 +60,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..e94ae98947fe4 100644 --- a/src/hotspot/share/gc/z/zNUMA.hpp +++ b/src/hotspot/share/gc/z/zNUMA.hpp @@ -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..85240ce3b961c 100644 --- a/src/hotspot/share/gc/z/zNUMA.inline.hpp +++ b/src/hotspot/share/gc/z/zNUMA.inline.hpp @@ -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" From 45dc106a0119f9f3fe2d8b9f3a3397a2a2f0f30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Sikstr=C3=B6m?= Date: Wed, 12 Mar 2025 17:00:22 +0100 Subject: [PATCH 2/3] Style fix --- src/hotspot/os/linux/gc/z/zNUMA_linux.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp index 9245bf7329e67..503e60b42d7fa 100644 --- a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp +++ b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp @@ -32,10 +32,9 @@ void ZNUMA::pd_initialize() { _enabled = UseNUMA; - _count = UseNUMA - ? os::Linux::numa_max_node() + 1 - : 1; + ? os::Linux::numa_max_node() + 1 + : 1; } uint32_t ZNUMA::id() { From bdfcc781e44feaf53ac4652fec09dc2acc71b8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Sikstr=C3=B6m?= Date: Thu, 13 Mar 2025 09:59:21 +0100 Subject: [PATCH 3/3] Copyright years --- src/hotspot/os/linux/gc/z/zNUMA_linux.cpp | 2 +- src/hotspot/share/gc/z/zNUMA.hpp | 2 +- src/hotspot/share/gc/z/zNUMA.inline.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp index 503e60b42d7fa..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 diff --git a/src/hotspot/share/gc/z/zNUMA.hpp b/src/hotspot/share/gc/z/zNUMA.hpp index e94ae98947fe4..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 diff --git a/src/hotspot/share/gc/z/zNUMA.inline.hpp b/src/hotspot/share/gc/z/zNUMA.inline.hpp index 85240ce3b961c..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