comparison src/os/linux/vm/os_linux.hpp @ 141:fcbfc50865ab

6684395: Port NUMA-aware allocator to linux Summary: NUMA-aware allocator port to Linux Reviewed-by: jmasa, apetrusenko
author iveresov
date Tue, 29 Apr 2008 13:51:26 +0400
parents a61af66fc99e
children d1605aabd0a1 f139919897d2
comparison
equal deleted inserted replaced
140:3febac328d82 141:fcbfc50865ab
57 57
58 static bool _is_floating_stack; 58 static bool _is_floating_stack;
59 static bool _is_NPTL; 59 static bool _is_NPTL;
60 static bool _supports_fast_thread_cpu_time; 60 static bool _supports_fast_thread_cpu_time;
61 61
62 static GrowableArray<int>* _cpu_to_node;
63
62 protected: 64 protected:
63 65
64 static julong _physical_memory; 66 static julong _physical_memory;
65 static pthread_t _main_thread; 67 static pthread_t _main_thread;
66 static Mutex* _createThread_lock; 68 static Mutex* _createThread_lock;
77 79
78 static void set_is_NPTL() { _is_NPTL = true; } 80 static void set_is_NPTL() { _is_NPTL = true; }
79 static void set_is_LinuxThreads() { _is_NPTL = false; } 81 static void set_is_LinuxThreads() { _is_NPTL = false; }
80 static void set_is_floating_stack() { _is_floating_stack = true; } 82 static void set_is_floating_stack() { _is_floating_stack = true; }
81 83
84 static void rebuild_cpu_to_node_map();
85 static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }
82 public: 86 public:
83
84 static void init_thread_fpu_state(); 87 static void init_thread_fpu_state();
85 static int get_fpu_control_word(); 88 static int get_fpu_control_word();
86 static void set_fpu_control_word(int fpu_control); 89 static void set_fpu_control_word(int fpu_control);
87 static pthread_t main_thread(void) { return _main_thread; } 90 static pthread_t main_thread(void) { return _main_thread; }
88 // returns kernel thread id (similar to LWP id on Solaris), which can be 91 // returns kernel thread id (similar to LWP id on Solaris), which can be
141 // NPTL is always floating stack. LinuxThreads could be using floating 144 // NPTL is always floating stack. LinuxThreads could be using floating
142 // stack or fixed stack. 145 // stack or fixed stack.
143 static bool is_floating_stack() { return _is_floating_stack; } 146 static bool is_floating_stack() { return _is_floating_stack; }
144 147
145 static void libpthread_init(); 148 static void libpthread_init();
149 static void libnuma_init();
146 150
147 // Minimum stack size a thread can be created with (allowing 151 // Minimum stack size a thread can be created with (allowing
148 // the VM to completely create the thread and enter user code) 152 // the VM to completely create the thread and enter user code)
149 static size_t min_stack_allowed; 153 static size_t min_stack_allowed;
150 154
227 } 231 }
228 bool is_suspended() { return _state & SR_SUSPENDED; } 232 bool is_suspended() { return _state & SR_SUSPENDED; }
229 233
230 #undef SR_SUSPENDED 234 #undef SR_SUSPENDED
231 }; 235 };
236
237 private:
238 typedef int (*sched_getcpu_func_t)(void);
239 typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
240 typedef int (*numa_max_node_func_t)(void);
241 typedef int (*numa_available_func_t)(void);
242 typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
243
244
245 static sched_getcpu_func_t _sched_getcpu;
246 static numa_node_to_cpus_func_t _numa_node_to_cpus;
247 static numa_max_node_func_t _numa_max_node;
248 static numa_available_func_t _numa_available;
249 static numa_tonode_memory_func_t _numa_tonode_memory;
250
251 static void set_sched_getcpu(sched_getcpu_func_t func) { _sched_getcpu = func; }
252 static void set_numa_node_to_cpus(numa_node_to_cpus_func_t func) { _numa_node_to_cpus = func; }
253 static void set_numa_max_node(numa_max_node_func_t func) { _numa_max_node = func; }
254 static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
255 static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
256
257 public:
258 static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
259 static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
260 return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
261 }
262 static int numa_max_node() { return _numa_max_node != NULL ? _numa_max_node() : -1; }
263 static int numa_available() { return _numa_available != NULL ? _numa_available() : -1; }
264 static int numa_tonode_memory(void *start, size_t size, int node) {
265 return _numa_tonode_memory != NULL ? _numa_tonode_memory(start, size, node) : -1;
266 }
267 static int get_node_by_cpu(int cpu_id);
232 }; 268 };
233 269
234 270
235 class PlatformEvent : public CHeapObj { 271 class PlatformEvent : public CHeapObj {
236 private: 272 private: