1 /*
2 * Copyright (c) 1999, 2013, 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 *
2982 os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory;
2983 os::Linux::numa_set_bind_policy_func_t os::Linux::_numa_set_bind_policy;
2984 unsigned long* os::Linux::_numa_all_nodes;
2985
2986 bool os::pd_uncommit_memory(char* addr, size_t size) {
2987 uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
2988 MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);
2989 return res != (uintptr_t) MAP_FAILED;
2990 }
2991
2992 static
2993 address get_stack_commited_bottom(address bottom, size_t size) {
2994 address nbot = bottom;
2995 address ntop = bottom + size;
2996
2997 size_t page_sz = os::vm_page_size();
2998 unsigned pages = size / page_sz;
2999
3000 unsigned char vec[1];
3001 unsigned imin = 1, imax = pages + 1, imid;
3002 int mincore_return_value;
3003
3004 while (imin < imax) {
3005 imid = (imax + imin) / 2;
3006 nbot = ntop - (imid * page_sz);
3007
3008 // Use a trick with mincore to check whether the page is mapped or not.
3009 // mincore sets vec to 1 if page resides in memory and to 0 if page
3010 // is swapped output but if page we are asking for is unmapped
3011 // it returns -1,ENOMEM
3012 mincore_return_value = mincore(nbot, page_sz, vec);
3013
3014 if (mincore_return_value == -1) {
3015 // Page is not mapped go up
3016 // to find first mapped page
3017 if (errno != EAGAIN) {
3018 assert(errno == ENOMEM, "Unexpected mincore errno");
3019 imax = imid;
3020 }
3021 } else {
3022 // Page is mapped go down
3023 // to find first not mapped page
|
1 /*
2 * Copyright (c) 1999, 2014, 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 *
2982 os::Linux::numa_interleave_memory_func_t os::Linux::_numa_interleave_memory;
2983 os::Linux::numa_set_bind_policy_func_t os::Linux::_numa_set_bind_policy;
2984 unsigned long* os::Linux::_numa_all_nodes;
2985
2986 bool os::pd_uncommit_memory(char* addr, size_t size) {
2987 uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
2988 MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);
2989 return res != (uintptr_t) MAP_FAILED;
2990 }
2991
2992 static
2993 address get_stack_commited_bottom(address bottom, size_t size) {
2994 address nbot = bottom;
2995 address ntop = bottom + size;
2996
2997 size_t page_sz = os::vm_page_size();
2998 unsigned pages = size / page_sz;
2999
3000 unsigned char vec[1];
3001 unsigned imin = 1, imax = pages + 1, imid;
3002 int mincore_return_value = 0;
3003
3004 assert(imin < imax, "Unexpected page size");
3005
3006 while (imin < imax) {
3007 imid = (imax + imin) / 2;
3008 nbot = ntop - (imid * page_sz);
3009
3010 // Use a trick with mincore to check whether the page is mapped or not.
3011 // mincore sets vec to 1 if page resides in memory and to 0 if page
3012 // is swapped output but if page we are asking for is unmapped
3013 // it returns -1,ENOMEM
3014 mincore_return_value = mincore(nbot, page_sz, vec);
3015
3016 if (mincore_return_value == -1) {
3017 // Page is not mapped go up
3018 // to find first mapped page
3019 if (errno != EAGAIN) {
3020 assert(errno == ENOMEM, "Unexpected mincore errno");
3021 imax = imid;
3022 }
3023 } else {
3024 // Page is mapped go down
3025 // to find first not mapped page
|