提交 6a250048 编写于 作者: M Ma Wupeng 提交者: openeuler-sync-bot

mm: mem_reliable: Update reliable page counter to zero if underflows

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I77BDW
CVE: NA

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

Since reliable page counter is used for debug purpose only, There is no
real function problem by doing this.
Signed-off-by: NMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: NNanyong Sun <sunnanyong@huawei.com>
(cherry picked from commit a687d7a0)
上级 0db7efd7
......@@ -132,8 +132,19 @@ static inline bool reliable_allow_fb_enabled(void)
static inline void reliable_page_counter(struct page *page,
struct mm_struct *mm, int val)
{
if (page_reliable(page))
atomic_long_add(val, &mm->reliable_nr_page);
if (!page_reliable(page))
return;
atomic_long_add(val, &mm->reliable_nr_page);
/*
* Update reliable page counter to zero if underflows.
*
* Since reliable page counter is used for debug purpose only,
* there is no real function problem by doing this.
*/
if (unlikely(atomic_long_read(&mm->reliable_nr_page) < 0))
atomic_long_set(&mm->reliable_nr_page, 0);
}
static inline void reliable_clear_page_counter(struct mm_struct *mm)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册