1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2020 SAP SE. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #ifndef SHARE_MEMORY_METASPACE_MSSETTINGS_HPP 27 #define SHARE_MEMORY_METASPACE_MSSETTINGS_HPP 28 29 #include "memory/allocation.hpp" 30 #include "memory/metaspace/msChunklevel.hpp" 31 #include "utilities/globalDefinitions.hpp" 32 33 namespace metaspace { 34 35 class Settings : public AllStatic { 36 37 // Granularity, in bytes, metaspace is committed with. 38 static size_t _commit_granule_bytes; 39 40 // Granularity, in words, metaspace is committed with. 41 static size_t _commit_granule_words; 42 43 // The default size of a non-class VirtualSpaceNode (unless created differently). 44 // Must be a multiple of the root chunk size. 45 static const size_t VirtualSpaceNodeDefaultWordSize = chunklevel::MAX_CHUNK_WORD_SIZE * 2; // lets go with 8mb virt size. Seems a good compromise betw. virt and mapping fragmentation. 46 47 // Alignment of the base address of a virtual space node 48 static const size_t VirtualSpaceNodeReserveAlignmentWordSize = chunklevel::MAX_CHUNK_WORD_SIZE; 49 50 // When allocating from a chunk, if the remaining area in the chunk is too small to hold 51 // the requested size, we attempt to double the chunk size in place... 52 static const bool EnlargeChunksInPlace = true; 53 54 // Whether or not chunks handed out to an arena start out fully committed; 55 // if true, this deactivates committing-on-demand (irregardless of whether 56 // we uncommit free chunks). 57 static bool _new_chunks_are_fully_committed; 58 59 // If true, chunks equal or larger than a commit granule are uncommitted 60 // after being returned to the freelist. 61 static bool _uncommit_free_chunks; 62 63 // If true, metablock allocations are guarded and periodically checked. 64 DEBUG_ONLY(static bool _use_allocation_guard;) 65 66 // If true, we handle deallocated blocks (default). 67 DEBUG_ONLY(static bool _handle_deallocations;) 68 69 public: 70 71 static size_t commit_granule_bytes() { return _commit_granule_bytes; } 72 static size_t commit_granule_words() { return _commit_granule_words; } 73 static bool new_chunks_are_fully_committed() { return _new_chunks_are_fully_committed; } 74 static size_t virtual_space_node_default_word_size() { return VirtualSpaceNodeDefaultWordSize; } 75 static size_t virtual_space_node_reserve_alignment_words() { return VirtualSpaceNodeReserveAlignmentWordSize; } 76 static bool enlarge_chunks_in_place() { return EnlargeChunksInPlace; } 77 static bool uncommit_free_chunks() { return _uncommit_free_chunks; } 78 79 static bool use_allocation_guard() { return DEBUG_ONLY(_use_allocation_guard) NOT_DEBUG(false); } 80 static bool handle_deallocations() { return DEBUG_ONLY(_handle_deallocations) NOT_DEBUG(true); } 81 82 static void ergo_initialize(); 83 84 static void print_on(outputStream* st); 85 86 }; 87 88 } // namespace metaspace 89 90 #endif // SHARE_MEMORY_METASPACE_MSSETTINGS_HPP