Commit 8d1faee5 authored by Chen Wandun's avatar Chen Wandun Committed by Zheng Zengkai
Browse files

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: default avatarChen Wandun <chenwandun@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent cb06286c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ extern void mem_reliable_init(bool has_unmirrored_mem,
			      unsigned long *zone_movable_pfn);
extern void shmem_reliable_init(void);
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)
{
@@ -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 bool shmem_reliable_is_enabled(void) { return false; }
static inline void page_cache_prepare_alloc(gfp_t *gfp) {}
#endif

#endif
+2 −0
Original line number Diff line number Diff line
@@ -954,6 +954,8 @@ struct page *__page_cache_alloc(gfp_t gfp)
	int n;
	struct page *page;

	page_cache_prepare_alloc(&gfp);

	if (cpuset_do_page_mem_spread()) {
		unsigned int cpuset_mems_cookie;
		do {
+6 −0
Original line number Diff line number Diff line
@@ -15,6 +15,12 @@ bool reliable_enabled;
static atomic_long_t total_reliable_mem;
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)
{
	atomic_long_add(sz, &total_reliable_mem);