The patch titled Subject: mm: hugetlb: soft-offline: dissolve source hugepage after successful migration has been added to the -mm tree. Its filename is mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Anshuman Khandual <khandual@xxxxxxxxxxxxxxxxxx> Subject: mm: hugetlb: soft-offline: dissolve source hugepage after successful migration Currently hugepage migrated by soft-offline (i.e. due to correctable memory errors) is contained as a hugepage, which means many non-error pages in it are unreusable, i.e. wasted. This patch solves this issue by dissolving source hugepages into buddy. As done in previous patch, PageHWPoison is set only on a head page of the error hugepage. Then in dissoliving we move the PageHWPoison flag to the raw error page so that all healthy subpages return back to buddy. Link: http://lkml.kernel.org/r/1496305019-5493-5-git-send-email-n-horiguchi@xxxxxxxxxxxxx Signed-off-by: Anshuman Khandual <khandual@xxxxxxxxxxxxxxxxxx> Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/hugetlb.h | 2 ++ mm/hugetlb.c | 10 +++++++++- mm/memory-failure.c | 5 +---- mm/migrate.c | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff -puN include/linux/hugetlb.h~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration include/linux/hugetlb.h --- a/include/linux/hugetlb.h~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration +++ a/include/linux/hugetlb.h @@ -472,6 +472,7 @@ static inline pgoff_t basepage_index(str return __basepage_index(page); } +extern int dissolve_free_huge_page(struct page *page); extern int dissolve_free_huge_pages(unsigned long start_pfn, unsigned long end_pfn); static inline bool hugepage_migration_supported(struct hstate *h) @@ -557,6 +558,7 @@ static inline pgoff_t basepage_index(str { return page->index; } +#define dissolve_free_huge_page(p) 0 #define dissolve_free_huge_pages(s, e) 0 #define hugepage_migration_supported(h) false diff -puN mm/hugetlb.c~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration mm/hugetlb.c --- a/mm/hugetlb.c~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration +++ a/mm/hugetlb.c @@ -1459,7 +1459,7 @@ static int free_pool_huge_page(struct hs * number of free hugepages would be reduced below the number of reserved * hugepages. */ -static int dissolve_free_huge_page(struct page *page) +int dissolve_free_huge_page(struct page *page) { int rc = 0; @@ -1472,6 +1472,14 @@ static int dissolve_free_huge_page(struc rc = -EBUSY; goto out; } + /* + * Move PageHWPoison flag from head page to the raw error page, + * which makes any subpages rather than the error page reusable. + */ + if (PageHWPoison(head) && page != head) { + SetPageHWPoison(page); + ClearPageHWPoison(head); + } list_del(&head->lru); h->free_huge_pages--; h->free_huge_pages_node[nid]--; diff -puN mm/memory-failure.c~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration mm/memory-failure.c --- a/mm/memory-failure.c~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration +++ a/mm/memory-failure.c @@ -1572,11 +1572,8 @@ static int soft_offline_huge_page(struct if (ret > 0) ret = -EIO; } else { - /* overcommit hugetlb page will be freed to buddy */ - SetPageHWPoison(page); if (PageHuge(page)) - dequeue_hwpoisoned_huge_page(hpage); - num_poisoned_pages_inc(); + dissolve_free_huge_page(page); } return ret; } diff -puN mm/migrate.c~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration mm/migrate.c --- a/mm/migrate.c~mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration +++ a/mm/migrate.c @@ -1252,6 +1252,8 @@ put_anon: out: if (rc != -EAGAIN) putback_active_hugepage(hpage); + if (reason == MR_MEMORY_FAILURE && !test_set_page_hwpoison(hpage)) + num_poisoned_pages_inc(); /* * If migration was not successful and there's a freeing callback, use _ Patches currently in -mm which might be from khandual@xxxxxxxxxxxxxxxxxx are mm-vmstat-standardize-file-operations-variable-names.patch mm-madvise-enable-softhard-offline-of-hugetlb-pages-at-pgd-level.patch mm-follow_page_mask-add-support-for-hugetlb-pgd-entries.patch mm-hugetlb-soft-offline-dissolve-source-hugepage-after-successful-migration.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html