1
2 /*
3 * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
562 bool setup_pages) {
563 assert(clear_space, "Reallocation will destroy data!");
564 assert(lgrp_spaces()->length() > 0, "There should be at least one space");
565
566 MemRegion old_region = region(), new_region;
567 set_bottom(mr.start());
568 set_end(mr.end());
569 // Must always clear the space
570 clear(SpaceDecorator::DontMangle);
571
572 // Compute chunk sizes
573 size_t prev_page_size = page_size();
574 set_page_size(UseLargePages ? alignment() : os::vm_page_size());
575 HeapWord* rounded_bottom = (HeapWord*)round_to((intptr_t) bottom(), page_size());
576 HeapWord* rounded_end = (HeapWord*)round_down((intptr_t) end(), page_size());
577 size_t base_space_size_pages = pointer_delta(rounded_end, rounded_bottom, sizeof(char)) / page_size();
578
579 // Try small pages if the chunk size is too small
580 if (base_space_size_pages / lgrp_spaces()->length() == 0
581 && page_size() > (size_t)os::vm_page_size()) {
582 set_page_size(os::vm_page_size());
583 rounded_bottom = (HeapWord*)round_to((intptr_t) bottom(), page_size());
584 rounded_end = (HeapWord*)round_down((intptr_t) end(), page_size());
585 base_space_size_pages = pointer_delta(rounded_end, rounded_bottom, sizeof(char)) / page_size();
586 }
587 guarantee(base_space_size_pages / lgrp_spaces()->length() > 0, "Space too small");
588 set_base_space_size(base_space_size_pages);
589
590 // Handle space resize
591 MemRegion top_region, bottom_region;
592 if (!old_region.equals(region())) {
593 new_region = MemRegion(rounded_bottom, rounded_end);
594 MemRegion intersection = new_region.intersection(old_region);
595 if (intersection.start() == NULL ||
596 intersection.end() == NULL ||
597 prev_page_size > page_size()) { // If the page size got smaller we have to change
598 // the page size preference for the whole space.
599 intersection = MemRegion(new_region.start(), new_region.start());
600 }
601 select_tails(new_region, intersection, &bottom_region, &top_region);
|
1
2 /*
3 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
562 bool setup_pages) {
563 assert(clear_space, "Reallocation will destroy data!");
564 assert(lgrp_spaces()->length() > 0, "There should be at least one space");
565
566 MemRegion old_region = region(), new_region;
567 set_bottom(mr.start());
568 set_end(mr.end());
569 // Must always clear the space
570 clear(SpaceDecorator::DontMangle);
571
572 // Compute chunk sizes
573 size_t prev_page_size = page_size();
574 set_page_size(UseLargePages ? alignment() : os::vm_page_size());
575 HeapWord* rounded_bottom = (HeapWord*)round_to((intptr_t) bottom(), page_size());
576 HeapWord* rounded_end = (HeapWord*)round_down((intptr_t) end(), page_size());
577 size_t base_space_size_pages = pointer_delta(rounded_end, rounded_bottom, sizeof(char)) / page_size();
578
579 // Try small pages if the chunk size is too small
580 if (base_space_size_pages / lgrp_spaces()->length() == 0
581 && page_size() > (size_t)os::vm_page_size()) {
582 #ifdef LINUX
583 // If we are using pin region, we cannot change the page size to default size
584 // as we could free memory which is not expected for pin region in Linux.
585 if (UseLargePages && !os::can_commit_large_page_memory()) {
586 vm_exit_during_initialization("Failed initializing NUMA. Too small heap size");
587 }
588 #endif // LINUX
589 set_page_size(os::vm_page_size());
590 rounded_bottom = (HeapWord*)round_to((intptr_t) bottom(), page_size());
591 rounded_end = (HeapWord*)round_down((intptr_t) end(), page_size());
592 base_space_size_pages = pointer_delta(rounded_end, rounded_bottom, sizeof(char)) / page_size();
593 }
594 guarantee(base_space_size_pages / lgrp_spaces()->length() > 0, "Space too small");
595 set_base_space_size(base_space_size_pages);
596
597 // Handle space resize
598 MemRegion top_region, bottom_region;
599 if (!old_region.equals(region())) {
600 new_region = MemRegion(rounded_bottom, rounded_end);
601 MemRegion intersection = new_region.intersection(old_region);
602 if (intersection.start() == NULL ||
603 intersection.end() == NULL ||
604 prev_page_size > page_size()) { // If the page size got smaller we have to change
605 // the page size preference for the whole space.
606 intersection = MemRegion(new_region.start(), new_region.start());
607 }
608 select_tails(new_region, intersection, &bottom_region, &top_region);
|