@@ -1350,6 +1350,43 @@ static inline void __update_and_free_page(struct hstate *h, struct page *page)
schedule_work(&hpage_update_work);
}
+static inline void hwpoison_subpage_deliver(struct hstate *h, struct page *head)
+{
+ struct page *page;
+
+ if (!PageHWPoison(head) || !free_vmemmap_pages_per_hpage(h))
+ return;
+
+ page = head + page_private(head + 4);
+
+ /*
+ * Move PageHWPoison flag from head page to the raw error page,
+ * which makes any subpages rather than the error page reusable.
+ */
+ if (page != head) {
+ SetPageHWPoison(page);
+ ClearPageHWPoison(head);
+ }
+}
+
+static inline void hwpoison_subpage_set(struct hstate *h, struct page *head,
+ struct page *page)
+{
+ if (!PageHWPoison(head))
+ return;
+
+ if (free_vmemmap_pages_per_hpage(h)) {
+ set_page_private(head + 4, page - head);
+ } else if (page != head) {
+ /*
+ * Move PageHWPoison flag from head page to the raw error page,
+ * which makes any subpages rather than the error page reusable.
+ */
+ SetPageHWPoison(page);
+ ClearPageHWPoison(head);
+ }
+}
+
static void update_and_free_page(struct hstate *h, struct page *page)
{
if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())
@@ -1366,6 +1403,7 @@ static void __free_hugepage(struct hstate *h, struct page *page)
int i;
alloc_huge_page_vmemmap(h, page);
+ hwpoison_subpage_deliver(h, page);
for (i = 0; i < pages_per_huge_page(h); i++) {
page[i].flags &= ~(1 << PG_locked | 1 << PG_error |
@@ -1843,14 +1881,8 @@ int dissolve_free_huge_page(struct page *page)
int nid = page_to_nid(head);
if (h->free_huge_pages - h->resv_huge_pages == 0)
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);
- }
+
+ hwpoison_subpage_set(h, head, page);
list_del(&head->lru);
h->free_huge_pages--;
h->free_huge_pages_node[nid]--;