1 /* 2 * Copyright (c) 2015, 2019, 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 #include "precompiled.hpp" 25 #include "gc/z/zArray.inline.hpp" 26 #include "gc/z/zBackingFile_linux.hpp" 27 #include "gc/z/zBackingPath_linux.hpp" 28 #include "gc/z/zErrno.hpp" 29 #include "gc/z/zGlobals.hpp" 30 #include "gc/z/zLargePages.inline.hpp" 31 #include "gc/z/zSyscall_linux.hpp" 32 #include "logging/log.hpp" 33 #include "runtime/init.hpp" 34 #include "runtime/os.hpp" 35 #include "utilities/align.hpp" 36 #include "utilities/debug.hpp" 37 38 #include <fcntl.h> 39 #include <stdio.h> 40 #include <sys/mman.h> 41 #include <sys/stat.h> 42 #include <sys/statfs.h> 43 #include <sys/types.h> 44 #include <unistd.h> 45 46 // 47 // Support for building on older Linux systems 48 // 49 50 // memfd_create(2) flags 51 #ifndef MFD_CLOEXEC 52 #define MFD_CLOEXEC 0x0001U 53 #endif 54 #ifndef MFD_HUGETLB 55 #define MFD_HUGETLB 0x0004U 56 #endif 57 58 // open(2) flags 59 #ifndef O_CLOEXEC 60 #define O_CLOEXEC 02000000 61 #endif 62 #ifndef O_TMPFILE 63 #define O_TMPFILE (020000000 | O_DIRECTORY) 64 #endif 65 66 // fallocate(2) flags 67 #ifndef FALLOC_FL_KEEP_SIZE 68 #define FALLOC_FL_KEEP_SIZE 0x01 69 #endif 70 #ifndef FALLOC_FL_PUNCH_HOLE 71 #define FALLOC_FL_PUNCH_HOLE 0x02 72 #endif 73 74 // Filesystem types, see statfs(2) 75 #ifndef TMPFS_MAGIC 76 #define TMPFS_MAGIC 0x01021994 77 #endif 78 #ifndef HUGETLBFS_MAGIC 79 #define HUGETLBFS_MAGIC 0x958458f6 80 #endif 81 82 // Filesystem names 83 #define ZFILESYSTEM_TMPFS "tmpfs" 84 #define ZFILESYSTEM_HUGETLBFS "hugetlbfs" 85 86 // Proc file entry for max map mount 87 #define ZFILENAME_PROC_MAX_MAP_COUNT "/proc/sys/vm/max_map_count" 88 89 // Sysfs file for transparent huge page on tmpfs 90 #define ZFILENAME_SHMEM_ENABLED "/sys/kernel/mm/transparent_hugepage/shmem_enabled" 91 92 // Java heap filename 93 #define ZFILENAME_HEAP "java_heap" 94 95 // Preferred tmpfs mount points, ordered by priority 96 static const char* z_preferred_tmpfs_mountpoints[] = { 97 "/dev/shm", 98 "/run/shm", 99 NULL 100 }; 101 102 // Preferred hugetlbfs mount points, ordered by priority 103 static const char* z_preferred_hugetlbfs_mountpoints[] = { 104 "/dev/hugepages", 105 "/hugepages", 106 NULL 107 }; 108 109 static int z_fallocate_hugetlbfs_attempts = 3; 110 static bool z_fallocate_supported = true; 111 112 ZBackingFile::ZBackingFile() : 113 _fd(-1), 114 _size(0), 115 _filesystem(0), 116 _block_size(0), 117 _available(0), 118 _initialized(false) { 119 120 // Create backing file 121 _fd = create_fd(ZFILENAME_HEAP); 122 if (_fd == -1) { 123 return; 124 } 125 126 // Get filesystem statistics 127 struct statfs buf; 128 if (fstatfs(_fd, &buf) == -1) { 129 ZErrno err; 130 log_error(gc)("Failed to determine filesystem type for backing file (%s)", err.to_string()); 131 return; 132 } 133 134 _filesystem = buf.f_type; 135 _block_size = buf.f_bsize; 136 _available = buf.f_bavail * _block_size; 137 138 // Make sure we're on a supported filesystem 139 if (!is_tmpfs() && !is_hugetlbfs()) { 140 log_error(gc)("Backing file must be located on a %s or a %s filesystem", 141 ZFILESYSTEM_TMPFS, ZFILESYSTEM_HUGETLBFS); 142 return; 143 } 144 145 // Make sure the filesystem type matches requested large page type 146 if (ZLargePages::is_transparent() && !is_tmpfs()) { 147 log_error(gc)("-XX:+UseTransparentHugePages can only be enable when using a %s filesystem", 148 ZFILESYSTEM_TMPFS); 149 return; 150 } 151 152 if (ZLargePages::is_transparent() && !tmpfs_supports_transparent_huge_pages()) { 153 log_error(gc)("-XX:+UseTransparentHugePages on a %s filesystem not supported by kernel", 154 ZFILESYSTEM_TMPFS); 155 return; 156 } 157 158 if (ZLargePages::is_explicit() && !is_hugetlbfs()) { 159 log_error(gc)("-XX:+UseLargePages (without -XX:+UseTransparentHugePages) can only be enabled " 160 "when using a %s filesystem", ZFILESYSTEM_HUGETLBFS); 161 return; 162 } 163 164 if (!ZLargePages::is_explicit() && is_hugetlbfs()) { 165 log_error(gc)("-XX:+UseLargePages must be enabled when using a %s filesystem", 166 ZFILESYSTEM_HUGETLBFS); 167 return; 168 } 169 170 const size_t expected_block_size = is_tmpfs() ? os::vm_page_size() : os::large_page_size(); 171 if (expected_block_size != _block_size) { 172 log_error(gc)("%s filesystem has unexpected block size " SIZE_FORMAT " (expected " SIZE_FORMAT ")", 173 is_tmpfs() ? ZFILESYSTEM_TMPFS : ZFILESYSTEM_HUGETLBFS, _block_size, expected_block_size); 174 return; 175 } 176 177 // Successfully initialized 178 _initialized = true; 179 } 180 181 int ZBackingFile::create_mem_fd(const char* name) const { 182 // Create file name 183 char filename[PATH_MAX]; 184 snprintf(filename, sizeof(filename), "%s%s", name, ZLargePages::is_explicit() ? ".hugetlb" : ""); 185 186 // Create file 187 const int extra_flags = ZLargePages::is_explicit() ? MFD_HUGETLB : 0; 188 const int fd = ZSyscall::memfd_create(filename, MFD_CLOEXEC | extra_flags); 189 if (fd == -1) { 190 ZErrno err; 191 log_debug(gc, init)("Failed to create memfd file (%s)", 192 ((ZLargePages::is_explicit() && err == EINVAL) ? "Hugepages not supported" : err.to_string())); 193 return -1; 194 } 195 196 log_info(gc, init)("Heap backed by file: /memfd:%s", filename); 197 198 return fd; 199 } 200 201 int ZBackingFile::create_file_fd(const char* name) const { 202 const char* const filesystem = ZLargePages::is_explicit() 203 ? ZFILESYSTEM_HUGETLBFS 204 : ZFILESYSTEM_TMPFS; 205 const char** const preferred_mountpoints = ZLargePages::is_explicit() 206 ? z_preferred_hugetlbfs_mountpoints 207 : z_preferred_tmpfs_mountpoints; 208 209 // Find mountpoint 210 ZBackingPath path(filesystem, preferred_mountpoints); 211 if (path.get() == NULL) { 212 log_error(gc)("Use -XX:ZPath to specify the path to a %s filesystem", filesystem); 213 return -1; 214 } 215 216 // Try to create an anonymous file using the O_TMPFILE flag. Note that this 217 // flag requires kernel >= 3.11. If this fails we fall back to open/unlink. 218 const int fd_anon = os::open(path.get(), O_TMPFILE|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR); 219 if (fd_anon == -1) { 220 ZErrno err; 221 log_debug(gc, init)("Failed to create anonymous file in %s (%s)", path.get(), 222 (err == EINVAL ? "Not supported" : err.to_string())); 223 } else { 224 // Get inode number for anonymous file 225 struct stat stat_buf; 226 if (fstat(fd_anon, &stat_buf) == -1) { 227 ZErrno err; 228 log_error(gc)("Failed to determine inode number for anonymous file (%s)", err.to_string()); 229 return -1; 230 } 231 232 log_info(gc, init)("Heap backed by file: %s/#" UINT64_FORMAT, path.get(), (uint64_t)stat_buf.st_ino); 233 234 return fd_anon; 235 } 236 237 log_debug(gc, init)("Falling back to open/unlink"); 238 239 // Create file name 240 char filename[PATH_MAX]; 241 snprintf(filename, sizeof(filename), "%s/%s.%d", path.get(), name, os::current_process_id()); 242 243 // Create file 244 const int fd = os::open(filename, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR); 245 if (fd == -1) { 246 ZErrno err; 247 log_error(gc)("Failed to create file %s (%s)", filename, err.to_string()); 248 return -1; 249 } 250 251 // Unlink file 252 if (unlink(filename) == -1) { 253 ZErrno err; 254 log_error(gc)("Failed to unlink file %s (%s)", filename, err.to_string()); 255 return -1; 256 } 257 258 log_info(gc, init)("Heap backed by file: %s", filename); 259 260 return fd; 261 } 262 263 int ZBackingFile::create_fd(const char* name) const { 264 if (ZPath == NULL) { 265 // If the path is not explicitly specified, then we first try to create a memfd file 266 // instead of looking for a tmpfd/hugetlbfs mount point. Note that memfd_create() might 267 // not be supported at all (requires kernel >= 3.17), or it might not support large 268 // pages (requires kernel >= 4.14). If memfd_create() fails, then we try to create a 269 // file on an accessible tmpfs or hugetlbfs mount point. 270 const int fd = create_mem_fd(name); 271 if (fd != -1) { 272 return fd; 273 } 274 275 log_debug(gc, init)("Falling back to searching for an accessible mount point"); 276 } 277 278 return create_file_fd(name); 279 } 280 281 bool ZBackingFile::is_initialized() const { 282 return _initialized; 283 } 284 285 void ZBackingFile::warn_available_space(size_t max) const { 286 // Note that the available space on a tmpfs or a hugetlbfs filesystem 287 // will be zero if no size limit was specified when it was mounted. 288 if (_available == 0) { 289 // No size limit set, skip check 290 log_info(gc, init)("Available space on backing filesystem: N/A"); 291 return; 292 } 293 294 log_info(gc, init)("Available space on backing filesystem: " SIZE_FORMAT "M", _available / M); 295 296 // Warn if the filesystem doesn't currently have enough space available to hold 297 // the max heap size. The max heap size will be capped if we later hit this limit 298 // when trying to expand the heap. 299 if (_available < max) { 300 log_warning(gc)("***** WARNING! INCORRECT SYSTEM CONFIGURATION DETECTED! *****"); 301 log_warning(gc)("Not enough space available on the backing filesystem to hold the current max Java heap"); 302 log_warning(gc)("size (" SIZE_FORMAT "M). Please adjust the size of the backing filesystem accordingly " 303 "(available", max / M); 304 log_warning(gc)("space is currently " SIZE_FORMAT "M). Continuing execution with the current filesystem " 305 "size could", _available / M); 306 log_warning(gc)("lead to a premature OutOfMemoryError being thrown, due to failure to map memory."); 307 } 308 } 309 310 void ZBackingFile::warn_max_map_count(size_t max) const { 311 const char* const filename = ZFILENAME_PROC_MAX_MAP_COUNT; 312 FILE* const file = fopen(filename, "r"); 313 if (file == NULL) { 314 // Failed to open file, skip check 315 log_debug(gc, init)("Failed to open %s", filename); 316 return; 317 } 318 319 size_t actual_max_map_count = 0; 320 const int result = fscanf(file, SIZE_FORMAT, &actual_max_map_count); 321 fclose(file); 322 if (result != 1) { 323 // Failed to read file, skip check 324 log_debug(gc, init)("Failed to read %s", filename); 325 return; 326 } 327 328 // The required max map count is impossible to calculate exactly since subsystems 329 // other than ZGC are also creating memory mappings, and we have no control over that. 330 // However, ZGC tends to create the most mappings and dominate the total count. 331 // In the worst cases, ZGC will map each granule three times, i.e. once per heap view. 332 // We speculate that we need another 20% to allow for non-ZGC subsystems to map memory. 333 const size_t required_max_map_count = (max / ZGranuleSize) * 3 * 1.2; 334 if (actual_max_map_count < required_max_map_count) { 335 log_warning(gc)("***** WARNING! INCORRECT SYSTEM CONFIGURATION DETECTED! *****"); 336 log_warning(gc)("The system limit on number of memory mappings per process might be too low for the given"); 337 log_warning(gc)("max Java heap size (" SIZE_FORMAT "M). Please adjust %s to allow for at", 338 max / M, filename); 339 log_warning(gc)("least " SIZE_FORMAT " mappings (current limit is " SIZE_FORMAT "). Continuing execution " 340 "with the current", required_max_map_count, actual_max_map_count); 341 log_warning(gc)("limit could lead to a fatal error, due to failure to map memory."); 342 } 343 } 344 345 void ZBackingFile::warn_commit_limits(size_t max) const { 346 // Warn if available space is too low 347 warn_available_space(max); 348 349 // Warn if max map count is too low 350 warn_max_map_count(max); 351 } 352 353 size_t ZBackingFile::size() const { 354 return _size; 355 } 356 357 bool ZBackingFile::is_tmpfs() const { 358 return _filesystem == TMPFS_MAGIC; 359 } 360 361 bool ZBackingFile::is_hugetlbfs() const { 362 return _filesystem == HUGETLBFS_MAGIC; 363 } 364 365 bool ZBackingFile::tmpfs_supports_transparent_huge_pages() const { 366 // If the shmem_enabled file exists and is readable then we 367 // know the kernel supports transparent huge pages for tmpfs. 368 return access(ZFILENAME_SHMEM_ENABLED, R_OK) == 0; 369 } 370 371 ZErrno ZBackingFile::fallocate_compat_ftruncate(size_t size) const { 372 while (ftruncate(_fd, size) == -1) { 373 if (errno != EINTR) { 374 // Failed 375 return errno; 376 } 377 } 378 379 // Success 380 return 0; 381 } 382 383 ZErrno ZBackingFile::fallocate_compat_mmap(size_t offset, size_t length, bool touch) const { 384 // On hugetlbfs, mapping a file segment will fail immediately, without 385 // the need to touch the mapped pages first, if there aren't enough huge 386 // pages available to back the mapping. 387 void* const addr = mmap(0, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset); 388 if (addr == MAP_FAILED) { 389 // Failed 390 return errno; 391 } 392 393 // Once mapped, the huge pages are only reserved. We need to touch them 394 // to associate them with the file segment. Note that we can not punch 395 // hole in file segments which only have reserved pages. 396 if (touch) { 397 char* const start = (char*)addr; 398 char* const end = start + length; 399 os::pretouch_memory(start, end, _block_size); 400 } 401 402 // Unmap again. From now on, the huge pages that were mapped are allocated 403 // to this file. There's no risk in getting SIGBUS when touching them. 404 if (munmap(addr, length) == -1) { 405 // Failed 406 return errno; 407 } 408 409 // Success 410 return 0; 411 } 412 413 ZErrno ZBackingFile::fallocate_compat_pwrite(size_t offset, size_t length) const { 414 uint8_t data = 0; 415 416 // Allocate backing memory by writing to each block 417 for (size_t pos = offset; pos < offset + length; pos += _block_size) { 418 if (pwrite(_fd, &data, sizeof(data), pos) == -1) { 419 // Failed 420 return errno; 421 } 422 } 423 424 // Success 425 return 0; 426 } 427 428 ZErrno ZBackingFile::fallocate_fill_hole_compat(size_t offset, size_t length) { 429 // fallocate(2) is only supported by tmpfs since Linux 3.5, and by hugetlbfs 430 // since Linux 4.3. When fallocate(2) is not supported we emulate it using 431 // ftruncate/pwrite (for tmpfs) or ftruncate/mmap/munmap (for hugetlbfs). 432 433 const size_t end = offset + length; 434 if (end > _size) { 435 // Increase file size 436 const ZErrno err = fallocate_compat_ftruncate(end); 437 if (err) { 438 // Failed 439 return err; 440 } 441 } 442 443 // Allocate backing memory 444 const ZErrno err = is_hugetlbfs() ? fallocate_compat_mmap(offset, length, false /* touch */) 445 : fallocate_compat_pwrite(offset, length); 446 if (err) { 447 if (end > _size) { 448 // Restore file size 449 fallocate_compat_ftruncate(_size); 450 } 451 452 // Failed 453 return err; 454 } 455 456 if (end > _size) { 457 // Record new file size 458 _size = end; 459 } 460 461 // Success 462 return 0; 463 } 464 465 ZErrno ZBackingFile::fallocate_fill_hole_syscall(size_t offset, size_t length) { 466 const int mode = 0; // Allocate 467 const int res = ZSyscall::fallocate(_fd, mode, offset, length); 468 if (res == -1) { 469 // Failed 470 return errno; 471 } 472 473 const size_t end = offset + length; 474 if (end > _size) { 475 // Record new file size 476 _size = end; 477 } 478 479 // Success 480 return 0; 481 } 482 483 ZErrno ZBackingFile::fallocate_fill_hole(size_t offset, size_t length) { 484 // Using compat mode is more efficient when allocating space on hugetlbfs. 485 // Note that allocating huge pages this way will only reserve them, and not 486 // associate them with segments of the file. We must guarantee that we at 487 // some point touch these segments, otherwise we can not punch hole in them. 488 if (z_fallocate_supported && !is_hugetlbfs()) { 489 const ZErrno err = fallocate_fill_hole_syscall(offset, length); 490 if (!err) { 491 // Success 492 return 0; 493 } 494 495 if (err != ENOSYS && err != EOPNOTSUPP) { 496 // Failed 497 return err; 498 } 499 500 // Not supported 501 log_debug(gc)("Falling back to fallocate() compatibility mode"); 502 z_fallocate_supported = false; 503 } 504 505 return fallocate_fill_hole_compat(offset, length); 506 } 507 508 ZErrno ZBackingFile::fallocate_punch_hole(size_t offset, size_t length) { 509 if (is_hugetlbfs()) { 510 // We can only punch hole in pages that have been touched. Non-touched 511 // pages are only reserved, and not associated with any specific file 512 // segment. We don't know which pages have been previously touched, so 513 // we always touch them here to guarantee that we can punch hole. 514 const ZErrno err = fallocate_compat_mmap(offset, length, true /* touch */); 515 if (err) { 516 // Failed 517 return err; 518 } 519 } 520 521 const int mode = FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE; 522 if (ZSyscall::fallocate(_fd, mode, offset, length) == -1) { 523 // Failed 524 return errno; 525 } 526 527 // Success 528 return 0; 529 } 530 531 ZErrno ZBackingFile::split_and_fallocate(bool punch_hole, size_t offset, size_t length) { 532 // Try first half 533 const size_t offset0 = offset; 534 const size_t length0 = align_up(length / 2, _block_size); 535 const ZErrno err0 = fallocate(punch_hole, offset0, length0); 536 if (err0) { 537 return err0; 538 } 539 540 // Try second half 541 const size_t offset1 = offset0 + length0; 542 const size_t length1 = length - length0; 543 const ZErrno err1 = fallocate(punch_hole, offset1, length1); 544 if (err1) { 545 return err1; 546 } 547 548 // Success 549 return 0; 550 } 551 552 ZErrno ZBackingFile::fallocate(bool punch_hole, size_t offset, size_t length) { 553 assert(is_aligned(offset, _block_size), "Invalid offset"); 554 assert(is_aligned(length, _block_size), "Invalid length"); 555 556 const ZErrno err = punch_hole ? fallocate_punch_hole(offset, length) : fallocate_fill_hole(offset, length); 557 if (err == EINTR && length > _block_size) { 558 // Calling fallocate(2) with a large length can take a long time to 559 // complete. When running profilers, such as VTune, this syscall will 560 // be constantly interrupted by signals. Expanding the file in smaller 561 // steps avoids this problem. 562 return split_and_fallocate(punch_hole, offset, length); 563 } 564 565 return err; 566 } 567 568 bool ZBackingFile::commit_inner(size_t offset, size_t length) { 569 log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", 570 offset / M, (offset + length) / M, length / M); 571 572 retry: 573 const ZErrno err = fallocate(false /* punch_hole */, offset, length); 574 if (err) { 575 if (err == ENOSPC && !is_init_completed() && is_hugetlbfs() && z_fallocate_hugetlbfs_attempts-- > 0) { 576 // If we fail to allocate during initialization, due to lack of space on 577 // the hugetlbfs filesystem, then we wait and retry a few times before 578 // giving up. Otherwise there is a risk that running JVMs back-to-back 579 // will fail, since there is a delay between process termination and the 580 // huge pages owned by that process being returned to the huge page pool 581 // and made available for new allocations. 582 log_debug(gc, init)("Failed to commit memory (%s), retrying", err.to_string()); 583 584 // Wait and retry in one second, in the hope that huge pages will be 585 // available by then. 586 sleep(1); 587 goto retry; 588 } 589 590 // Failed 591 log_error(gc)("Failed to commit memory (%s)", err.to_string()); 592 return false; 593 } 594 595 // Success 596 return true; 597 } 598 599 size_t ZBackingFile::commit(size_t offset, size_t length) { 600 // Try to commit the whole region 601 if (commit_inner(offset, length)) { 602 // Success 603 return length; 604 } 605 606 // Failed, try to commit as much as possible 607 size_t start = offset; 608 size_t end = offset + length; 609 610 for (;;) { 611 length = align_down((end - start) / 2, ZGranuleSize); 612 if (length < ZGranuleSize) { 613 // Done, don't commit more 614 return start - offset; 615 } 616 617 if (commit_inner(start, length)) { 618 // Success, try commit more 619 start += length; 620 } else { 621 // Failed, try commit less 622 end -= length; 623 } 624 } 625 } 626 627 size_t ZBackingFile::uncommit(size_t offset, size_t length) { 628 log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", 629 offset / M, (offset + length) / M, length / M); 630 631 const ZErrno err = fallocate(true /* punch_hole */, offset, length); 632 if (err) { 633 log_error(gc)("Failed to uncommit memory (%s)", err.to_string()); 634 return 0; 635 } 636 637 return length; 638 } 639 640 void ZBackingFile::map(uintptr_t addr, size_t size, uintptr_t offset) const { 641 const void* const res = mmap((void*)addr, size, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED, _fd, offset); 642 if (res == MAP_FAILED) { 643 ZErrno err; 644 fatal("Failed to map memory (%s)", err.to_string()); 645 } 646 } 647 648 void ZBackingFile::unmap(uintptr_t addr, size_t size) const { 649 // Note that we must keep the address space reservation intact and just detach 650 // the backing memory. For this reason we map a new anonymous, non-accessible 651 // and non-reserved page over the mapping instead of actually unmapping. 652 const void* const res = mmap((void*)addr, size, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); 653 if (res == MAP_FAILED) { 654 ZErrno err; 655 fatal("Failed to map memory (%s)", err.to_string()); 656 } 657 }