From: Zhou Guanghui zhouguanghui1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4PM0Y 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: Zhou Guanghui zhouguanghui1@huawei.com --- include/linux/mem_reliable.h | 7 +++++++ mm/shmem.c | 2 ++ 2 files changed, 9 insertions(+)
diff --git a/include/linux/mem_reliable.h b/include/linux/mem_reliable.h index 019e17130c67..fd62c8ec38ed 100644 --- a/include/linux/mem_reliable.h +++ b/include/linux/mem_reliable.h @@ -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 diff --git a/mm/shmem.c b/mm/shmem.c index 69595d341882..71fd12ad473f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -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