Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b3398c3 authored by Huang Jianan's avatar Huang Jianan Committed by Gao Xiang
Browse files

erofs: use sync decompression for atomic contexts only

Sync decompression was introduced to get rid of additional kworker
scheduling overhead. But there is no such overhead in non-atomic
contexts. Therefore, it should be better to turn off sync decompression
to avoid the current thread waiting in z_erofs_runqueue.

Link: https://lore.kernel.org/r/20210317035448.13921-3-huangjianan@oppo.com


Reviewed-by: default avatarGao Xiang <hsiangkao@redhat.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarHuang Jianan <huangjianan@oppo.com>
Signed-off-by: default avatarGuo Weichao <guoweichao@oppo.com>
Signed-off-by: default avatarGao Xiang <hsiangkao@redhat.com>
parent 076924e0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,9 @@ struct erofs_sb_info {
	/* the dedicated workstation for compression */
	struct radix_tree_root workstn_tree;

	/* strategy of sync decompression (false - auto, true - force on) */
	bool readahead_sync_decompress;

	/* threshold for decompression synchronously */
	unsigned int max_sync_decompress_pages;

+1 −0
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@ static void erofs_default_options(struct erofs_sb_info *sbi)
#ifdef CONFIG_EROFS_FS_ZIP
	sbi->cache_strategy = EROFS_ZIP_CACHE_READAROUND;
	sbi->max_sync_decompress_pages = 3;
	sbi->readahead_sync_decompress = false;
#endif
#ifdef CONFIG_EROFS_FS_XATTR
	set_opt(sbi, XATTR_USER);
+6 −2
Original line number Diff line number Diff line
@@ -712,6 +712,8 @@ static void z_erofs_decompressqueue_work(struct work_struct *work);
static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,
				       bool sync, int bios)
{
	struct erofs_sb_info *const sbi = EROFS_SB(io->sb);

	/* wake up the caller thread for sync decompression */
	if (sync) {
		unsigned long flags;
@@ -725,9 +727,10 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,

	if (atomic_add_return(bios, &io->pending_bios))
		return;
	/* Use workqueue decompression for atomic contexts only */
	/* Use workqueue and sync decompression for atomic contexts only */
	if (in_atomic() || irqs_disabled()) {
		queue_work(z_erofs_workqueue, &io->u.work);
		sbi->readahead_sync_decompress = true;
		return;
	}
	z_erofs_decompressqueue_work(&io->u.work);
@@ -1341,7 +1344,8 @@ static int z_erofs_readpages(struct file *filp, struct address_space *mapping,
	struct inode *const inode = mapping->host;
	struct erofs_sb_info *const sbi = EROFS_I_SB(inode);

	bool sync = (nr_pages <= sbi->max_sync_decompress_pages);
	bool sync = (sbi->readahead_sync_decompress &&
			nr_pages <= sbi->max_sync_decompress_pages);
	struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode);
	gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL);
	struct page *head = NULL;