[PATCH openEuler-1.0-LTS] mm/mem_reliable: use percise count during limit check
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8USBA -------------------------------- If the fallback for memory reliable is enabled, direct reclaim will be used if the task's reliable memory limit is reached and pages need to be released. However, percpu_counter_read_positive() provides a fast but imprecise counter reading. During limit enforcement, this inaccuracy may cause the observed usage to appear significantly larger than the actual value. As a result, even repeated constrained reclaim attempts may fail to bring memory usage below the limit, eventually leading to OOM. To avoid this issue, use an accurate counter check when determining whether the reliable memory limit has been exceeded. Fixes: 875ffd41499e ("mm: Do limit checking after memory allocation for memory reliable") Signed-off-by: Wupeng Ma <mawupeng1@huawei.com> --- include/linux/mem_reliable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/mem_reliable.h b/include/linux/mem_reliable.h index c0eff851bbe7..d70146a59a3e 100644 --- a/include/linux/mem_reliable.h +++ b/include/linux/mem_reliable.h @@ -84,8 +84,9 @@ static inline bool reliable_mem_limit_check(unsigned long nr_page) { s64 num; - num = percpu_counter_read_positive(&pagecache_reliable_pages); - num += percpu_counter_read_positive(&anon_reliable_pages); + /* limit check need precise counter, use sum rather than read */ + num = percpu_counter_sum_positive(&pagecache_reliable_pages); + num += percpu_counter_sum_positive(&anon_reliable_pages); return num + nr_page <= task_reliable_limit / PAGE_SIZE; } -- 2.43.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/19723 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/IPG... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/19723 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/IPG...
participants (2)
-
patchwork bot -
Wupeng Ma