[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <154703643564.32690.8416317230641240199.stgit@localhost.localdomain>
Date: Wed, 09 Jan 2019 15:20:35 +0300
From: Kirill Tkhai <ktkhai@...tuozzo.com>
To: akpm@...ux-foundation.org, hannes@...xchg.org,
josef@...icpanda.com, jack@...e.cz, hughd@...gle.com,
ktkhai@...tuozzo.com, darrick.wong@...cle.com, mhocko@...e.com,
aryabinin@...tuozzo.com, guro@...com, mgorman@...hsingularity.net,
shakeelb@...gle.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] mm: Pass FGP_NOWAIT in generic_file_buffered_read and
enable ext4
All page-obtaining functions, which are used by ext4, look
to go thru pagecache_get_page() path, so all taken uncharged
pages will be properly charged. Thus, we enable AS_KEEP_MEMCG_RECLAIM
for ext4 regular files.
Since memcg accounting requires page lock, and function
generic_file_buffered_read() is the only of ext4-used
functions, which does not care about FGP_NOWAIT, we make
it use find_get_page_flags() and pass the flag. This allows
pagecache_get_page() to use lock_page(), when it's possible.
Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
---
fs/ext4/inode.c | 1 +
mm/filemap.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b1d7ddd70eee..2fc9e4a7c0db 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5065,6 +5065,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
inode->i_op = &ext4_file_inode_operations;
inode->i_fop = &ext4_file_operations;
ext4_set_aops(inode);
+ set_bit(AS_KEEP_MEMCG_RECLAIM, &inode->i_mapping->flags);
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op = &ext4_dir_inode_operations;
inode->i_fop = &ext4_dir_operations;
diff --git a/mm/filemap.c b/mm/filemap.c
index 2603c44fc74a..46922003811f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2061,6 +2061,11 @@ static void shrink_readahead_size_eio(struct file *filp,
ra->ra_pages /= 4;
}
+static int kiocb_fgp_flags(struct kiocb *iocb)
+{
+ return (iocb->ki_flags & IOCB_NOWAIT) ? FGP_NOWAIT : 0;
+}
+
/**
* generic_file_buffered_read - generic file read routine
* @iocb: the iocb to read
@@ -2111,7 +2116,8 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
goto out;
}
- page = find_get_page(mapping, index);
+ page = find_get_page_flags(mapping, index,
+ kiocb_fgp_flags(iocb));
if (!page) {
if (iocb->ki_flags & IOCB_NOWAIT)
goto would_block;
Powered by blists - more mailing lists