File: numa_on_early_glibc.patch

package info (click to toggle)
openjdk-6 6b27-1.12.6-1~deb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-proposed-updates
  • size: 133,540 kB
  • ctags: 37,146
  • sloc: java: 173,188; cpp: 13,710; asm: 6,470; ansic: 4,827; sh: 4,156; makefile: 4,149; perl: 1,005; python: 310
file content (46 lines) | stat: -rw-r--r-- 1,394 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- openjdk.orig/hotspot/src/os/linux/vm/os_linux.cpp	2010-09-14 15:30:59.000000000 +0100
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp	2010-09-14 17:45:54.000000000 +0100
@@ -54,6 +54,10 @@ 
 # include <sys/shm.h>
 # include <link.h>
 
+#if __x86_64__
+#include <asm/vsyscall.h>
+#endif
+
 #define MAX_PATH    (2 * K)
 
 // for timer info max values which include all bits
@@ -2414,6 +2418,21 @@ 
   return end;
 }
 
+static int sched_getcpu_syscall(void) {
+  unsigned int cpu;
+  int retval = -1;
+
+#if __x86_64__
+  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);
+#elif __i386__
+  retval = syscall(SYS_getcpu, &cpu, NULL, NULL);
+#endif
+
+  return (retval == -1) ? retval : cpu;
+}
+
 extern "C" void numa_warn(int number, char *where, ...) { }
 extern "C" void numa_error(char *where) { }
 
@@ -2422,6 +2441,10 @@ 
   set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
                                   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?
     void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
     if (handle != NULL) {