ascend inclusion category: Feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8LNGH
---------------------------------------------
This is a simple wrap of walk_page_range() to get all the pages of a spa. It doesn't support holes.
Signed-off-by: Wang Wensheng wangwensheng4@huawei.com --- mm/share_pool.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/mm/share_pool.c b/mm/share_pool.c index ce96ce8d3c80..cb3828ec325c 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -1555,7 +1555,36 @@ EXPORT_SYMBOL_GPL(mg_sp_unshare); int mg_sp_walk_page_range(unsigned long uva, unsigned long size, struct task_struct *tsk, struct sp_walk_data *sp_walk_data) { - return -EOPNOTSUPP; + struct mm_struct *mm; + int ret = 0; + + if (!sp_is_enabled()) + return -EOPNOTSUPP; + + check_interrupt_context(); + + if (unlikely(!sp_walk_data)) { + pr_err_ratelimited("null pointer when walk page range\n"); + return -EINVAL; + } + if (!tsk || (tsk->flags & PF_EXITING)) + return -ESRCH; + + get_task_struct(tsk); + mm = get_task_mm(tsk); + if (!mm) { + put_task_struct(tsk); + return -ESRCH; + } + + mmap_write_lock(mm); + ret = __sp_walk_page_range(uva, size, mm, sp_walk_data); + mmap_write_unlock(mm); + + mmput(mm); + put_task_struct(tsk); + + return ret; } EXPORT_SYMBOL_GPL(mg_sp_walk_page_range);
@@ -1565,6 +1594,15 @@ EXPORT_SYMBOL_GPL(mg_sp_walk_page_range); */ void mg_sp_walk_page_free(struct sp_walk_data *sp_walk_data) { + if (!sp_is_enabled()) + return; + + check_interrupt_context(); + + if (!sp_walk_data) + return; + + __sp_walk_page_free(sp_walk_data); } EXPORT_SYMBOL_GPL(mg_sp_walk_page_free);