Commit 005ccde6 authored by Chen Wandun's avatar Chen Wandun Committed by Wupeng Ma
Browse files

mm: mem_reliable: Alloc pagecache from reliable region

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8USBA


CVE: NA

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

filemap_alloc_folio 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>
parent 5b97d548
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -69,6 +69,12 @@ static inline void shmem_prepare_alloc(gfp_t *gfp_mask)
	if (mem_reliable_is_enabled())
		*gfp_mask |= GFP_RELIABLE;
}

static inline void filemap_prepare_alloc(gfp_t *gfp_mask)
{
	if (mem_reliable_is_enabled())
		*gfp_mask |= GFP_RELIABLE;
}
#else
#define reliable_enabled 0

@@ -84,6 +90,7 @@ static inline bool skip_non_mirrored_zone(gfp_t gfp, struct zoneref *z)
static inline bool mem_reliable_status(void) { return false; }
static inline bool mem_reliable_hide_file(const char *name) { return false; }
static inline void shmem_prepare_alloc(gfp_t *gfp_mask) {}
static inline void filemap_prepare_alloc(gfp_t *gfp_mask) {}
#endif

#endif
+2 −0
Original line number Diff line number Diff line
@@ -963,6 +963,8 @@ struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order)
	int n;
	struct folio *folio;

	filemap_prepare_alloc(&gfp);

	if (cpuset_do_page_mem_spread()) {
		unsigned int cpuset_mems_cookie;
		do {