8075505: aix: improve handling of native memory

Reviewed-by: kvn, stuefe
This commit is contained in:
Thomas Stuefe 2015-03-19 14:30:52 +01:00 committed by Goetz Lindenmaier
parent 12008d9c8f
commit addb7b0b0f
9 changed files with 911 additions and 1006 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2013 SAP AG. All rights reserved. * Copyright 2012, 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -144,6 +144,10 @@ class ArgumentIterator : public StackObj {
} }
char* next() { char* next() {
if (*_pos == '\0') { if (*_pos == '\0') {
if (_pos < _end) {
_pos += 1;
}
return NULL; return NULL;
} }
char* res = _pos; char* res = _pos;
@ -214,6 +218,7 @@ int AixAttachListener::init() {
// bind socket // bind socket
struct sockaddr_un addr; struct sockaddr_un addr;
memset((void *)&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, initial_path); strcpy(addr.sun_path, initial_path);
::unlink(initial_path); ::unlink(initial_path);

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2013 SAP AG. All rights reserved. * Copyright 2012, 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,10 @@
// //
#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct) \ #define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct) \
\ \
/* Use 64K pages for virtual memory (shmat). */ \
product(bool, Use64KPages, true, \
"Use 64K pages if available.") \
\
/* If UseLargePages == true allow or deny usage of 16M pages. 16M pages are */ \ /* If UseLargePages == true allow or deny usage of 16M pages. 16M pages are */ \
/* a scarce resource and there may be situations where we do not want the VM */ \ /* a scarce resource and there may be situations where we do not want the VM */ \
/* to run with 16M pages. (Will fall back to 64K pages). */ \ /* to run with 16M pages. (Will fall back to 64K pages). */ \
@ -55,7 +59,7 @@ define_pd_global(intx, AttachListenerTimeout, 1000);
// Defines Aix-specific default values. The flags are available on all // Defines Aix-specific default values. The flags are available on all
// platforms, but they may have different default values on other platforms. // platforms, but they may have different default values on other platforms.
// //
define_pd_global(bool, UseLargePages, true); define_pd_global(bool, UseLargePages, false);
define_pd_global(bool, UseLargePagesIndividualAllocation, false); define_pd_global(bool, UseLargePagesIndividualAllocation, false);
define_pd_global(bool, UseOSErrorReporting, false); define_pd_global(bool, UseOSErrorReporting, false);
define_pd_global(bool, UseThreadPriorities, true) ; define_pd_global(bool, UseThreadPriorities, true) ;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2013 SAP AG. All rights reserved. * Copyright 2012, 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,8 +23,8 @@
* *
*/ */
#ifndef OS_LINUX_VM_INTERFACESUPPORT_LINUX_HPP #ifndef OS_AIX_VM_INTERFACESUPPORT_AIX_HPP
#define OS_LINUX_VM_INTERFACESUPPORT_LINUX_HPP #define OS_AIX_VM_INTERFACESUPPORT_AIX_HPP
// Contains inlined functions for class InterfaceSupport // Contains inlined functions for class InterfaceSupport
@ -32,4 +32,4 @@ static inline void serialize_memory(JavaThread *thread) {
os::write_memory_serialize_page(thread); os::write_memory_serialize_page(thread);
} }
#endif // OS_LINUX_VM_INTERFACESUPPORT_LINUX_HPP #endif // OS_AIX_VM_INTERFACESUPPORT_AIX_HPP

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2013 SAP AG. All rights reserved. * Copyright 2012, 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@ void OSThread::pd_initialize() {
_startThread_lock = new Monitor(Mutex::event, "startThread_lock", true, _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true,
Monitor::_safepoint_check_never); Monitor::_safepoint_check_never);
assert(_startThread_lock !=NULL, "check"); assert(_startThread_lock != NULL, "check");
} }
void OSThread::pd_destroy() { void OSThread::pd_destroy() {

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013 SAP AG. All rights reserved. * Copyright 2013, 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,9 +35,9 @@ class Aix {
friend class os; friend class os;
// For signal-chaining // For signal-chaining
// highest so far (AIX 5.2) is SIGSAK (63) // highest so far (AIX 5.2 - 6.1) is SIGSAK (63)
#define MAXSIGNUM 63 #define MAXSIGNUM 63
// length of strings included in the libperfstat structures // Length of strings included in the libperfstat structures.
#define IDENTIFIER_LENGTH 64 #define IDENTIFIER_LENGTH 64
static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
@ -111,22 +111,6 @@ class Aix {
// (should be LDR_CNTRL DATAPSIZE because stack is allocated on heap by pthread lib) // (should be LDR_CNTRL DATAPSIZE because stack is allocated on heap by pthread lib)
static int _stack_page_size; static int _stack_page_size;
// Default shm page size. Read: what page size shared memory will be backed
// with if no page size was set explicitly using shmctl(SHM_PAGESIZE).
// Should be LDR_CNTRL SHMPSIZE.
static size_t _shm_default_page_size;
// True if sys V shm can be used with 64K pages dynamically.
// (via shmctl(.. SHM_PAGESIZE..). Should be true for AIX 53 and
// newer / PASE V6R1 and newer. (0 or 1, -1 if not initialized)
static int _can_use_64K_pages;
// True if sys V shm can be used with 16M pages dynamically.
// (via shmctl(.. SHM_PAGESIZE..). Only true on AIX 5.3 and
// newer, if the system was set up to use 16M pages and the
// jvm has enough user rights. (0 or 1, -1 if not initialized)
static int _can_use_16M_pages;
static julong available_memory(); static julong available_memory();
static julong physical_memory() { return _physical_memory; } static julong physical_memory() { return _physical_memory; }
static void initialize_system_info(); static void initialize_system_info();
@ -135,10 +119,6 @@ class Aix {
// one of Aix::on_pase(), Aix::os_version(). // one of Aix::on_pase(), Aix::os_version().
static void initialize_os_info(); static void initialize_os_info();
static int commit_memory_impl(char* addr, size_t bytes, bool exec);
static int commit_memory_impl(char* addr, size_t bytes,
size_t alignment_hint, bool exec);
// Scan environment for important settings which might effect the // Scan environment for important settings which might effect the
// VM. Trace out settings. Warn about invalid settings and/or // VM. Trace out settings. Warn about invalid settings and/or
// correct them. // correct them.
@ -146,10 +126,6 @@ class Aix {
// Must run after os::Aix::initialue_os_info(). // Must run after os::Aix::initialue_os_info().
static void scan_environment(); static void scan_environment();
// Retrieve information about multipage size support. Will initialize
// _page_size, _stack_page_size, _can_use_64K_pages/_can_use_16M_pages
static void query_multipage_support();
// Initialize libo4 (on PASE) and libperfstat (on AIX). Call this // Initialize libo4 (on PASE) and libperfstat (on AIX). Call this
// before relying on functions from either lib, e.g. Aix::get_meminfo(). // before relying on functions from either lib, e.g. Aix::get_meminfo().
static void initialize_libo4(); static void initialize_libo4();
@ -187,27 +163,8 @@ class Aix {
return _stack_page_size; return _stack_page_size;
} }
// default shm page size. Read: what page size shared memory // This is used to scale stack space (guard pages etc.). The name is somehow misleading.
// will be backed with if no page size was set explicitly using shmctl(SHM_PAGESIZE). static int vm_default_page_size(void ) { return 8*K; }
// Should be LDR_CNTRL SHMPSIZE.
static int shm_default_page_size(void) {
assert(_shm_default_page_size != -1, "not initialized");
return _shm_default_page_size;
}
// Return true if sys V shm can be used with 64K pages dynamically
// (via shmctl(.. SHM_PAGESIZE..).
static bool can_use_64K_pages () {
assert(_can_use_64K_pages != -1, "not initialized");
return _can_use_64K_pages == 1 ? true : false;
}
// Return true if sys V shm can be used with 16M pages dynamically.
// (via shmctl(.. SHM_PAGESIZE..).
static bool can_use_16M_pages () {
assert(_can_use_16M_pages != -1, "not initialized");
return _can_use_16M_pages == 1 ? true : false;
}
static address ucontext_get_pc(const ucontext_t* uc); static address ucontext_get_pc(const ucontext_t* uc);
static intptr_t* ucontext_get_sp(ucontext_t* uc); static intptr_t* ucontext_get_sp(ucontext_t* uc);
@ -269,6 +226,11 @@ class Aix {
return _os_version; return _os_version;
} }
// Convenience method: returns true if running on PASE V5R4 or older.
static bool on_pase_V5R4_or_older() {
return on_pase() && os_version() <= 0x0504;
}
// Convenience method: returns true if running on AIX 5.3 or older. // Convenience method: returns true if running on AIX 5.3 or older.
static bool on_aix_53_or_older() { static bool on_aix_53_or_older() {
return on_aix() && os_version() <= 0x0503; return on_aix() && os_version() <= 0x0503;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2013 SAP AG. All rights reserved. * Copyright 2012, 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,7 @@ inline void* os::thread_local_storage_at(int index) {
return pthread_getspecific((pthread_key_t)index); return pthread_getspecific((pthread_key_t)index);
} }
// File names are case-sensitive on windows only // File names are case-sensitive on windows only.
inline int os::file_name_strcmp(const char* s1, const char* s2) { inline int os::file_name_strcmp(const char* s1, const char* s2) {
return strcmp(s1, s2); return strcmp(s1, s2);
} }
@ -53,18 +53,19 @@ inline bool os::uses_stack_guard_pages() {
return true; return true;
} }
// Whether or not calling code should/can commit/uncommit stack pages
// before guarding them. Answer for AIX is definitly no, because memory
// is automatically committed on touch.
inline bool os::allocate_stack_guard_pages() { inline bool os::allocate_stack_guard_pages() {
assert(uses_stack_guard_pages(), "sanity check"); assert(uses_stack_guard_pages(), "sanity check");
return true; return false;
} }
// On Aix, reservations are made on a page by page basis, nothing to do. // On Aix, reservations are made on a page by page basis, nothing to do.
inline void os::pd_split_reserved_memory(char *base, size_t size, inline void os::pd_split_reserved_memory(char *base, size_t size,
size_t split, bool realloc) { size_t split, bool realloc) {
} }
// Bang the shadow pages if they need to be touched to be mapped. // Bang the shadow pages if they need to be touched to be mapped.
inline void os::bang_stack_shadow_pages() { inline void os::bang_stack_shadow_pages() {
} }
@ -75,15 +76,13 @@ inline void os::dll_unload(void *lib) {
inline const int os::default_file_open_flags() { return 0;} inline const int os::default_file_open_flags() { return 0;}
inline DIR* os::opendir(const char* dirname) inline DIR* os::opendir(const char* dirname) {
{
assert(dirname != NULL, "just checking"); assert(dirname != NULL, "just checking");
return ::opendir(dirname); return ::opendir(dirname);
} }
inline int os::readdir_buf_size(const char *path) inline int os::readdir_buf_size(const char *path) {
{ // According to aix sys/limits, NAME_MAX must be retrieved at runtime.
// according to aix sys/limits, NAME_MAX must be retrieved at runtime. */
const long my_NAME_MAX = pathconf(path, _PC_NAME_MAX); const long my_NAME_MAX = pathconf(path, _PC_NAME_MAX);
return my_NAME_MAX + sizeof(dirent) + 1; return my_NAME_MAX + sizeof(dirent) + 1;
} }
@ -104,8 +103,7 @@ inline int os::ftruncate(int fd, jlong length) {
return ::ftruncate64(fd, length); return ::ftruncate64(fd, length);
} }
inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf) {
{
dirent* p; dirent* p;
int status; int status;
assert(dirp != NULL, "just checking"); assert(dirp != NULL, "just checking");
@ -174,11 +172,11 @@ inline int os::send(int fd, char* buf, size_t nBytes, uint flags) {
RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
} }
inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { inline int os::raw_send(int fd, char *buf, size_t nBytes, uint flags) {
return os::send(fd, buf, nBytes, flags); return os::send(fd, buf, nBytes, flags);
} }
inline int os::connect(int fd, struct sockaddr* him, socklen_t len) { inline int os::connect(int fd, struct sockaddr *him, socklen_t len) {
RESTARTABLE_RETURN_INT(::connect(fd, him, len)); RESTARTABLE_RETURN_INT(::connect(fd, him, len));
} }

View File

@ -797,7 +797,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
// Close the directory and reset the current working directory. // Close the directory and reset the current working directory.
close_directory_secure_cwd(dirp, saved_cwd_fd); close_directory_secure_cwd(dirp, saved_cwd_fd);
FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); FREE_C_HEAP_ARRAY(char, dbuf);
} }
// Make the user specific temporary directory. Returns true if // Make the user specific temporary directory. Returns true if
@ -1164,9 +1164,9 @@ static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemor
// store file, we don't follow them when attaching either. // store file, we don't follow them when attaching either.
// //
if (!is_directory_secure(dirname)) { if (!is_directory_secure(dirname)) {
FREE_C_HEAP_ARRAY(char, dirname, mtInternal); FREE_C_HEAP_ARRAY(char, dirname);
if (luser != user) { if (luser != user) {
FREE_C_HEAP_ARRAY(char, luser, mtInternal); FREE_C_HEAP_ARRAY(char, luser);
} }
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Process not found"); "Process not found");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012, 2013 SAP AG. All rights reserved. * Copyright 2012, 2015 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -22,8 +22,18 @@
* *
*/ */
#ifndef OS_AIX_VM_PORTING_AIX_HPP
#define OS_AIX_VM_PORTING_AIX_HPP
#include <stddef.h> #include <stddef.h>
// PPC port only:
#define assert0(b) assert( (b), "" )
#define guarantee0(b) assert( (b), "" )
template <class T1, class T2> bool is_aligned_to(T1 what, T2 alignment) {
return ( ((uintx)(what)) & (((uintx)(alignment)) - 1) ) == 0 ? true : false;
}
// Header file to contain porting-relevant code which does not have a // Header file to contain porting-relevant code which does not have a
// home anywhere else and which can not go into os_<platform>.h because // home anywhere else and which can not go into os_<platform>.h because
// that header is included inside the os class definition, hence all // that header is included inside the os class definition, hence all
@ -79,3 +89,62 @@ int getFuncName(
const struct tbtable** p_tb, // [out] optional: ptr to traceback table to get further information const struct tbtable** p_tb, // [out] optional: ptr to traceback table to get further information
char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages
); );
// -------------------------------------------------------------------------
// A simple critical section which shall be based upon OS critical
// sections (CRITICAL_SECTION resp. Posix Mutex) and nothing else.
#include <pthread.h>
namespace MiscUtils {
typedef pthread_mutex_t critsect_t;
inline void init_critsect(MiscUtils::critsect_t* cs) {
pthread_mutex_init(cs, NULL);
}
inline void free_critsect(MiscUtils::critsect_t* cs) {
pthread_mutex_destroy(cs);
}
inline void enter_critsect(MiscUtils::critsect_t* cs) {
pthread_mutex_lock(cs);
}
inline void leave_critsect(MiscUtils::critsect_t* cs) {
pthread_mutex_unlock(cs);
}
// Need to wrap this in an object because we need to dynamically initialize
// critical section (because of windows, where there is no way to initialize
// a CRITICAL_SECTION statically. On Unix, we could use
// PTHREAD_MUTEX_INITIALIZER)
// Note: The critical section does NOT get cleaned up in the destructor. That is
// by design: the CritSect class is only ever used as global objects whose
// lifetime spans the whole VM life; in that context we don't want the lock to
// be cleaned up when global C++ objects are destroyed, but to continue to work
// correctly right to the very end of the process life.
class CritSect {
critsect_t _cs;
public:
CritSect() { init_critsect(&_cs); }
//~CritSect() { free_critsect(&_cs); }
void enter() { enter_critsect(&_cs); }
void leave() { leave_critsect(&_cs); }
};
class AutoCritSect {
CritSect* const _pcsobj;
public:
AutoCritSect(CritSect* pcsobj)
: _pcsobj(pcsobj)
{
_pcsobj->enter();
}
~AutoCritSect() {
_pcsobj->leave();
}
};
}
#endif // OS_AIX_VM_PORTING_AIX_HPP