1 /* 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_G1_NUMA_INLINE_HPP 26 #define SHARE_VM_GC_G1_NUMA_INLINE_HPP 27 28 #include "gc/g1/g1MemoryNodeManager.hpp" 29 #include "gc/g1/g1NUMA.hpp" 30 #include "runtime/atomic.hpp" 31 32 inline bool G1NUMA::is_valid_numa_id(int numa_id) { 33 // Valid numa id should be one of active numa ids. 34 for (uint i = 0; i < _num_active_numa_ids; i++) { 35 if (_numa_ids[i] == numa_id) { 36 return true; 37 } 38 } 39 return false; 40 } 41 42 inline bool G1NUMA::is_valid_numa_index(uint numa_index) const { 43 // Valid numa index should be less than the number of active numa ids. 44 return numa_index < _num_active_numa_ids; 45 } 46 47 inline uint G1NUMA::num_active_numa_ids() const { 48 assert(_num_active_numa_ids > 0, "just checking"); 49 return _num_active_numa_ids; 50 } 51 52 inline uint G1NUMA::index_of_numa_id(int numa_id) const { 53 // Don't need call is_valid_numa_id, as _numa_id_to_index_map 54 // may return G1MemoryNodeManager::InvalidNodeIndex. 55 if (numa_id >= 0 && numa_id < _len_numa_id_to_index_map) { 56 return _numa_id_to_index_map[numa_id]; 57 } 58 return G1MemoryNodeManager::InvalidNodeIndex; 59 } 60 61 inline int G1NUMA::numa_id_of_index(uint numa_index) const { 62 if (is_valid_numa_index(numa_index)) { 63 return _numa_ids[numa_index]; 64 } 65 return os::InvalidId; 66 } 67 68 #endif // SHARE_VM_GC_G1_NUMA_INLINE_HPP