From: Jiaqi Yan <jiaqiyan@google.com>
To: nao.horiguchi@gmail.com, linmiaohe@huawei.com,
sidhartha.kumar@oracle.com, muchun.song@linux.dev
Cc: jane.chu@oracle.com, akpm@linux-foundation.org,
osalvador@suse.de, rientjes@google.com, jthoughton@google.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Jiaqi Yan <jiaqiyan@google.com>
Subject: [RFC PATCH v1 2/2] mm/hugetlb: immature fix to handle HWPoisoned folio
Date: Sun, 19 Jan 2025 18:06:08 +0000 [thread overview]
Message-ID: <20250119180608.2132296-3-jiaqiyan@google.com> (raw)
In-Reply-To: <20250119180608.2132296-1-jiaqiyan@google.com>
The fix has two steps
1. Decrement HWPoison HugeTLB huge folio's refcount when it is 1. It is
done in folios_put_refs during truncating or eviting HugeTLB file.
2. Dissolve HugeTLB HWpoison folio in free_huge_folio.
Again, just for demo purpose, not a proper fix, especially step 1.
Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
---
mm/hugetlb.c | 6 ++++++
mm/swap.c | 9 ++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 87761b042ed04..b28e0bc7f199f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1818,6 +1818,7 @@ void free_huge_folio(struct folio *folio)
int nid = folio_nid(folio);
struct hugepage_subpool *spool = hugetlb_folio_subpool(folio);
bool restore_reserve;
+ bool hwpoison = folio_test_hwpoison(folio);
unsigned long flags;
VM_BUG_ON_FOLIO(folio_ref_count(folio), folio);
@@ -1869,6 +1870,11 @@ void free_huge_folio(struct folio *folio)
remove_hugetlb_folio(h, folio, true);
spin_unlock_irqrestore(&hugetlb_lock, flags);
update_and_free_hugetlb_folio(h, folio, true);
+ } else if (hwpoison) {
+ remove_hugetlb_folio(h, folio, false);
+ h->max_huge_pages--;
+ spin_unlock_irqrestore(&hugetlb_lock, flags);
+ update_and_free_hugetlb_folio(h, folio, true);
} else {
arch_clear_hugetlb_flags(folio);
enqueue_hugetlb_folio(h, folio);
diff --git a/mm/swap.c b/mm/swap.c
index 746a5ceba42c9..d6b4d4cb4004f 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -961,7 +961,14 @@ void folios_put_refs(struct folio_batch *folios, unsigned int *refs)
continue;
}
- if (!folio_ref_sub_and_test(folio, nr_refs))
+ folio_ref_sub(folio, nr_refs);
+
+ if (folio_test_hugetlb(folio) &&
+ folio_ref_count(folio) == 1 &&
+ folio_test_hwpoison(folio))
+ folio_ref_dec(folio);
+
+ if (folio_ref_count(folio) > 0)
continue;
/* hugetlb has its own memcg */
--
2.48.0.rc2.279.g1de40edade-goog
next prev parent reply other threads:[~2025-01-19 18:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-19 18:06 [RFC PATCH v1 0/2] How HugeTLB handle HWPoison page at truncation Jiaqi Yan
2025-01-19 18:06 ` [RFC PATCH v1 1/2] selftest/mm: test HWPoison hugetlb truncation behavior Jiaqi Yan
2025-01-19 20:18 ` Pedro Falcato
2025-01-19 18:06 ` Jiaqi Yan [this message]
2025-01-20 10:59 ` [RFC PATCH v1 0/2] How HugeTLB handle HWPoison page at truncation David Hildenbrand
2025-01-21 1:21 ` Jiaqi Yan
2025-01-21 5:00 ` jane.chu
2025-01-21 5:08 ` Jiaqi Yan
2025-01-21 5:22 ` jane.chu
2025-01-21 8:02 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250119180608.2132296-3-jiaqiyan@google.com \
--to=jiaqiyan@google.com \
--cc=akpm@linux-foundation.org \
--cc=jane.chu@oracle.com \
--cc=jthoughton@google.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rientjes@google.com \
--cc=sidhartha.kumar@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®