[PATCH OLK-6.6] mm: try skipping pinned page before unmapping in migration
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDDIIR ----------------------------------------- Racy check if the page is pinned before unmapping to avoid page talbe unmaping and restoring, eventually migration will fail if page is pinned, so skip it at the begining as much as possible, no lock here but the racy window is short. Signed-off-by: Nanyong Sun <sunnanyong@huawei.com> --- mm/migrate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 4edd29d9a041..148e55fab012 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1290,6 +1290,14 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, /* Establish migration ptes */ VM_BUG_ON_FOLIO(folio_test_anon(src) && !folio_test_ksm(src) && !anon_vma, src); + + /* + * Racy check here to avoid page table walking and modifications + * as much as possible. + */ + if (unlikely(folio_maybe_dma_pinned(src))) + goto out; + try_to_migrate(src, mode == MIGRATE_ASYNC ? TTU_BATCH_FLUSH : 0); old_page_state |= PAGE_WAS_MAPPED; } @@ -1464,6 +1472,14 @@ static int unmap_and_move_huge_page(new_folio_t get_new_folio, if (folio_mapped(src)) { enum ttu_flags ttu = 0; + /* + * Racy check folio is pinned, try to avoid unnecessary page + * table unmapping and restoring, because the subsequent + * move_to_new_folio will eventually check the reference count. + */ + if (unlikely(folio_maybe_dma_pinned(src))) + goto unlock_put_anon; + if (!folio_test_anon(src)) { /* * In shared mappings, try_to_unmap could potentially -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/19707 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/UIK... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/19707 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/UIK...
participants (2)
-
Nanyong Sun -
patchwork bot