mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
7060836: RHEL 5.5 and 5.6 should support UseNUMA
Add a wrapper for sched_getcpu() for systems where libc lacks it Reviewed-by: ysr
This commit is contained in:
parent
427c404400
commit
c4b791d93a
2 changed files with 25 additions and 0 deletions
|
@ -125,6 +125,10 @@
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
# include <sys/ioctl.h>
|
# include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#ifdef AMD64
|
||||||
|
#include <asm/vsyscall.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_PATH (2 * K)
|
#define MAX_PATH (2 * K)
|
||||||
|
|
||||||
// for timer info max values which include all bits
|
// for timer info max values which include all bits
|
||||||
|
@ -2578,6 +2582,22 @@ char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int os::Linux::sched_getcpu_syscall(void) {
|
||||||
|
unsigned int cpu;
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
#if defined(IA32)
|
||||||
|
retval = syscall(SYS_getcpu, &cpu, NULL, NULL);
|
||||||
|
#elif defined(AMD64)
|
||||||
|
typedef long (*vgetcpu_t)(unsigned int *cpu, unsigned int *node, unsigned long *tcache);
|
||||||
|
vgetcpu_t vgetcpu = (vgetcpu_t)VSYSCALL_ADDR(__NR_vgetcpu);
|
||||||
|
retval = vgetcpu(&cpu, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (retval == -1) ? retval : cpu;
|
||||||
|
}
|
||||||
|
|
||||||
// Something to do with the numa-aware allocator needs these symbols
|
// Something to do with the numa-aware allocator needs these symbols
|
||||||
extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
|
extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
|
||||||
extern "C" JNIEXPORT void numa_error(char *where) { }
|
extern "C" JNIEXPORT void numa_error(char *where) { }
|
||||||
|
@ -2601,6 +2621,10 @@ bool os::Linux::libnuma_init() {
|
||||||
set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
|
set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
|
||||||
dlsym(RTLD_DEFAULT, "sched_getcpu")));
|
dlsym(RTLD_DEFAULT, "sched_getcpu")));
|
||||||
|
|
||||||
|
// If it's not, try a direct syscall.
|
||||||
|
if (sched_getcpu() == -1)
|
||||||
|
set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t, (void*)&sched_getcpu_syscall));
|
||||||
|
|
||||||
if (sched_getcpu() != -1) { // Does it work?
|
if (sched_getcpu() != -1) { // Does it work?
|
||||||
void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
|
void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
|
||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
|
|
|
@ -263,6 +263,7 @@ private:
|
||||||
static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
|
static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
|
||||||
static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
|
static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
|
||||||
static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
|
static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
|
||||||
|
static int sched_getcpu_syscall(void);
|
||||||
public:
|
public:
|
||||||
static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
|
static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
|
||||||
static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
|
static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue