Skip to content

Commit

Permalink
8298482: Implement ParallelGC NUMAStats for Linux
Browse files Browse the repository at this point in the history
Reviewed-by: ayang, sjohanss, tschatzl
  • Loading branch information
nick-arm committed Jan 12, 2023
1 parent 0ee8cac commit 036c808
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 54 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/os/aix/os_aix.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -1872,7 +1872,7 @@ int os::numa_get_group_id_for_address(const void* address) {
return 0;
}

bool os::get_page_info(char *start, page_info* info) {
bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, size_t count) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/bsd/os_bsd.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2023, 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
Expand Down Expand Up @@ -1575,7 +1575,7 @@ int os::numa_get_group_id_for_address(const void* address) {
return 0;
}

bool os::get_page_info(char *start, page_info* info) {
bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, size_t count) {
return false;
}

Expand Down
11 changes: 6 additions & 5 deletions src/hotspot/os/linux/os_linux.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -2777,6 +2777,11 @@ int os::numa_get_group_id_for_address(const void* address) {
return id;
}

bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, size_t count) {
void** pages = const_cast<void**>(addresses);
return os::Linux::numa_move_pages(0, count, pages, NULL, lgrp_ids, 0) == 0;
}

int os::Linux::get_existing_num_nodes() {
int node;
int highest_node_number = Linux::numa_max_node();
Expand Down Expand Up @@ -2807,10 +2812,6 @@ size_t os::numa_get_leaf_groups(int *ids, size_t size) {
return i;
}

bool os::get_page_info(char *start, page_info* info) {
return false;
}

char *os::scan_pages(char *start, char* end, page_info* page_expected,
page_info* page_found) {
return end;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/windows/os_windows.cpp
Expand Up @@ -3727,7 +3727,7 @@ int os::numa_get_group_id_for_address(const void* address) {
return 0;
}

bool os::get_page_info(char *start, page_info* info) {
bool os::numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, size_t count) {
return false;
}

Expand Down
58 changes: 20 additions & 38 deletions src/hotspot/share/gc/parallel/mutableNUMASpace.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2023, 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
Expand Down Expand Up @@ -376,12 +376,6 @@ void MutableNUMASpace::update() {
}
}

if (NUMAStats) {
for (int i = 0; i < lgrp_spaces()->length(); i++) {
lgrp_spaces()->at(i)->accumulate_statistics(page_size());
}
}

scan_pages(NUMAPageScanRate);
}

Expand All @@ -405,12 +399,6 @@ void MutableNUMASpace::accumulate_statistics() {
}
increment_samples_count();
}

if (NUMAStats) {
for (int i = 0; i < lgrp_spaces()->length(); i++) {
lgrp_spaces()->at(i)->accumulate_statistics(page_size());
}
}
}

// Get the current size of a chunk.
Expand Down Expand Up @@ -870,14 +858,11 @@ void MutableNUMASpace::print_on(outputStream* st) const {
lgrp_spaces()->at(i)->accumulate_statistics(page_size());
}
st->print(" local/remote/unbiased/uncommitted: " SIZE_FORMAT "K/"
SIZE_FORMAT "K/" SIZE_FORMAT "K/" SIZE_FORMAT
"K, large/small pages: " SIZE_FORMAT "/" SIZE_FORMAT "\n",
SIZE_FORMAT "K/" SIZE_FORMAT "K/" SIZE_FORMAT "K\n",
ls->space_stats()->_local_space / K,
ls->space_stats()->_remote_space / K,
ls->space_stats()->_unbiased_space / K,
ls->space_stats()->_uncommited_space / K,
ls->space_stats()->_large_pages,
ls->space_stats()->_small_pages);
ls->space_stats()->_uncommited_space / K);
}
}
}
Expand All @@ -895,28 +880,25 @@ void MutableNUMASpace::LGRPSpace::accumulate_statistics(size_t page_size) {
clear_space_stats();
char *start = (char*)align_up(space()->bottom(), page_size);
char* end = (char*)align_down(space()->end(), page_size);
if (start < end) {
for (char *p = start; p < end;) {
os::page_info info;
if (os::get_page_info(p, &info)) {
if (info.size > 0) {
if (info.size > (size_t)os::vm_page_size()) {
space_stats()->_large_pages++;
} else {
space_stats()->_small_pages++;
}
if (info.lgrp_id == lgrp_id()) {
space_stats()->_local_space += info.size;
} else {
space_stats()->_remote_space += info.size;
}
p += info.size;
} else {
p += os::vm_page_size();
for (char *p = start; p < end; ) {
static const size_t PagesPerIteration = 128;
const void* pages[PagesPerIteration];
int lgrp_ids[PagesPerIteration];

size_t npages = 0;
for (; npages < PagesPerIteration && p < end; p += os::vm_page_size()) {
pages[npages++] = p;
}

if (os::numa_get_group_ids_for_range(pages, lgrp_ids, npages)) {
for (size_t i = 0; i < npages; i++) {
if (lgrp_ids[i] < 0) {
space_stats()->_uncommited_space += os::vm_page_size();
} else if (lgrp_ids[i] == lgrp_id()) {
space_stats()->_local_space += os::vm_page_size();
} else {
space_stats()->_remote_space += os::vm_page_size();
}
} else {
return;
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/share/gc/parallel/mutableNUMASpace.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2023, 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
Expand Down Expand Up @@ -73,15 +73,12 @@ class MutableNUMASpace : public MutableSpace {

struct SpaceStats {
size_t _local_space, _remote_space, _unbiased_space, _uncommited_space;
size_t _large_pages, _small_pages;

SpaceStats() {
_local_space = 0;
_remote_space = 0;
_unbiased_space = 0;
_uncommited_space = 0;
_large_pages = 0;
_small_pages = 0;
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/os.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023, 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
Expand Down Expand Up @@ -500,13 +500,13 @@ class os: AllStatic {
static bool numa_topology_changed();
static int numa_get_group_id();
static int numa_get_group_id_for_address(const void* address);
static bool numa_get_group_ids_for_range(const void** addresses, int* lgrp_ids, size_t count);

// Page manipulation
struct page_info {
size_t size;
int lgrp_id;
};
static bool get_page_info(char *start, page_info* info);
static char* scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found);

static char* non_memory_address_word();
Expand Down

1 comment on commit 036c808

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.