summaryrefslogtreecommitdiffstats
path: root/mm/madvise.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/madvise.c')
-rw-r--r--mm/madvise.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/mm/madvise.c b/mm/madvise.c
index 21261ff0466f..fd70d6aabc3e 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -625,18 +625,26 @@ static int madvise_inject_error(int behavior,
625{ 625{
626 struct page *page; 626 struct page *page;
627 struct zone *zone; 627 struct zone *zone;
628 unsigned int order;
628 629
629 if (!capable(CAP_SYS_ADMIN)) 630 if (!capable(CAP_SYS_ADMIN))
630 return -EPERM; 631 return -EPERM;
631 632
632 for (; start < end; start += PAGE_SIZE << 633
633 compound_order(compound_head(page))) { 634 for (; start < end; start += PAGE_SIZE << order) {
634 int ret; 635 int ret;
635 636
636 ret = get_user_pages_fast(start, 1, 0, &page); 637 ret = get_user_pages_fast(start, 1, 0, &page);
637 if (ret != 1) 638 if (ret != 1)
638 return ret; 639 return ret;
639 640
641 /*
642 * When soft offlining hugepages, after migrating the page
643 * we dissolve it, therefore in the second loop "page" will
644 * no longer be a compound page, and order will be 0.
645 */
646 order = compound_order(compound_head(page));
647
640 if (PageHWPoison(page)) { 648 if (PageHWPoison(page)) {
641 put_page(page); 649 put_page(page);
642 continue; 650 continue;
@@ -749,6 +757,9 @@ madvise_behavior_valid(int behavior)
749 * MADV_DONTFORK - omit this area from child's address space when forking: 757 * MADV_DONTFORK - omit this area from child's address space when forking:
750 * typically, to avoid COWing pages pinned by get_user_pages(). 758 * typically, to avoid COWing pages pinned by get_user_pages().
751 * MADV_DOFORK - cancel MADV_DONTFORK: no longer omit this area when forking. 759 * MADV_DOFORK - cancel MADV_DONTFORK: no longer omit this area when forking.
760 * MADV_WIPEONFORK - present the child process with zero-filled memory in this
761 * range after a fork.
762 * MADV_KEEPONFORK - undo the effect of MADV_WIPEONFORK
752 * MADV_HWPOISON - trigger memory error handler as if the given memory range 763 * MADV_HWPOISON - trigger memory error handler as if the given memory range
753 * were corrupted by unrecoverable hardware memory failure. 764 * were corrupted by unrecoverable hardware memory failure.
754 * MADV_SOFT_OFFLINE - try to soft-offline the given range of memory. 765 * MADV_SOFT_OFFLINE - try to soft-offline the given range of memory.
@@ -769,7 +780,9 @@ madvise_behavior_valid(int behavior)
769 * zero - success 780 * zero - success
770 * -EINVAL - start + len < 0, start is not page-aligned, 781 * -EINVAL - start + len < 0, start is not page-aligned,
771 * "behavior" is not a valid value, or application 782 * "behavior" is not a valid value, or application
772 * is attempting to release locked or shared pages. 783 * is attempting to release locked or shared pages,
784 * or the specified address range includes file, Huge TLB,
785 * MAP_SHARED or VMPFNMAP range.
773 * -ENOMEM - addresses in the specified range are not currently 786 * -ENOMEM - addresses in the specified range are not currently
774 * mapped, or are outside the AS of the process. 787 * mapped, or are outside the AS of the process.
775 * -EIO - an I/O error occurred while paging in data. 788 * -EIO - an I/O error occurred while paging in data.