提交 368d710d 编写于 作者: M Ma Wupeng 提交者: Yongqiang Liu

mm: Fallback to non-mirrored region below low watermark

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

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

Commit 45bd608e ("mm: Introduce watermark check for memory reliable")
introduce watermark to reserve memory in mirrored region for kernel usage.
But this value does not interact well with kswapd and this will lead to
fallback to non-mirrored region without release pagecache in mirrored
region.

With this patch, watermark is set to zero to avoid this problem.
Memory allocation with ___GFP_RELIABILITY will fallback to non-mirrored
region if zone's low watermark is reached and kswapd will be awakened at
this time.
Signed-off-by: NMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 a30ba5b6
......@@ -11,7 +11,7 @@
#include <linux/oom.h>
#include <linux/crash_dump.h>
#define MEM_RELIABLE_RESERVE_MIN (256UL << 20)
#define MEM_RELIABLE_RESERVE_MIN 0
enum mem_reliable_types {
MEM_RELIABLE_ALL,
......
......@@ -4271,6 +4271,29 @@ check_retry_cpuset(int cpuset_mems_cookie, struct alloc_context *ac)
return false;
}
#ifdef CONFIG_MEMORY_RELIABLE
static inline void mem_reliable_fallback_slowpath(gfp_t gfp_mask,
struct alloc_context *ac)
{
if (!reliable_allow_fb_enabled())
return;
if (gfp_mask & __GFP_NOFAIL)
return;
if ((ac->high_zoneidx == ZONE_NORMAL) &&
(gfp_mask & ___GFP_RELIABILITY)) {
ac->high_zoneidx = gfp_zone(gfp_mask & ~___GFP_RELIABILITY);
ac->preferred_zoneref = first_zones_zonelist(
ac->zonelist, ac->high_zoneidx, ac->nodemask);
return;
}
}
#else
static inline void mem_reliable_fallback_slowpath(gfp_t gfp_mask,
struct alloc_context *ac) {}
#endif
static inline struct page *
__alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
struct alloc_context *ac)
......@@ -4322,6 +4345,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
if (gfp_mask & __GFP_KSWAPD_RECLAIM)
wake_all_kswapds(order, gfp_mask, ac);
mem_reliable_fallback_slowpath(gfp_mask, ac);
/*
* The adjusted alloc_flags might result in immediate success, so try
* that first
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册