Blame SOURCES/8181055-pr3394-rh1448880.patch

045ef6
# HG changeset patch
045ef6
# User zgu
045ef6
# Date 1496236768 14400
045ef6
#      Wed May 31 09:19:28 2017 -0400
045ef6
# Node ID 8330ff7914ec54c46fd19300221f72d774423405
045ef6
# Parent  55a34e4962e10c822affe8f89273a87e84cade92
045ef6
8181055: PPC64: "mbind: Invalid argument" still seen after 8175813
045ef6
Summary: Use numa_interleave_memory v2 api when available
045ef6
Reviewed-by: dholmes, shade
045ef6
045ef6
diff -r 74c81011375b src/os/linux/vm/os_linux.cpp
045ef6
--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp	Wed May 17 17:52:34 2017 -0400
045ef6
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp	Wed May 31 12:27:00 2017 -0400
045ef6
@@ -2819,11 +2819,8 @@
045ef6
 extern "C" JNIEXPORT void numa_error(char *where) { }
045ef6
 extern "C" JNIEXPORT int fork1() { return fork(); }
045ef6
 
045ef6
-
045ef6
-// If we are running with libnuma version > 2, then we should
045ef6
-// be trying to use symbols with versions 1.1
045ef6
-// If we are running with earlier version, which did not have symbol versions,
045ef6
-// we should use the base version.
045ef6
+// Handle request to load libnuma symbol version 1.1 (API v1). If it fails
045ef6
+// load symbol from base version instead.
045ef6
 void* os::Linux::libnuma_dlsym(void* handle, const char *name) {
045ef6
   void *f = dlvsym(handle, name, "libnuma_1.1");
045ef6
   if (f == NULL) {
045ef6
@@ -2832,6 +2829,12 @@
045ef6
   return f;
045ef6
 }
045ef6
 
045ef6
+// Handle request to load libnuma symbol version 1.2 (API v2) only.
045ef6
+// Return NULL if the symbol is not defined in this particular version.
045ef6
+void* os::Linux::libnuma_v2_dlsym(void* handle, const char* name) {
045ef6
+  return dlvsym(handle, name, "libnuma_1.2");
045ef6
+}
045ef6
+
045ef6
 bool os::Linux::libnuma_init() {
045ef6
   // sched_getcpu() should be in libc.
045ef6
   set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
045ef6
@@ -2856,6 +2859,8 @@
045ef6
                                             libnuma_dlsym(handle, "numa_tonode_memory")));
045ef6
       set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
045ef6
                                                 libnuma_dlsym(handle, "numa_interleave_memory")));
045ef6
+      set_numa_interleave_memory_v2(CAST_TO_FN_PTR(numa_interleave_memory_v2_func_t,
045ef6
+                                                libnuma_v2_dlsym(handle, "numa_interleave_memory")));
045ef6
       set_numa_set_bind_policy(CAST_TO_FN_PTR(numa_set_bind_policy_func_t,
045ef6
                                               libnuma_dlsym(handle, "numa_set_bind_policy")));
045ef6
       set_numa_bitmask_isbitset(CAST_TO_FN_PTR(numa_bitmask_isbitset_func_t,
045ef6
@@ -2975,6 +2980,7 @@
045ef6
 os::Linux::numa_available_func_t os::Linux::_numa_available;
045ef6
 os::Linux::numa_tonode_memory_func_t os::Linux::_numa_tonode_memory;
045ef6
 os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory;
045ef6
+os::Linux::numa_interleave_memory_v2_func_t os::Linux::_numa_interleave_memory_v2;
045ef6
 os::Linux::numa_set_bind_policy_func_t os::Linux::_numa_set_bind_policy;
045ef6
 os::Linux::numa_bitmask_isbitset_func_t os::Linux::_numa_bitmask_isbitset;
045ef6
 os::Linux::numa_distance_func_t os::Linux::_numa_distance;
045ef6
diff -r 74c81011375b src/os/linux/vm/os_linux.hpp
045ef6
--- openjdk/hotspot/src/os/linux/vm/os_linux.hpp	Wed May 17 17:52:34 2017 -0400
045ef6
+++ openjdk/hotspot/src/os/linux/vm/os_linux.hpp	Wed May 31 12:27:00 2017 -0400
045ef6
@@ -1,5 +1,5 @@
045ef6
 /*
045ef6
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
045ef6
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
045ef6
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
045ef6
  *
045ef6
  * This code is free software; you can redistribute it and/or modify it
045ef6
@@ -190,6 +190,9 @@
045ef6
   static void libpthread_init();
045ef6
   static bool libnuma_init();
045ef6
   static void* libnuma_dlsym(void* handle, const char* name);
045ef6
+  // libnuma v2 (libnuma_1.2) symbols
045ef6
+  static void* libnuma_v2_dlsym(void* handle, const char* name);
045ef6
+
045ef6
   // Minimum stack size a thread can be created with (allowing
045ef6
   // the VM to completely create the thread and enter user code)
045ef6
   static size_t min_stack_allowed;
045ef6
@@ -250,6 +253,8 @@
045ef6
   typedef int (*numa_available_func_t)(void);
045ef6
   typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
045ef6
   typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
045ef6
+  typedef void (*numa_interleave_memory_v2_func_t)(void *start, size_t size, struct bitmask* mask);
045ef6
+
045ef6
   typedef void (*numa_set_bind_policy_func_t)(int policy);
045ef6
   typedef int (*numa_bitmask_isbitset_func_t)(struct bitmask *bmp, unsigned int n);
045ef6
   typedef int (*numa_distance_func_t)(int node1, int node2);
045ef6
@@ -261,6 +266,7 @@
045ef6
   static numa_available_func_t _numa_available;
045ef6
   static numa_tonode_memory_func_t _numa_tonode_memory;
045ef6
   static numa_interleave_memory_func_t _numa_interleave_memory;
045ef6
+  static numa_interleave_memory_v2_func_t _numa_interleave_memory_v2;
045ef6
   static numa_set_bind_policy_func_t _numa_set_bind_policy;
045ef6
   static numa_bitmask_isbitset_func_t _numa_bitmask_isbitset;
045ef6
   static numa_distance_func_t _numa_distance;
045ef6
@@ -275,6 +281,7 @@
045ef6
   static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
045ef6
   static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
045ef6
   static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
045ef6
+  static void set_numa_interleave_memory_v2(numa_interleave_memory_v2_func_t func) { _numa_interleave_memory_v2 = func; }
045ef6
   static void set_numa_set_bind_policy(numa_set_bind_policy_func_t func) { _numa_set_bind_policy = func; }
045ef6
   static void set_numa_bitmask_isbitset(numa_bitmask_isbitset_func_t func) { _numa_bitmask_isbitset = func; }
045ef6
   static void set_numa_distance(numa_distance_func_t func) { _numa_distance = func; }
045ef6
@@ -296,7 +303,10 @@
045ef6
     return _numa_tonode_memory != NULL ? _numa_tonode_memory(start, size, node) : -1;
045ef6
   }
045ef6
   static void numa_interleave_memory(void *start, size_t size) {
045ef6
-    if (_numa_interleave_memory != NULL && _numa_all_nodes != NULL) {
045ef6
+    // Use v2 api if available
045ef6
+    if (_numa_interleave_memory_v2 != NULL && _numa_all_nodes_ptr != NULL) {
045ef6
+      _numa_interleave_memory_v2(start, size, _numa_all_nodes_ptr);
045ef6
+    } else if (_numa_interleave_memory != NULL && _numa_all_nodes != NULL) {
045ef6
       _numa_interleave_memory(start, size, _numa_all_nodes);
045ef6
     }
045ef6
   }
045ef6