[lustre-devel] [PATCH 04/33] lustre: llite: add __GFP_NORETRY for read-ahead page

James Simmons <[email protected]> Sun, 2 Feb 2025 15:46:04 -0500
Newsgroups org.lustre.lists.lustre-devel
Message-ID <[email protected]>
From: Qian Yingjin <[email protected]>

We need __GFP_NORETRY for read-ahead page, otherwise the read
process would be OOM killed when reached cgroup memory limits.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16713
Lustre-commit: 8db5d39f669f03aa6 ("LU-16713 llite: add __GFP_NORETRY for read-ahead page")
Signed-off-by: Qian Yingjin <[email protected]>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50625
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Patrick Farrell <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
 fs/lustre/llite/rw.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/llite/rw.c b/fs/lustre/llite/rw.c
index 92a9c252247e..9b1cf71116df 100644
--- a/fs/lustre/llite/rw.c
+++ b/fs/lustre/llite/rw.c
@@ -210,7 +210,16 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io,
 
 	switch (hint) {
 	case MAYNEED:
-		vmpage = grab_cache_page_nowait(inode->i_mapping, index);
+		/*
+		 * We need __GFP_NORETRY here for read-ahead page, otherwise
+		 * the process will fail with OOM killed due to memcg limit.
+		 * See @readahead_gfp_mask for an example.
+		 */
+		vmpage = pagecache_get_page(inode->i_mapping, index,
+					    FGP_LOCK | FGP_CREAT |
+					    FGP_NOFS | FGP_NOWAIT,
+					    mapping_gfp_mask(inode->i_mapping) |
+					    __GFP_NORETRY | __GFP_NOWARN);
 		if (!vmpage) {
 			which = RA_STAT_FAILED_GRAB_PAGE;
 			msg = "g_c_p_n failed";
-- 
2.39.3

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org