src/hotspot/share/gc/g1/g1RegionsOnNodes.cpp
author sangheki
Wed, 13 Nov 2019 10:51:41 -0800
changeset 59062 6530de931b8e
permissions -rw-r--r--
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3) Reviewed-by: kbarrett, sjohanss, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59062
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     1
/*
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     4
 *
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     8
 *
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    13
 * accompanied this code).
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    14
 *
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    18
 *
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    21
 * questions.
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    22
 *
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    23
 */
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    24
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    25
#include "precompiled.hpp"
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    26
#include "gc/g1/g1NUMA.hpp"
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    27
#include "gc/g1/g1RegionsOnNodes.hpp"
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    28
#include "gc/g1/heapRegion.hpp"
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    29
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    30
G1RegionsOnNodes::G1RegionsOnNodes() : _count_per_node(NULL), _numa(G1NUMA::numa()) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    31
  _count_per_node = NEW_C_HEAP_ARRAY(uint, _numa->num_active_nodes(), mtGC);
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    32
  clear();
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    33
}
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    34
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    35
G1RegionsOnNodes::~G1RegionsOnNodes() {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    36
  FREE_C_HEAP_ARRAY(uint, _count_per_node);
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    37
}
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    38
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    39
uint G1RegionsOnNodes::add(HeapRegion* hr) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    40
  uint node_index = hr->node_index();
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    41
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    42
  // Update only if the node index is valid.
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    43
  if (node_index < _numa->num_active_nodes()) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    44
    *(_count_per_node + node_index) += 1;
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    45
    return node_index;
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    46
  }
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    47
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    48
  return G1NUMA::UnknownNodeIndex;
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    49
}
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    50
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    51
void G1RegionsOnNodes::clear() {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    52
  for (uint i = 0; i < _numa->num_active_nodes(); i++) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    53
    _count_per_node[i] = 0;
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    54
  }
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    55
}
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    56
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    57
uint G1RegionsOnNodes::count(uint node_index) const {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    58
  return _count_per_node[node_index];
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents:
diff changeset
    59
}