Skip to content
Permalink
Browse files

8237758: ZGC: Move get_mempolicy() syscall wrapper to ZSyscall

Reviewed-by: eosterlund
  • Loading branch information
pliden committed Jan 30, 2020
1 parent 91d58b8 commit 24691f248c64dfd6e88750d80c1f98adc6e4697a
@@ -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/zErrno.hpp"
#include "gc/z/zCPU.inline.hpp"
#include "gc/z/zErrno.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 ZNUMA::memory_id(uintptr_t addr) {

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());
}
@@ -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::memfd_create(const char *name, unsigned int flags) {
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);
}
@@ -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
@@ -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 const ZVirtualMemory& ZPage::virtual_memory() const {

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;

0 comments on commit 24691f2

Please sign in to comment.