Skip to contentSkip to conversation

fs-hugetlbfs-cleanup-folio-in-adjust_range_hwpoison.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Sep 21, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: fs: hugetlbfs: cleanup folio in adjust_range_hwpoison()
has been removed from the -mm tree. Its filename was
fs-hugetlbfs-cleanup-folio-in-adjust_range_hwpoison.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: David Hildenbrand <[email protected]>
Subject: fs: hugetlbfs: cleanup folio in adjust_range_hwpoison()
Date: Mon, 1 Sep 2025 17:03:37 +0200

Let's cleanup and simplify the function a bit.

---

 fs/hugetlbfs/inode.c |   34 +++++++++++-----------------------
 1 file changed, 11 insertions(+), 23 deletions(-)
fs/hugetlbfs/inode.c renamed from fs/hugetlbfs/inode.c~fs-hugetlbfs-cleanup-folio-in-adjust_range_hwpoison +11 -23
@@ -192,37 +192,25 @@ hugetlb_get_unmapped_area(struct file *f
  * Someone wants to read @bytes from a HWPOISON hugetlb @folio from @offset.
  * Returns the maximum number of bytes one can read without touching the 1st raw
  * HWPOISON page.
- *
- * The implementation borrows the iteration logic from copy_page_to_iter*.
  */
 static size_t adjust_range_hwpoison(struct folio *folio, size_t offset,
 		size_t bytes)
 {
-	struct page *page;
-	size_t n = 0;
-	size_t res = 0;
+	struct page *page = folio_page(folio, offset / PAGE_SIZE);
+	size_t safe_bytes;
 
-	/* First page to start the loop. */
-	page = folio_page(folio, offset / PAGE_SIZE);
-	offset %= PAGE_SIZE;
-	while (1) {
-		if (is_raw_hwpoison_page_in_hugepage(page))
-			break;
+	if (is_raw_hwpoison_page_in_hugepage(page))
+		return 0;
+	/* Safe to read the remaining bytes in this page. */
+	safe_bytes = PAGE_SIZE - (offset % PAGE_SIZE);
+	page++;
 
-		/* Safe to read n bytes without touching HWPOISON subpage. */
-		n = min(bytes, (size_t)PAGE_SIZE - offset);
-		res += n;
-		bytes -= n;
-		if (!bytes || !n)
+	/* Check each remaining page as long as we are not done yet. */
+	for (; safe_bytes < bytes; safe_bytes += PAGE_SIZE, page++)
+		if (is_raw_hwpoison_page_in_hugepage(page))
 			break;
-		offset += n;
-		if (offset == PAGE_SIZE) {
-			page++;
-			offset = 0;
-		}
-	}
 
-	return res;
+	return min(safe_bytes, bytes);
 }
 
 /*

_

Patches currently in -mm which might be from [email protected] are