From: Christoph Hellwig hch@lst.de
mainline inclusion from mainline-v6.1-rc1 commit 99486c511f686c799bb4e60b79d79808bb9440f4 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8BCRJ CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
erofs uses an additional address space for compressed data read from disk in addition to the one directly associated with the inode. Reading into the lower address space is open coded using add_to_page_cache_lru instead of using the filemap.c helper for page allocation micro-optimizations, which means it is not covered by the MM PSI annotations for ->read_folio and ->readahead, so add manual ones instead.
Signed-off-by: Christoph Hellwig hch@lst.de Acked-by: Johannes Weiner hannes@cmpxchg.org Acked-by: Gao Xiang hsiangkao@linux.alibaba.com Link: https://lore.kernel.org/r/20220915094200.139713-5-hch@lst.de Signed-off-by: Jens Axboe axboe@kernel.dk Signed-off-by: Liu Shixin liushixin2@huawei.com --- fs/erofs/zdata.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 8cb2cf612e49b..004274bceae68 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -7,6 +7,7 @@ #include "zdata.h" #include "compress.h" #include <linux/prefetch.h> +#include <linux/psi.h>
#include <trace/events/erofs.h>
@@ -1165,6 +1166,8 @@ static void z_erofs_submit_queue(struct super_block *sb, pgoff_t last_index; unsigned int nr_bios = 0; struct bio *bio = NULL; + /* initialize to 1 to make skip psi_memstall_leave unless needed */ + unsigned long pflags = 1;
bi_private = jobqueueset_init(sb, q, fgq, force_fg); qtail[JQ_BYPASS] = &q[JQ_BYPASS]->head; @@ -1203,10 +1206,15 @@ static void z_erofs_submit_queue(struct super_block *sb,
if (bio && cur != last_index + 1) { submit_bio_retry: + if (!pflags) + psi_memstall_leave(&pflags); submit_bio(bio); bio = NULL; }
+ if (unlikely(PageWorkingset(page))) + psi_memstall_enter(&pflags); + if (!bio) { bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
@@ -1234,8 +1242,11 @@ static void z_erofs_submit_queue(struct super_block *sb, move_to_bypass_jobqueue(pcl, qtail, owned_head); } while (owned_head != Z_EROFS_PCLUSTER_TAIL);
- if (bio) + if (bio) { + if (!pflags) + psi_memstall_leave(&pflags); submit_bio(bio); + }
/* * although background is preferred, no one is pending for submission.