Commit dfa98f56 authored by Baolin Wang's avatar Baolin Wang Committed by Andrew Morton

mm: khugepaged: support shmem mTHP copy

Iterate each subpage in the large folio to copy, as preparation for
supporting shmem mTHP collapse.

Link: https://lkml.kernel.org/r/222d615b7c837eabb47a238126c5fdeff8aa5283.1724140601.git.baolin.wang@linux.alibaba.comSigned-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <21cnbao@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent d6b8f296
...@@ -2056,18 +2056,23 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, ...@@ -2056,18 +2056,23 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
index = start; index = start;
dst = folio_page(new_folio, 0); dst = folio_page(new_folio, 0);
list_for_each_entry(folio, &pagelist, lru) { list_for_each_entry(folio, &pagelist, lru) {
int i, nr_pages = folio_nr_pages(folio);
while (index < folio->index) { while (index < folio->index) {
clear_highpage(dst); clear_highpage(dst);
index++; index++;
dst++; dst++;
} }
if (copy_mc_highpage(dst, folio_page(folio, 0)) > 0) {
for (i = 0; i < nr_pages; i++) {
if (copy_mc_highpage(dst, folio_page(folio, i)) > 0) {
result = SCAN_COPY_MC; result = SCAN_COPY_MC;
goto rollback; goto rollback;
} }
index++; index++;
dst++; dst++;
} }
}
while (index < end) { while (index < end) {
clear_highpage(dst); clear_highpage(dst);
index++; index++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment