src/os/linux/vm/os_linux.cpp

Print this page




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




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