forked from pool/openucx
cc6c36d10f
- Update openucx-s390x-support.patch to fix mmap syscall on s390x (bsc#1182691) OBS-URL: https://build.opensuse.org/request/show/874909 OBS-URL: https://build.opensuse.org/package/show/science:HPC/openucx?expand=0&rev=44
434 lines
12 KiB
Diff
434 lines
12 KiB
Diff
commit b47dad27703f0b59072f5a8d8fba99c1d173f8f0
|
|
Author: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
|
|
Date: Thu Aug 9 07:41:24 2018 +0200
|
|
|
|
openucx s390x support
|
|
|
|
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
|
|
|
|
diff --git config/m4/ucm.m4 config/m4/ucm.m4
|
|
index 9c7c820d9fff..8297fc7e6ec2 100644
|
|
--- config/m4/ucm.m4
|
|
+++ config/m4/ucm.m4
|
|
@@ -86,9 +86,20 @@ AC_CHECK_DECLS([SYS_ipc],
|
|
[ipc_hooks_happy=no],
|
|
[#include <sys/syscall.h>])
|
|
|
|
+
|
|
+SAVE_CFLAGS=$CFLAGS
|
|
+CFLAGS="$CLAGS -Isrc/"
|
|
+bistro_arch_happy=yes
|
|
+AC_CHECK_DECLS([ucm_bistro_patch],
|
|
+ [],
|
|
+ [bistro_arch_happy=no],
|
|
+ [#include <ucm/bistro/bistro.h>])
|
|
+CFLAGS=$SAVE_CFLAGS
|
|
+
|
|
AS_IF([test "x$mmap_hooks_happy" = "xyes"],
|
|
AS_IF([test "x$ipc_hooks_happy" = "xyes" -o "x$shm_hooks_happy" = "xyes"],
|
|
- [bistro_hooks_happy=yes]))
|
|
+ AS_IF([test "x$bistro_arch_happy" == "xyes"],
|
|
+ [bistro_hooks_happy=yes])))
|
|
|
|
AS_IF([test "x$bistro_hooks_happy" = "xyes"],
|
|
[AC_DEFINE([UCM_BISTRO_HOOKS], [1], [Enable BISTRO hooks])],
|
|
diff --git src/tools/info/sys_info.c src/tools/info/sys_info.c
|
|
index 88d317670462..04d2c223b970 100644
|
|
--- src/tools/info/sys_info.c
|
|
+++ src/tools/info/sys_info.c
|
|
@@ -38,6 +38,7 @@ static const char* cpu_vendor_names[] = {
|
|
[UCS_CPU_VENDOR_AMD] = "AMD",
|
|
[UCS_CPU_VENDOR_GENERIC_ARM] = "Generic ARM",
|
|
[UCS_CPU_VENDOR_GENERIC_PPC] = "Generic PPC",
|
|
+ [UCS_CPU_VENDOR_GENERIC_IBM] = "Generic IBM",
|
|
[UCS_CPU_VENDOR_FUJITSU_ARM] = "Fujitsu ARM"
|
|
};
|
|
|
|
diff --git src/ucm/Makefile.am src/ucm/Makefile.am
|
|
index e53a30a46916..21bce848045d 100644
|
|
--- src/ucm/Makefile.am
|
|
+++ src/ucm/Makefile.am
|
|
@@ -30,7 +30,8 @@ noinst_HEADERS = \
|
|
bistro/bistro.h \
|
|
bistro/bistro_x86_64.h \
|
|
bistro/bistro_aarch64.h \
|
|
- bistro/bistro_ppc64.h
|
|
+ bistro/bistro_ppc64.h \
|
|
+ bistro/bistro_s390x.h
|
|
|
|
libucm_la_SOURCES = \
|
|
event/event.c \
|
|
diff --git src/ucm/bistro/bistro.h src/ucm/bistro/bistro.h
|
|
index 16e988700c35..b4c2762fb5b2 100644
|
|
--- src/ucm/bistro/bistro.h
|
|
+++ src/ucm/bistro/bistro.h
|
|
@@ -20,6 +20,8 @@ typedef struct ucm_bistro_restore_point ucm_bistro_restore_point_t;
|
|
# include "bistro_aarch64.h"
|
|
#elif defined(__x86_64__)
|
|
# include "bistro_x86_64.h"
|
|
+#elif defined(__s390x__)
|
|
+# include "bistro_s390x.h"
|
|
#else
|
|
# error "Unsupported architecture"
|
|
#endif
|
|
diff --git src/ucm/bistro/bistro_s390x.h src/ucm/bistro/bistro_s390x.h
|
|
new file mode 100644
|
|
index 000000000000..334c0474e8b6
|
|
--- /dev/null
|
|
+++ src/ucm/bistro/bistro_s390x.h
|
|
@@ -0,0 +1,13 @@
|
|
+#ifndef UCM_BISTRO_BISTRO_S390X_H_
|
|
+#define UCM_BISTRO_BISTRO_S390X_H_
|
|
+
|
|
+#include <stdint.h>
|
|
+
|
|
+#include <ucs/type/status.h>
|
|
+#include <ucs/sys/compiler_def.h>
|
|
+
|
|
+#define UCM_BISTRO_PROLOGUE
|
|
+#define UCM_BISTRO_EPILOGUE
|
|
+
|
|
+
|
|
+#endif
|
|
diff --git src/ucm/mmap/install.c src/ucm/mmap/install.c
|
|
index 6b46baaeecfa..522fd6eaa89f 100644
|
|
--- src/ucm/mmap/install.c
|
|
+++ src/ucm/mmap/install.c
|
|
@@ -331,7 +331,11 @@ static ucs_status_t ucs_mmap_install_reloc(int events)
|
|
status = ucm_reloc_modify(&entry->patch);
|
|
} else {
|
|
ucs_assert(ucm_mmap_hook_mode() == UCM_MMAP_HOOK_BISTRO);
|
|
+#if UCM_BISTRO_HOOKS
|
|
status = ucm_bistro_patch(entry->patch.symbol, entry->patch.value, NULL);
|
|
+#else
|
|
+ status = UCS_ERR_UNSUPPORTED;
|
|
+#endif
|
|
}
|
|
if (status != UCS_OK) {
|
|
ucm_warn("failed to install %s hook for '%s'",
|
|
diff --git src/ucs/Makefile.am src/ucs/Makefile.am
|
|
index b612ddeb54ff..6d01521b697b 100644
|
|
--- src/ucs/Makefile.am
|
|
+++ src/ucs/Makefile.am
|
|
@@ -64,6 +64,7 @@ nobase_dist_libucs_la_HEADERS = \
|
|
arch/x86_64/global_opts.h \
|
|
arch/aarch64/global_opts.h \
|
|
arch/ppc64/global_opts.h \
|
|
+ arch/s390x/global_opts.h \
|
|
arch/global_opts.h
|
|
|
|
noinst_HEADERS = \
|
|
@@ -71,6 +72,8 @@ noinst_HEADERS = \
|
|
arch/generic/atomic.h \
|
|
arch/generic/cpu.h \
|
|
arch/ppc64/cpu.h \
|
|
+ arch/s390x/bitops.h \
|
|
+ arch/s390x/cpu.h \
|
|
arch/x86_64/atomic.h \
|
|
arch/x86_64/cpu.h \
|
|
arch/atomic.h \
|
|
@@ -112,6 +115,7 @@ libucs_la_SOURCES = \
|
|
algorithm/qsort_r.c \
|
|
arch/aarch64/cpu.c \
|
|
arch/aarch64/global_opts.c \
|
|
+ arch/s390x/global_opts.c \
|
|
arch/ppc64/timebase.c \
|
|
arch/ppc64/global_opts.c \
|
|
arch/x86_64/cpu.c \
|
|
diff --git src/ucs/arch/atomic.h src/ucs/arch/atomic.h
|
|
index 99e53ca5d0f7..dfa83b757bb0 100644
|
|
--- src/ucs/arch/atomic.h
|
|
+++ src/ucs/arch/atomic.h
|
|
@@ -15,6 +15,8 @@
|
|
# include "generic/atomic.h"
|
|
#elif defined(__aarch64__)
|
|
# include "generic/atomic.h"
|
|
+#elif defined(__s390x__)
|
|
+# include "generic/atomic.h"
|
|
#else
|
|
# error "Unsupported architecture"
|
|
#endif
|
|
diff --git src/ucs/arch/bitops.h src/ucs/arch/bitops.h
|
|
index 10a86b53ca42..80084eea6260 100644
|
|
--- src/ucs/arch/bitops.h
|
|
+++ src/ucs/arch/bitops.h
|
|
@@ -18,6 +18,8 @@ BEGIN_C_DECLS
|
|
# include "ppc64/bitops.h"
|
|
#elif defined(__aarch64__)
|
|
# include "aarch64/bitops.h"
|
|
+#elif defined(__s390x__)
|
|
+# include "s390x/bitops.h"
|
|
#else
|
|
# error "Unsupported architecture"
|
|
#endif
|
|
diff --git src/ucs/arch/cpu.c src/ucs/arch/cpu.c
|
|
index 6d9ebbafeaed..5cda2179efca 100644
|
|
--- src/ucs/arch/cpu.c
|
|
+++ src/ucs/arch/cpu.c
|
|
@@ -60,6 +60,10 @@ const ucs_cpu_builtin_memcpy_t ucs_cpu_builtin_memcpy[UCS_CPU_VENDOR_LAST] = {
|
|
.min = UCS_MEMUNITS_INF,
|
|
.max = UCS_MEMUNITS_INF
|
|
},
|
|
+ [UCS_CPU_VENDOR_GENERIC_IBM] = {
|
|
+ .min = UCS_MEMUNITS_INF,
|
|
+ .max = UCS_MEMUNITS_INF
|
|
+ },
|
|
[UCS_CPU_VENDOR_FUJITSU_ARM] = {
|
|
.min = UCS_MEMUNITS_INF,
|
|
.max = UCS_MEMUNITS_INF
|
|
@@ -72,6 +76,7 @@ const size_t ucs_cpu_est_bcopy_bw[UCS_CPU_VENDOR_LAST] = {
|
|
[UCS_CPU_VENDOR_AMD] = 5008 * UCS_MBYTE,
|
|
[UCS_CPU_VENDOR_GENERIC_ARM] = 5800 * UCS_MBYTE,
|
|
[UCS_CPU_VENDOR_GENERIC_PPC] = 5800 * UCS_MBYTE,
|
|
+ [UCS_CPU_VENDOR_GENERIC_IBM] = 5800 * UCS_MBYTE,
|
|
[UCS_CPU_VENDOR_FUJITSU_ARM] = 5800 * UCS_MBYTE
|
|
};
|
|
|
|
diff --git src/ucs/arch/cpu.h src/ucs/arch/cpu.h
|
|
index cb317a8db3a4..5174eeb7e1db 100644
|
|
--- src/ucs/arch/cpu.h
|
|
+++ src/ucs/arch/cpu.h
|
|
@@ -58,6 +58,7 @@ typedef enum ucs_cpu_vendor {
|
|
UCS_CPU_VENDOR_AMD,
|
|
UCS_CPU_VENDOR_GENERIC_ARM,
|
|
UCS_CPU_VENDOR_GENERIC_PPC,
|
|
+ UCS_CPU_VENDOR_GENERIC_IBM,
|
|
UCS_CPU_VENDOR_FUJITSU_ARM,
|
|
UCS_CPU_VENDOR_LAST
|
|
} ucs_cpu_vendor_t;
|
|
@@ -92,6 +93,8 @@ typedef struct ucs_cpu_builtin_memcpy {
|
|
# include "ppc64/cpu.h"
|
|
#elif defined(__aarch64__)
|
|
# include "aarch64/cpu.h"
|
|
+#elif defined(__s390x__)
|
|
+# include "s390x/cpu.h"
|
|
#else
|
|
# error "Unsupported architecture"
|
|
#endif
|
|
diff --git src/ucs/arch/global_opts.h src/ucs/arch/global_opts.h
|
|
index 8786f130290a..0d251fb91868 100644
|
|
--- src/ucs/arch/global_opts.h
|
|
+++ src/ucs/arch/global_opts.h
|
|
@@ -15,6 +15,8 @@
|
|
# include "ppc64/global_opts.h"
|
|
#elif defined(__aarch64__)
|
|
# include "aarch64/global_opts.h"
|
|
+#elif defined(__s390x__)
|
|
+# include "s390x/global_opts.h"
|
|
#else
|
|
# error "Unsupported architecture"
|
|
#endif
|
|
diff --git src/ucs/arch/s390x/bitops.h src/ucs/arch/s390x/bitops.h
|
|
new file mode 100644
|
|
index 000000000000..39ad125107e9
|
|
--- /dev/null
|
|
+++ src/ucs/arch/s390x/bitops.h
|
|
@@ -0,0 +1,32 @@
|
|
+/**
|
|
+* Copyright (C) Mellanox Technologies Ltd. 2001-2015. ALL RIGHTS RESERVED.
|
|
+*
|
|
+* See file LICENSE for terms.
|
|
+*/
|
|
+
|
|
+#ifndef UCS_S390X_BITOPS_H_
|
|
+#define UCS_S390X_BITOPS_H_
|
|
+
|
|
+#include <stdint.h>
|
|
+
|
|
+
|
|
+static inline unsigned __ucs_ilog2_u32(uint32_t n)
|
|
+{
|
|
+ if (!n)
|
|
+ return 0;
|
|
+ return 31 - __builtin_clz(n);
|
|
+}
|
|
+
|
|
+static inline unsigned __ucs_ilog2_u64(uint64_t n)
|
|
+{
|
|
+ if (!n)
|
|
+ return 0;
|
|
+ return 63 - __builtin_clz(n);
|
|
+}
|
|
+
|
|
+static inline unsigned ucs_ffs64(uint64_t n)
|
|
+{
|
|
+ return __ucs_ilog2_u64(n & -n);
|
|
+}
|
|
+
|
|
+#endif
|
|
diff --git src/ucs/arch/s390x/cpu.h src/ucs/arch/s390x/cpu.h
|
|
new file mode 100644
|
|
index 000000000000..4f0a87006118
|
|
--- /dev/null
|
|
+++ src/ucs/arch/s390x/cpu.h
|
|
@@ -0,0 +1,84 @@
|
|
+/**
|
|
+* Copyright (C) Mellanox Technologies Ltd. 2001-2013. ALL RIGHTS RESERVED.
|
|
+* Copyright (C) ARM Ltd. 2016-2017. ALL RIGHTS RESERVED.
|
|
+*
|
|
+* See file LICENSE for terms.
|
|
+*/
|
|
+
|
|
+
|
|
+#ifndef UCS_S390X_CPU_H_
|
|
+#define UCS_S390X_CPU_H_
|
|
+
|
|
+#include <ucs/sys/compiler.h>
|
|
+#include <ucs/arch/generic/cpu.h>
|
|
+#include <stdint.h>
|
|
+#include <string.h>
|
|
+#include <ucs/type/status.h>
|
|
+
|
|
+
|
|
+#define UCS_ARCH_CACHE_LINE_SIZE 256
|
|
+
|
|
+BEGIN_C_DECLS
|
|
+
|
|
+/* Assume the worst - weak memory ordering */
|
|
+#define ucs_memory_bus_fence() asm volatile (""::: "memory")
|
|
+#define ucs_memory_bus_store_fence() ucs_memory_bus_fence()
|
|
+#define ucs_memory_bus_load_fence() ucs_memory_bus_fence()
|
|
+#define ucs_memory_bus_wc_flush() ucs_memory_bus_fence()
|
|
+#define ucs_memory_cpu_fence() ucs_memory_bus_fence()
|
|
+#define ucs_memory_cpu_store_fence() ucs_memory_bus_fence()
|
|
+#define ucs_memory_cpu_load_fence() ucs_memory_bus_fence()
|
|
+#define ucs_memory_cpu_wc_fence() ucs_memory_bus_fence()
|
|
+
|
|
+
|
|
+static inline uint64_t ucs_arch_read_hres_clock()
|
|
+{
|
|
+ unsigned long clk;
|
|
+ asm volatile("stck %0" : "=Q" (clk) : : "cc");
|
|
+ return clk >> 2;
|
|
+}
|
|
+#define ucs_arch_get_clocks_per_sec ucs_arch_generic_get_clocks_per_sec
|
|
+
|
|
+
|
|
+static inline ucs_cpu_model_t ucs_arch_get_cpu_model()
|
|
+{
|
|
+ return UCS_CPU_MODEL_UNKNOWN;
|
|
+}
|
|
+
|
|
+static inline ucs_cpu_vendor_t ucs_arch_get_cpu_vendor()
|
|
+{
|
|
+ return UCS_CPU_VENDOR_GENERIC_IBM;
|
|
+}
|
|
+
|
|
+static inline int ucs_arch_get_cpu_flag()
|
|
+{
|
|
+ return UCS_CPU_FLAG_UNKNOWN;
|
|
+}
|
|
+
|
|
+double ucs_arch_get_clocks_per_sec();
|
|
+
|
|
+#define ucs_arch_wait_mem ucs_arch_generic_wait_mem
|
|
+
|
|
+static inline void ucs_cpu_init()
|
|
+{
|
|
+}
|
|
+
|
|
+static inline void *ucs_memcpy_relaxed(void *dst, const void *src, size_t len)
|
|
+{
|
|
+ return memcpy(dst, src, len);
|
|
+}
|
|
+
|
|
+static UCS_F_ALWAYS_INLINE void
|
|
+ucs_memcpy_nontemporal(void *dst, const void *src, size_t len)
|
|
+{
|
|
+ memcpy(dst, src, len);
|
|
+}
|
|
+
|
|
+static inline ucs_status_t ucs_arch_get_cache_size(size_t *cache_sizes)
|
|
+{
|
|
+ return UCS_ERR_UNSUPPORTED;
|
|
+}
|
|
+
|
|
+END_C_DECLS
|
|
+
|
|
+#endif
|
|
diff --git src/ucs/arch/s390x/global_opts.c src/ucs/arch/s390x/global_opts.c
|
|
new file mode 100644
|
|
index 000000000000..4fa0c74034a7
|
|
--- /dev/null
|
|
+++ src/ucs/arch/s390x/global_opts.c
|
|
@@ -0,0 +1,24 @@
|
|
+/**
|
|
+* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED.
|
|
+*
|
|
+* See file LICENSE for terms.
|
|
+*/
|
|
+
|
|
+#if defined(__s390x__)
|
|
+
|
|
+#ifdef HAVE_CONFIG_H
|
|
+# include "config.h"
|
|
+#endif
|
|
+
|
|
+#include <ucs/arch/global_opts.h>
|
|
+#include <ucs/config/parser.h>
|
|
+
|
|
+ucs_config_field_t ucs_arch_global_opts_table[] = {
|
|
+ {NULL}
|
|
+};
|
|
+
|
|
+void ucs_arch_print_memcpy_limits(ucs_arch_global_opts_t *config)
|
|
+{
|
|
+}
|
|
+
|
|
+#endif
|
|
diff --git src/ucs/arch/s390x/global_opts.h src/ucs/arch/s390x/global_opts.h
|
|
new file mode 100644
|
|
index 000000000000..225e4e5e896a
|
|
--- /dev/null
|
|
+++ src/ucs/arch/s390x/global_opts.h
|
|
@@ -0,0 +1,25 @@
|
|
+/**
|
|
+* Copyright (C) Mellanox Technologies Ltd. 2019. ALL RIGHTS RESERVED.
|
|
+*
|
|
+* See file LICENSE for terms.
|
|
+*/
|
|
+
|
|
+
|
|
+#ifndef UCS_PPC64_GLOBAL_OPTS_H_
|
|
+#define UCS_PPC64_GLOBAL_OPTS_H_
|
|
+
|
|
+#include <ucs/sys/compiler_def.h>
|
|
+
|
|
+BEGIN_C_DECLS
|
|
+
|
|
+#define UCS_ARCH_GLOBAL_OPTS_INITALIZER {}
|
|
+
|
|
+/* built-in memcpy config */
|
|
+typedef struct ucs_arch_global_opts {
|
|
+ char dummy;
|
|
+} ucs_arch_global_opts_t;
|
|
+
|
|
+END_C_DECLS
|
|
+
|
|
+#endif
|
|
+
|
|
diff --git src/ucs/sys/sys.c src/ucs/sys/sys.c
|
|
index 62e555b409d1..8adc26241781 100644
|
|
--- src/ucs/sys/sys.c
|
|
+++ src/ucs/sys/sys.c
|
|
@@ -1134,8 +1134,19 @@ void *ucs_sys_realloc(void *old_ptr, size_t old_length, size_t new_length)
|
|
if (old_ptr == NULL) {
|
|
/* Note: Must pass the 0 offset as "long", otherwise it will be
|
|
* partially undefined when converted to syscall arguments */
|
|
+#if defined(__s390x__)
|
|
+ long int _args[6] = {
|
|
+ (long int) NULL,
|
|
+ (long int) new_length,
|
|
+ (long int) PROT_READ|PROT_WRITE,
|
|
+ (long int) MAP_PRIVATE|MAP_ANONYMOUS,
|
|
+ (long int) -1,
|
|
+ (long int) 0ul};
|
|
+ ptr = (void*)syscall(__NR_mmap, _args);
|
|
+#else
|
|
ptr = (void*)syscall(__NR_mmap, NULL, new_length, PROT_READ|PROT_WRITE,
|
|
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0ul);
|
|
+#endif
|
|
if (ptr == MAP_FAILED) {
|
|
ucs_log_fatal_error("mmap(NULL, %zu, READ|WRITE, PRIVATE|ANON) failed: %m",
|
|
new_length);
|