Skip to content

Commit 5f5ee52

Browse files
tujinjiang11akpm00
authored andcommitted
mm/hwpoison: introduce folio_contain_hwpoisoned_page() helper
Patch series "mm/vmscan: don't try to reclaim hwpoison folio". Fix a bug during memory reclaim if folio is hwpoisoned. This patch (of 2): Introduce helper folio_contain_hwpoisoned_page() to check if the entire folio is hwpoisoned or it contains hwpoisoned pages. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jinjiang Tu <[email protected]> Acked-by: Miaohe Lin <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Nanyong Sun <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: <stable@vger,kernel.org> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4c8bc7c commit 5f5ee52

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

include/linux/page-flags.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,12 @@ static inline bool is_page_hwpoison(const struct page *page)
10981098
return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
10991099
}
11001100

1101+
static inline bool folio_contain_hwpoisoned_page(struct folio *folio)
1102+
{
1103+
return folio_test_hwpoison(folio) ||
1104+
(folio_test_large(folio) && folio_test_has_hwpoisoned(folio));
1105+
}
1106+
11011107
bool is_free_buddy_page(const struct page *page);
11021108

11031109
PAGEFLAG(Isolated, isolated, PF_ANY);

mm/memory_hotplug.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,8 +1828,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
18281828
if (unlikely(page_folio(page) != folio))
18291829
goto put_folio;
18301830

1831-
if (folio_test_hwpoison(folio) ||
1832-
(folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) {
1831+
if (folio_contain_hwpoisoned_page(folio)) {
18331832
if (WARN_ON(folio_test_lru(folio)))
18341833
folio_isolate_lru(folio);
18351834
if (folio_mapped(folio)) {

mm/shmem.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,8 +3290,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
32903290
if (ret)
32913291
return ret;
32923292

3293-
if (folio_test_hwpoison(folio) ||
3294-
(folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) {
3293+
if (folio_contain_hwpoisoned_page(folio)) {
32953294
folio_unlock(folio);
32963295
folio_put(folio);
32973296
return -EIO;

0 commit comments

Comments
 (0)