comparison src/os/linux/vm/os_linux.cpp @ 3826:7c2653aefc46

7060836: RHEL 5.5 and 5.6 should support UseNUMA Summary: Add a wrapper for sched_getcpu() for systems where libc lacks it Reviewed-by: ysr Contributed-by: Andrew John Hughes <ahughes@redhat.com>
author iveresov
date Fri, 05 Aug 2011 16:50:14 -0700
parents a20e6e447d3d
children 3cd0157e1d4d
comparison
equal deleted inserted replaced
3825:a20e6e447d3d 3826:7c2653aefc46
123 # include <link.h> 123 # include <link.h>
124 # include <stdint.h> 124 # include <stdint.h>
125 # include <inttypes.h> 125 # include <inttypes.h>
126 # include <sys/ioctl.h> 126 # include <sys/ioctl.h>
127 127
128 #ifdef AMD64
129 #include <asm/vsyscall.h>
130 #endif
131
128 #define MAX_PATH (2 * K) 132 #define MAX_PATH (2 * K)
129 133
130 // for timer info max values which include all bits 134 // for timer info max values which include all bits
131 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) 135 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
132 #define SEC_IN_NANOSECS 1000000000LL 136 #define SEC_IN_NANOSECS 1000000000LL
2576 2580
2577 char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) { 2581 char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) {
2578 return end; 2582 return end;
2579 } 2583 }
2580 2584
2585
2586 int os::Linux::sched_getcpu_syscall(void) {
2587 unsigned int cpu;
2588 int retval = -1;
2589
2590 #if defined(IA32)
2591 retval = syscall(SYS_getcpu, &cpu, NULL, NULL);
2592 #elif defined(AMD64)
2593 typedef long (*vgetcpu_t)(unsigned int *cpu, unsigned int *node, unsigned long *tcache);
2594 vgetcpu_t vgetcpu = (vgetcpu_t)VSYSCALL_ADDR(__NR_vgetcpu);
2595 retval = vgetcpu(&cpu, NULL, NULL);
2596 #endif
2597
2598 return (retval == -1) ? retval : cpu;
2599 }
2600
2581 // Something to do with the numa-aware allocator needs these symbols 2601 // Something to do with the numa-aware allocator needs these symbols
2582 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } 2602 extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
2583 extern "C" JNIEXPORT void numa_error(char *where) { } 2603 extern "C" JNIEXPORT void numa_error(char *where) { }
2584 extern "C" JNIEXPORT int fork1() { return fork(); } 2604 extern "C" JNIEXPORT int fork1() { return fork(); }
2585 2605
2598 2618
2599 bool os::Linux::libnuma_init() { 2619 bool os::Linux::libnuma_init() {
2600 // sched_getcpu() should be in libc. 2620 // sched_getcpu() should be in libc.
2601 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, 2621 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
2602 dlsym(RTLD_DEFAULT, "sched_getcpu"))); 2622 dlsym(RTLD_DEFAULT, "sched_getcpu")));
2623
2624 // If it's not, try a direct syscall.
2625 if (sched_getcpu() == -1)
2626 set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, (void*)&sched_getcpu_syscall));
2603 2627
2604 if (sched_getcpu() != -1) { // Does it work? 2628 if (sched_getcpu() != -1) { // Does it work?
2605 void *handle = dlopen("libnuma.so.1", RTLD_LAZY); 2629 void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
2606 if (handle != NULL) { 2630 if (handle != NULL) {
2607 set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t, 2631 set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t,