lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 15 Mar 2021 19:28:38 +0800
From:   Gao Xiang <hsiangkao@...hat.com>
To:     Huang Jianan <huangjianan@...o.com>
Cc:     zhangshiming@...o.com, guoweichao@...o.com,
        linux-erofs@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 2/2] erofs: decompress in endio if possible

On Fri, Mar 05, 2021 at 05:58:40PM +0800, Huang Jianan via Linux-erofs wrote:
> z_erofs_decompressqueue_endio may not be executed in the atomic
> context, for example, when dm-verity is turned on. In this scenario,
> data can be decompressed directly to get rid of additional kworker
> scheduling overhead. Also, it makes no sense to apply synchronous
> decompression for such case.
> 
> Signed-off-by: Huang Jianan <huangjianan@...o.com>
> Signed-off-by: Guo Weichao <guoweichao@...o.com>
> ---
>  fs/erofs/internal.h |  2 ++
>  fs/erofs/super.c    |  1 +
>  fs/erofs/zdata.c    | 16 +++++++++++++---
>  3 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 67a7ec945686..e325da7be237 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -53,6 +53,8 @@ struct erofs_fs_context {
>  
>  	/* threshold for decompression synchronously */
>  	unsigned int max_sync_decompress_pages;
> +	/* decide whether to decompress synchronously */
> +	bool readahead_sync_decompress;

I updated this as below:

 	/* current strategy of how to use managed cache */
 	unsigned char cache_strategy;
+	/* strategy of sync decompression (false - auto, true - force on) */
+	bool readahead_sync_decompress;
 
 	/* threshold for decompression synchronously */
 	unsigned int max_sync_decompress_pages;

>  #endif
>  	unsigned int mount_opt;
>  };

...

> @@ -720,8 +723,14 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,
>  		return;
>  	}
>  
> -	if (!atomic_add_return(bios, &io->pending_bios))
> -		queue_work(z_erofs_workqueue, &io->u.work);
> +	if (!atomic_add_return(bios, &io->pending_bios)) {
> +		if (in_atomic() || irqs_disabled()) {
> +			queue_work(z_erofs_workqueue, &io->u.work);
> +			sbi->ctx.readahead_sync_decompress = true;
> +		} else {
> +			z_erofs_decompressqueue_work(&io->u.work);
> +		}
> +	}

Also updated this as below to return as early as possible:

-	if (!atomic_add_return(bios, &io->pending_bios))
+	if (atomic_add_return(bios, &io->pending_bios))
+		return;
+	/* Use workqueue and sync decompression for atomic contexts only */
+	if (in_atomic() || irqs_disabled()) {
 		queue_work(z_erofs_workqueue, &io->u.work);
+		sbi->ctx.readahead_sync_decompress = true;
+		return;
+	}
+	z_erofs_decompressqueue_work(&io->u.work);
 }

Otherwise, it looks good to me. I've applied to dev-test
for preliminary testing.

Reviewed-by: Gao Xiang <hsiangkao@...hat.com>

Thanks,
Gao Xiang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ