Commit 5b97d548 authored by Zhou Guanghui's avatar Zhou Guanghui Committed by Wupeng Ma
Browse files

shmem: mem_reliable: Alloc shmem from reliable region

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


CVE: NA

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

This feature depends on the overall memory reliable feature.
When the shared memory reliable feature is enabled, the pages
used by the shared memory are allocated from the mirrored
region by default.

Signed-off-by: default avatarZhou Guanghui <zhouguanghui1@huawei.com>
parent 7829f27d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ static inline bool skip_non_mirrored_zone(gfp_t gfp, struct zoneref *z)

	return false;
}

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

@@ -77,6 +83,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) {}
#endif

#endif
+2 −0
Original line number Diff line number Diff line
@@ -1677,6 +1677,8 @@ static struct folio *shmem_alloc_and_acct_folio(gfp_t gfp, struct inode *inode,
	if (err)
		goto failed;

	shmem_prepare_alloc(&gfp);

	if (huge)
		folio = shmem_alloc_hugefolio(gfp, info, index);
	else