Commit a687d7a0 authored by Ma Wupeng's avatar Ma Wupeng Committed by Wupeng Ma
Browse files

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: default avatarMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: default avatarNanyong Sun <sunnanyong@huawei.com>
parent e70b561e
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -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))
	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)