Skip to content

Commit 02f4ee5

Browse files
Kefeng Wangakpm00
authored andcommitted
mm: add folio_mc_copy()
Add a #MC variant of folio_copy() which uses copy_mc_highpage() to support #MC handled during folio copy, it will be used in folio migration soon. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kefeng Wang <[email protected]> Reviewed-by: Jane Chu <[email protected]> Reviewed-by: Miaohe Lin <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Benjamin LaHaise <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Jérôme Glisse <[email protected]> Cc: Jiaqi Yan <[email protected]> Cc: Lance Yang <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Muchun Song <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Tony Luck <[email protected]> Cc: Vishal Moola (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 28bdacb commit 02f4ee5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/linux/mm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ void put_pages_list(struct list_head *pages);
12911291

12921292
void split_page(struct page *page, unsigned int order);
12931293
void folio_copy(struct folio *dst, struct folio *src);
1294+
int folio_mc_copy(struct folio *dst, struct folio *src);
12941295

12951296
unsigned long nr_free_buffer_pages(void);
12961297

mm/util.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,23 @@ void folio_copy(struct folio *dst, struct folio *src)
828828
}
829829
EXPORT_SYMBOL(folio_copy);
830830

831+
int folio_mc_copy(struct folio *dst, struct folio *src)
832+
{
833+
long nr = folio_nr_pages(src);
834+
long i = 0;
835+
836+
for (;;) {
837+
if (copy_mc_highpage(folio_page(dst, i), folio_page(src, i)))
838+
return -EHWPOISON;
839+
if (++i == nr)
840+
break;
841+
cond_resched();
842+
}
843+
844+
return 0;
845+
}
846+
EXPORT_SYMBOL(folio_mc_copy);
847+
831848
int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS;
832849
int sysctl_overcommit_ratio __read_mostly = 50;
833850
unsigned long sysctl_overcommit_kbytes __read_mostly;

0 commit comments

Comments
 (0)