From: Chen Wandun chenwandun@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4PM0Z 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: Chen Wandun chenwandun@huawei.com --- include/linux/mem_reliable.h | 7 +++++++ mm/filemap.c | 2 ++ 2 files changed, 9 insertions(+)
diff --git a/include/linux/mem_reliable.h b/include/linux/mem_reliable.h index fd62c8ec38ed..bdd605bf2d45 100644 --- a/include/linux/mem_reliable.h +++ b/include/linux/mem_reliable.h @@ -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 diff --git a/mm/filemap.c b/mm/filemap.c index 485dfc8b0f9c..e75743ba4a98 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -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 {