Path: blob/master/src/hotspot/os/bsd/os_bsd.hpp
40949 views
/*1* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef OS_BSD_OS_BSD_HPP25#define OS_BSD_OS_BSD_HPP2627// Bsd_OS defines the interface to Bsd operating systems2829// Information about the protection of the page at address '0' on this os.30static bool zero_page_read_protected() { return true; }3132class Bsd {33friend class os;3435#ifdef __APPLE__36// mach_absolute_time37static mach_timebase_info_data_t _timebase_info;38static volatile uint64_t _max_abstime;39#endif4041static GrowableArray<int>* _cpu_to_node;4243protected:4445static julong _physical_memory;46static pthread_t _main_thread;47static int _page_size;4849static julong available_memory();50static julong physical_memory() { return _physical_memory; }51static void initialize_system_info();5253static void rebuild_cpu_to_node_map();54static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }5556static bool hugetlbfs_sanity_check(bool warn, size_t page_size);5758public:5960static void init_thread_fpu_state();61static pthread_t main_thread(void) { return _main_thread; }6263static pid_t gettid();6465static int page_size(void) { return _page_size; }66static void set_page_size(int val) { _page_size = val; }6768static intptr_t* ucontext_get_sp(const ucontext_t* uc);69static intptr_t* ucontext_get_fp(const ucontext_t* uc);7071static bool get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr);7273// Real-time clock functions74static void clock_init(void);7576// Stack repair handling7778// none present7980private:81typedef int (*sched_getcpu_func_t)(void);82typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);83typedef int (*numa_max_node_func_t)(void);84typedef int (*numa_available_func_t)(void);85typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);86typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);8788static sched_getcpu_func_t _sched_getcpu;89static numa_node_to_cpus_func_t _numa_node_to_cpus;90static numa_max_node_func_t _numa_max_node;91static numa_available_func_t _numa_available;92static numa_tonode_memory_func_t _numa_tonode_memory;93static numa_interleave_memory_func_t _numa_interleave_memory;94static unsigned long* _numa_all_nodes;9596static void set_sched_getcpu(sched_getcpu_func_t func) { _sched_getcpu = func; }97static void set_numa_node_to_cpus(numa_node_to_cpus_func_t func) { _numa_node_to_cpus = func; }98static void set_numa_max_node(numa_max_node_func_t func) { _numa_max_node = func; }99static void set_numa_available(numa_available_func_t func) { _numa_available = func; }100static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }101static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }102static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }103public:104static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }105static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {106return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;107}108static int numa_max_node() { return _numa_max_node != NULL ? _numa_max_node() : -1; }109static int numa_available() { return _numa_available != NULL ? _numa_available() : -1; }110static int numa_tonode_memory(void *start, size_t size, int node) {111return _numa_tonode_memory != NULL ? _numa_tonode_memory(start, size, node) : -1;112}113static void numa_interleave_memory(void *start, size_t size) {114if (_numa_interleave_memory != NULL && _numa_all_nodes != NULL) {115_numa_interleave_memory(start, size, _numa_all_nodes);116}117}118static int get_node_by_cpu(int cpu_id);119120static void print_uptime_info(outputStream* st);121};122123#endif // OS_BSD_OS_BSD_HPP124125126