提交 92751dfb 编写于 作者: Z ZhangPeng 提交者: Ma Wupeng

userswap: add page_count() check for swap-out VA

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6CAIM

--------------------------------

Add page_count() check for swap-out VA to make sure that no other kernel
mechanism is using this physical page.
Add lru_add_drain_all() before swap-out VA to correct page_count() of
swap-out pages.
Signed-off-by: NZhangPeng <zhangpeng362@huawei.com>
上级 4ca4ac49
...@@ -139,7 +139,8 @@ static unsigned long pages_can_be_swapped(struct mm_struct *mm, ...@@ -139,7 +139,8 @@ static unsigned long pages_can_be_swapped(struct mm_struct *mm,
* Check that no O_DIRECT or similar I/O is in progress on the * Check that no O_DIRECT or similar I/O is in progress on the
* page * page
*/ */
if (page_mapcount(page) > 1) { if (page_mapcount(page) > 1 ||
page_mapcount(page) + 1 != page_count(page)) {
ret = -EBUSY; ret = -EBUSY;
goto out_err; goto out_err;
} }
...@@ -378,6 +379,7 @@ unsigned long uswap_mremap(unsigned long old_addr, unsigned long old_len, ...@@ -378,6 +379,7 @@ unsigned long uswap_mremap(unsigned long old_addr, unsigned long old_len,
if (old_addr + old_len > new_addr && new_addr + new_len > old_addr) if (old_addr + old_len > new_addr && new_addr + new_len > old_addr)
return ret; return ret;
lru_add_drain_all();
down_read(&mm->mmap_lock); down_read(&mm->mmap_lock);
ret = pages_can_be_swapped(mm, old_addr, len, &pages); ret = pages_can_be_swapped(mm, old_addr, len, &pages);
if (ret) { if (ret) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册