src/os/linux/vm/os_linux.hpp

changeset 9303
c2ee42fa54cd
parent 9289
427b2fb1944f
child 9348
cb9634ab2906
equal deleted inserted replaced
9302:3e565a695187 9303:c2ee42fa54cd
282 static void set_numa_interleave_memory_v2(numa_interleave_memory_v2_func_t func) { _numa_interleave_memory_v2 = func; } 282 static void set_numa_interleave_memory_v2(numa_interleave_memory_v2_func_t func) { _numa_interleave_memory_v2 = func; }
283 static void set_numa_set_bind_policy(numa_set_bind_policy_func_t func) { _numa_set_bind_policy = func; } 283 static void set_numa_set_bind_policy(numa_set_bind_policy_func_t func) { _numa_set_bind_policy = func; }
284 static void set_numa_bitmask_isbitset(numa_bitmask_isbitset_func_t func) { _numa_bitmask_isbitset = func; } 284 static void set_numa_bitmask_isbitset(numa_bitmask_isbitset_func_t func) { _numa_bitmask_isbitset = func; }
285 static void set_numa_distance(numa_distance_func_t func) { _numa_distance = func; } 285 static void set_numa_distance(numa_distance_func_t func) { _numa_distance = func; }
286 static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; } 286 static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
287 static void set_numa_all_nodes_ptr(struct bitmask **ptr) { _numa_all_nodes_ptr = *ptr; } 287 static void set_numa_all_nodes_ptr(struct bitmask **ptr) { _numa_all_nodes_ptr = (ptr == NULL ? NULL : *ptr); }
288 static void set_numa_nodes_ptr(struct bitmask **ptr) { _numa_nodes_ptr = *ptr; } 288 static void set_numa_nodes_ptr(struct bitmask **ptr) { _numa_nodes_ptr = (ptr == NULL ? NULL : *ptr); }
289 static int sched_getcpu_syscall(void); 289 static int sched_getcpu_syscall(void);
290 public: 290 public:
291 static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; } 291 static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
292 static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) { 292 static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
293 return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1; 293 return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
327 } 327 }
328 // Check if numa node exists in the system (including zero memory nodes). 328 // Check if numa node exists in the system (including zero memory nodes).
329 static bool isnode_in_existing_nodes(unsigned int n) { 329 static bool isnode_in_existing_nodes(unsigned int n) {
330 if (_numa_bitmask_isbitset != NULL && _numa_nodes_ptr != NULL) { 330 if (_numa_bitmask_isbitset != NULL && _numa_nodes_ptr != NULL) {
331 return _numa_bitmask_isbitset(_numa_nodes_ptr, n); 331 return _numa_bitmask_isbitset(_numa_nodes_ptr, n);
332 } else if (_numa_bitmask_isbitset != NULL && _numa_all_nodes_ptr != NULL) {
333 // Not all libnuma API v2 implement numa_nodes_ptr, so it's not possible
334 // to trust the API version for checking its absence. On the other hand,
335 // numa_nodes_ptr found in libnuma 2.0.9 and above is the only way to get
336 // a complete view of all numa nodes in the system, hence numa_nodes_ptr
337 // is used to handle CPU and nodes on architectures (like PowerPC) where
338 // there can exist nodes with CPUs but no memory or vice-versa and the
339 // nodes may be non-contiguous. For most of the architectures, like
340 // x86_64, numa_node_ptr presents the same node set as found in
341 // numa_all_nodes_ptr so it's possible to use numa_all_nodes_ptr as a
342 // substitute.
343 return _numa_bitmask_isbitset(_numa_all_nodes_ptr, n);
332 } else 344 } else
333 return 0; 345 return 0;
334 } 346 }
335 }; 347 };
336 348

mercurial