Skip to content

Commit 5ecef01

Browse files
committed
8266217: ZGC: Improve the -Xlog:gc+init output for NUMA
Reviewed-by: stefank, tschatzl, pliden
1 parent 5d8c1cc commit 5ecef01

File tree

6 files changed

+37
-16
lines changed

6 files changed

+37
-16
lines changed

src/hotspot/os/bsd/gc/z/zNUMA_bsd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
2525
#include "gc/z/zNUMA.hpp"
2626

2727
void ZNUMA::pd_initialize() {
28-
_enabled = false;
28+
_state = Disabled;
2929
}
3030

3131
uint32_t ZNUMA::count() {

src/hotspot/os/linux/gc/z/zNUMA_linux.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "gc/z/zCPU.inline.hpp"
2525
#include "gc/z/zErrno.hpp"
2626
#include "gc/z/zNUMA.hpp"
27+
#include "gc/z/zNUMA.inline.hpp"
2728
#include "gc/z/zSyscall_linux.hpp"
2829
#include "runtime/globals.hpp"
2930
#include "runtime/globals_extension.hpp"
@@ -47,11 +48,15 @@ static bool is_numa_supported() {
4748
}
4849

4950
void ZNUMA::pd_initialize() {
50-
_enabled = UseNUMA && is_numa_supported();
51+
if (!UseNUMA) {
52+
_state = Disabled;
53+
} else {
54+
_state = is_numa_supported() ? Enabled : Unsupported;
55+
}
5156
}
5257

5358
uint32_t ZNUMA::count() {
54-
if (!_enabled) {
59+
if (!is_enabled()) {
5560
// NUMA support not enabled
5661
return 1;
5762
}
@@ -60,7 +65,7 @@ uint32_t ZNUMA::count() {
6065
}
6166

6267
uint32_t ZNUMA::id() {
63-
if (!_enabled) {
68+
if (!is_enabled()) {
6469
// NUMA support not enabled
6570
return 0;
6671
}
@@ -69,7 +74,7 @@ uint32_t ZNUMA::id() {
6974
}
7075

7176
uint32_t ZNUMA::memory_id(uintptr_t addr) {
72-
if (!_enabled) {
77+
if (!is_enabled()) {
7378
// NUMA support not enabled, assume everything belongs to node zero
7479
return 0;
7580
}

src/hotspot/os/windows/gc/z/zNUMA_windows.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
2525
#include "gc/z/zNUMA.hpp"
2626

2727
void ZNUMA::pd_initialize() {
28-
_enabled = false;
28+
_state = Disabled;
2929
}
3030

3131
uint32_t ZNUMA::count() {

src/hotspot/share/gc/z/zNUMA.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,18 +24,28 @@
2424
#include "precompiled.hpp"
2525
#include "gc/shared/gcLogPrecious.hpp"
2626
#include "gc/z/zNUMA.hpp"
27+
#include "gc/z/zNUMA.inline.hpp"
2728

28-
bool ZNUMA::_enabled;
29+
ZNUMA::State ZNUMA::_state;
2930

3031
void ZNUMA::initialize() {
3132
pd_initialize();
3233

3334
log_info_p(gc, init)("NUMA Support: %s", to_string());
34-
if (_enabled) {
35+
if (is_enabled()) {
3536
log_info_p(gc, init)("NUMA Nodes: %u", count());
3637
}
3738
}
3839

3940
const char* ZNUMA::to_string() {
40-
return _enabled ? "Enabled" : "Disabled";
41+
switch (_state) {
42+
case Enabled:
43+
return "Enabled";
44+
45+
case Unsupported:
46+
return "Unsupported";
47+
48+
default:
49+
return "Disabled";
50+
}
4151
}

src/hotspot/share/gc/z/zNUMA.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,13 @@
2828

2929
class ZNUMA : public AllStatic {
3030
private:
31-
static bool _enabled;
31+
enum State {
32+
Disabled,
33+
Enabled,
34+
Unsupported
35+
};
36+
37+
static State _state;
3238

3339
static void pd_initialize();
3440

src/hotspot/share/gc/z/zNUMA.inline.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
2727
#include "gc/z/zNUMA.hpp"
2828

2929
inline bool ZNUMA::is_enabled() {
30-
return _enabled;
30+
return _state == Enabled;
3131
}
3232

3333
#endif // SHARE_GC_Z_ZNUMA_INLINE_HPP

0 commit comments

Comments
 (0)