提交 8d1faee5 编写于 作者: C Chen Wandun 提交者: Zheng Zengkai

mm: add support for page cache use reliable memory

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

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

__page_cache_alloc is used to alloc page cache in most file system,
such as ext4, f2fs, so add GFP_RELIABLE flag to use reliable
memory when alloc page cache.
Signed-off-by: NChen Wandun <chenwandun@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 cb06286c
...@@ -20,6 +20,7 @@ extern void mem_reliable_init(bool has_unmirrored_mem, ...@@ -20,6 +20,7 @@ extern void mem_reliable_init(bool has_unmirrored_mem,
unsigned long *zone_movable_pfn); unsigned long *zone_movable_pfn);
extern void shmem_reliable_init(void); extern void shmem_reliable_init(void);
extern void reliable_report_meminfo(struct seq_file *m); extern void reliable_report_meminfo(struct seq_file *m);
extern void page_cache_prepare_alloc(gfp_t *gfp);
static inline bool mem_reliable_is_enabled(void) static inline bool mem_reliable_is_enabled(void)
{ {
...@@ -68,6 +69,7 @@ static inline bool skip_none_movable_zone(gfp_t gfp, struct zoneref *z) ...@@ -68,6 +69,7 @@ static inline bool skip_none_movable_zone(gfp_t gfp, struct zoneref *z)
} }
static inline void reliable_report_meminfo(struct seq_file *m) {} static inline void reliable_report_meminfo(struct seq_file *m) {}
static inline bool shmem_reliable_is_enabled(void) { return false; } static inline bool shmem_reliable_is_enabled(void) { return false; }
static inline void page_cache_prepare_alloc(gfp_t *gfp) {}
#endif #endif
#endif #endif
...@@ -954,6 +954,8 @@ struct page *__page_cache_alloc(gfp_t gfp) ...@@ -954,6 +954,8 @@ struct page *__page_cache_alloc(gfp_t gfp)
int n; int n;
struct page *page; struct page *page;
page_cache_prepare_alloc(&gfp);
if (cpuset_do_page_mem_spread()) { if (cpuset_do_page_mem_spread()) {
unsigned int cpuset_mems_cookie; unsigned int cpuset_mems_cookie;
do { do {
......
...@@ -15,6 +15,12 @@ bool reliable_enabled; ...@@ -15,6 +15,12 @@ bool reliable_enabled;
static atomic_long_t total_reliable_mem; static atomic_long_t total_reliable_mem;
bool shmem_reliable __read_mostly = true; bool shmem_reliable __read_mostly = true;
void page_cache_prepare_alloc(gfp_t *gfp)
{
if (mem_reliable_is_enabled())
*gfp |= GFP_RELIABLE;
}
void add_reliable_mem_size(long sz) void add_reliable_mem_size(long sz)
{ {
atomic_long_add(sz, &total_reliable_mem); atomic_long_add(sz, &total_reliable_mem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册