changeset 58829:b576a0ead397

8237758: ZGC: Move get_mempolicy() syscall wrapper to ZSyscall Reviewed-by: eosterlund
author pliden
date Thu, 30 Jan 2020 12:41:47 +0100
parents e6e4b43ee3ce
children 9c2c9e22c8ba
files src/hotspot/os/linux/gc/z/zNUMA_linux.cpp src/hotspot/os/linux/gc/z/zSyscall_linux.cpp src/hotspot/os/linux/gc/z/zSyscall_linux.hpp src/hotspot/share/gc/z/zPage.inline.hpp
diffstat 4 files changed, 22 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp	Thu Jan 30 12:41:26 2020 +0100
+++ b/src/hotspot/os/linux/gc/z/zNUMA_linux.cpp	Thu Jan 30 12:41:47 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,28 +21,14 @@
  * questions.
  */
 
+#include "gc/z/zCPU.inline.hpp"
 #include "gc/z/zErrno.hpp"
-#include "gc/z/zCPU.inline.hpp"
 #include "gc/z/zNUMA.hpp"
+#include "gc/z/zSyscall_linux.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/os.hpp"
 #include "utilities/debug.hpp"
 
-#include <unistd.h>
-#include <sys/syscall.h>
-
-#ifndef MPOL_F_NODE
-#define MPOL_F_NODE     (1<<0)  // Return next IL mode instead of node mask
-#endif
-
-#ifndef MPOL_F_ADDR
-#define MPOL_F_ADDR     (1<<1)  // Look up VMA using address
-#endif
-
-static int z_get_mempolicy(uint32_t* mode, const unsigned long *nmask, unsigned long maxnode, uintptr_t addr, int flags) {
-  return syscall(SYS_get_mempolicy, mode, nmask, maxnode, addr, flags);
-}
-
 void ZNUMA::initialize_platform() {
   _enabled = UseNUMA;
 }
@@ -73,7 +59,7 @@
 
   uint32_t id = (uint32_t)-1;
 
-  if (z_get_mempolicy(&id, NULL, 0, addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) {
+  if (ZSyscall::get_mempolicy((int*)&id, NULL, 0, (void*)addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) {
     ZErrno err;
     fatal("Failed to get NUMA id for memory at " PTR_FORMAT " (%s)", addr, err.to_string());
   }
--- a/src/hotspot/os/linux/gc/z/zSyscall_linux.cpp	Thu Jan 30 12:41:26 2020 +0100
+++ b/src/hotspot/os/linux/gc/z/zSyscall_linux.cpp	Thu Jan 30 12:41:47 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,3 +34,7 @@
 int ZSyscall::fallocate(int fd, int mode, size_t offset, size_t length) {
   return syscall(SYS_fallocate, fd, mode, offset, length);
 }
+
+long ZSyscall::get_mempolicy(int* mode, unsigned long* nodemask, unsigned long maxnode, void* addr, unsigned long flags) {
+  return syscall(SYS_get_mempolicy, mode, nodemask, maxnode, addr, flags);
+}
--- a/src/hotspot/os/linux/gc/z/zSyscall_linux.hpp	Thu Jan 30 12:41:26 2020 +0100
+++ b/src/hotspot/os/linux/gc/z/zSyscall_linux.hpp	Thu Jan 30 12:41:47 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,10 +26,19 @@
 
 #include "memory/allocation.hpp"
 
+// Flags for get_mempolicy()
+#ifndef MPOL_F_NODE
+#define MPOL_F_NODE        (1<<0)
+#endif
+#ifndef MPOL_F_ADDR
+#define MPOL_F_ADDR        (1<<1)
+#endif
+
 class ZSyscall : public AllStatic {
 public:
-  static int memfd_create(const char *name, unsigned int flags);
+  static int memfd_create(const char* name, unsigned int flags);
   static int fallocate(int fd, int mode, size_t offset, size_t length);
+  static long get_mempolicy(int* mode, unsigned long* nodemask, unsigned long maxnode, void* addr, unsigned long flags);
 };
 
 #endif // OS_LINUX_GC_Z_ZSYSCALL_LINUX_HPP
--- a/src/hotspot/share/gc/z/zPage.inline.hpp	Thu Jan 30 12:41:26 2020 +0100
+++ b/src/hotspot/share/gc/z/zPage.inline.hpp	Thu Jan 30 12:41:47 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -136,7 +136,7 @@
 
 inline uint8_t ZPage::numa_id() {
   if (_numa_id == (uint8_t)-1) {
-    _numa_id = (uint8_t)ZNUMA::memory_id(ZAddress::good(start()));
+    _numa_id = ZNUMA::memory_id(ZAddress::good(start()));
   }
 
   return _numa_id;