提交 71ab21df 编写于 作者: C Chen Wandun 提交者: Zheng Zengkai

mm: Add cmdline for the reliable memory usage of page cache

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

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

Add cmdline for the reliable memory usage of page cache.
Page cache will not use reliable memory when passing option
"P" to reliable_debug in cmdline.
Signed-off-by: NChen Wandun <chenwandun@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
上级 996667c3
...@@ -4778,9 +4778,10 @@ ...@@ -4778,9 +4778,10 @@
See Documentation/admin-guide/cgroup-v1/cpusets.rst. See Documentation/admin-guide/cgroup-v1/cpusets.rst.
reliable_debug= [ARM64] reliable_debug= [ARM64]
Format: [] Format: [P]
Only works with CONFIG_MEMORY_RELIABLE and Only works with CONFIG_MEMORY_RELIABLE and
"kernelcore=reliable" is configured. "kernelcore=reliable" is configured.
P: Page cache does not use the reliable memory.
reserve= [KNL,BUGS] Force kernel to ignore I/O ports or memory reserve= [KNL,BUGS] Force kernel to ignore I/O ports or memory
Format: <base1>,<size1>[,<base2>,<size2>,...] Format: <base1>,<size1>[,<base2>,<size2>,...]
......
...@@ -14,6 +14,7 @@ DECLARE_STATIC_KEY_FALSE(mem_reliable); ...@@ -14,6 +14,7 @@ DECLARE_STATIC_KEY_FALSE(mem_reliable);
extern bool reliable_enabled; extern bool reliable_enabled;
extern bool shmem_reliable; extern bool shmem_reliable;
extern bool pagecache_use_reliable_mem;
extern void mem_reliable_init(bool has_unmirrored_mem, extern void mem_reliable_init(bool has_unmirrored_mem,
unsigned long *zone_movable_pfn, unsigned long *zone_movable_pfn,
...@@ -28,6 +29,11 @@ static inline bool mem_reliable_is_enabled(void) ...@@ -28,6 +29,11 @@ static inline bool mem_reliable_is_enabled(void)
return static_branch_likely(&mem_reliable); return static_branch_likely(&mem_reliable);
} }
static inline bool pagecache_reliable_is_enabled(void)
{
return pagecache_use_reliable_mem;
}
static inline bool skip_none_movable_zone(gfp_t gfp, struct zoneref *z) static inline bool skip_none_movable_zone(gfp_t gfp, struct zoneref *z)
{ {
if (!mem_reliable_is_enabled()) if (!mem_reliable_is_enabled())
...@@ -52,8 +58,10 @@ static inline bool shmem_reliable_is_enabled(void) ...@@ -52,8 +58,10 @@ static inline bool shmem_reliable_is_enabled(void)
} }
#else #else
#define reliable_enabled 0 #define reliable_enabled 0
#define pagecache_use_reliable_mem 0
static inline bool mem_reliable_is_enabled(void) { return false; } static inline bool mem_reliable_is_enabled(void) { return false; }
static inline bool pagecache_reliable_is_enabled(void) { return false; }
static inline void mem_reliable_init(bool has_unmirrored_mem, static inline void mem_reliable_init(bool has_unmirrored_mem,
unsigned long *zone_movable_pfn, unsigned long *zone_movable_pfn,
unsigned long mirrored_sz) {} unsigned long mirrored_sz) {}
......
...@@ -16,6 +16,7 @@ EXPORT_SYMBOL_GPL(mem_reliable); ...@@ -16,6 +16,7 @@ EXPORT_SYMBOL_GPL(mem_reliable);
bool reliable_enabled; bool reliable_enabled;
bool shmem_reliable __read_mostly = true; bool shmem_reliable __read_mostly = true;
bool pagecache_use_reliable_mem __read_mostly = true;
bool mem_reliable_status(void) bool mem_reliable_status(void)
{ {
...@@ -25,8 +26,17 @@ EXPORT_SYMBOL_GPL(mem_reliable_status); ...@@ -25,8 +26,17 @@ EXPORT_SYMBOL_GPL(mem_reliable_status);
void page_cache_prepare_alloc(gfp_t *gfp) void page_cache_prepare_alloc(gfp_t *gfp)
{ {
if (mem_reliable_is_enabled()) if (!mem_reliable_is_enabled())
*gfp |= GFP_RELIABLE; return;
if (!pagecache_reliable_is_enabled())
goto no_reliable;
*gfp |= GFP_RELIABLE;
return;
no_reliable:
*gfp &= ~GFP_RELIABLE;
} }
static unsigned long total_reliable_pages(void) static unsigned long total_reliable_pages(void)
...@@ -121,6 +131,10 @@ static int __init setup_reliable_debug(char *str) ...@@ -121,6 +131,10 @@ static int __init setup_reliable_debug(char *str)
*/ */
for (; *str && *str != ','; str++) { for (; *str && *str != ','; str++) {
switch (*str) { switch (*str) {
case 'P':
pagecache_use_reliable_mem = false;
pr_info("disable page cache use reliable memory\n");
break;
default: default:
pr_err("reliable_debug option '%c' unknown. skipped\n", pr_err("reliable_debug option '%c' unknown. skipped\n",
*str); *str);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册