author | mdoerr |
Tue, 14 Nov 2017 16:45:27 +0100 | |
changeset 47889 | 839a3b403a5e |
parent 47881 | 0ce0ac68ace7 |
child 48506 | 478e77658965 |
permissions | -rw-r--r-- |
47881 | 1 |
/* |
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "logging/log.hpp" |
|
27 |
#include "runtime/globals.hpp" |
|
28 |
#include "runtime/os.hpp" |
|
29 |
#include "runtime/safepointMechanism.hpp" |
|
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
30 |
#include <sys/mman.h> |
47881 | 31 |
|
32 |
void SafepointMechanism::pd_initialize() { |
|
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
33 |
char* map_address = (char*)MAP_FAILED; |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
34 |
const size_t page_size = os::vm_page_size(); |
47881 | 35 |
// Use optimized addresses for the polling page, |
36 |
// e.g. map it to a special 32-bit address. |
|
37 |
if (OptimizePollingPageLocation) { |
|
38 |
// architecture-specific list of address wishes: |
|
39 |
char* address_wishes[] = { |
|
40 |
// AIX: addresses lower than 0x30000000 don't seem to work on AIX. |
|
41 |
// PPC64: all address wishes are non-negative 32 bit values where |
|
42 |
// the lower 16 bits are all zero. we can load these addresses |
|
43 |
// with a single ppc_lis instruction. |
|
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
44 |
(char*) 0x30000000, (char*) 0x31000000, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
45 |
(char*) 0x32000000, (char*) 0x33000000, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
46 |
(char*) 0x40000000, (char*) 0x41000000, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
47 |
(char*) 0x42000000, (char*) 0x43000000, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
48 |
(char*) 0x50000000, (char*) 0x51000000, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
49 |
(char*) 0x52000000, (char*) 0x53000000, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
50 |
(char*) 0x60000000, (char*) 0x61000000, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
51 |
(char*) 0x62000000, (char*) 0x63000000 |
47881 | 52 |
}; |
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
53 |
int address_wishes_length = sizeof(address_wishes)/sizeof(char*); |
47881 | 54 |
|
55 |
// iterate over the list of address wishes: |
|
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
56 |
for (int i = 0; i < address_wishes_length; i++) { |
47881 | 57 |
// Try to map with current address wish. |
58 |
// AIX: AIX needs MAP_FIXED if we provide an address and mmap will |
|
59 |
// fail if the address is already mapped. |
|
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
60 |
map_address = (char*) ::mmap(address_wishes[i] - (ssize_t)page_size, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
61 |
page_size, PROT_READ, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
62 |
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
63 |
-1, 0); |
47881 | 64 |
log_debug(os)("SafePoint Polling Page address: %p (wish) => %p", |
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
65 |
address_wishes[i], map_address + (ssize_t)page_size); |
47881 | 66 |
|
67 |
if (map_address + (ssize_t)page_size == address_wishes[i]) { |
|
68 |
// Map succeeded and map_address is at wished address, exit loop. |
|
69 |
break; |
|
70 |
} |
|
71 |
||
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
72 |
if (map_address != (char*)MAP_FAILED) { |
47881 | 73 |
// Map succeeded, but polling_page is not at wished address, unmap and continue. |
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
74 |
::munmap(map_address, page_size); |
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
75 |
map_address = (char*)MAP_FAILED; |
47881 | 76 |
} |
77 |
// Map failed, continue loop. |
|
78 |
} |
|
79 |
} |
|
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
80 |
if (map_address == (char*)MAP_FAILED) { |
47881 | 81 |
map_address = os::reserve_memory(page_size, NULL, page_size); |
82 |
} |
|
47889
839a3b403a5e
8191212: AIX: Build and polling page allocation broken after 8189941
mdoerr
parents:
47881
diff
changeset
|
83 |
guarantee(map_address != (char*)MAP_FAILED, "SafepointMechanism::pd_initialize: failed to allocate polling page"); |
47881 | 84 |
os::set_polling_page((address)(map_address)); |
85 |
} |