ascend inclusion category: Feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YF5R
---------------------------------------------
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 be52c5febbb1..4096934ab1e5 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; + } + + down_write(&mm->mmap_lock); + ret = __sp_walk_page_range(uva, size, mm, sp_walk_data); + up_write(&mm->mmap_lock); + + 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);