All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs: remove the fast path of per-CPU buffer decompression
@ 2021-10-14  5:57 ` Yue Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2021-10-14  5:57 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: linux-kernel, huyue2, zbestahu, zhangwen

From: Yue Hu <huyue2@yulong.com>

As Xiang mentioned, such path has no real impact to our current
decompression strategy, remove it directly. Also, update the return
value of z_erofs_lz4_decompress() to 0 if success to keep consistent
with LZMA which will return 0 as well for that case.

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 fs/erofs/decompressor.c | 64 +++++++------------------------------------------
 1 file changed, 8 insertions(+), 56 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index a5bc4b1..9905551 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -254,7 +254,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
 		DBG_BUGON(1);
 		return -EFAULT;
 	}
-	return ret;
+	return ret > 0 ? 0 : ret;
 }
 
 static struct z_erofs_decompressor decompressors[] = {
@@ -268,33 +268,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
 	},
 };
 
-static void copy_from_pcpubuf(struct page **out, const char *dst,
-			      unsigned short pageofs_out,
-			      unsigned int outputsize)
-{
-	const char *end = dst + outputsize;
-	const unsigned int righthalf = PAGE_SIZE - pageofs_out;
-	const char *cur = dst - pageofs_out;
-
-	while (cur < end) {
-		struct page *const page = *out++;
-
-		if (page) {
-			char *buf = kmap_atomic(page);
-
-			if (cur >= dst) {
-				memcpy(buf, cur, min_t(uint, PAGE_SIZE,
-						       end - cur));
-			} else {
-				memcpy(buf + pageofs_out, cur + pageofs_out,
-				       min_t(uint, righthalf, end - cur));
-			}
-			kunmap_atomic(buf);
-		}
-		cur += PAGE_SIZE;
-	}
-}
-
 static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
 				      struct list_head *pagepool)
 {
@@ -305,34 +278,13 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
 	void *dst;
 	int ret;
 
-	/* two optimized fast paths only for non bigpcluster cases yet */
-	if (rq->inputsize <= PAGE_SIZE) {
-		if (nrpages_out == 1 && !rq->inplace_io) {
-			DBG_BUGON(!*rq->out);
-			dst = kmap_atomic(*rq->out);
-			dst_maptype = 0;
-			goto dstmap_out;
-		}
-
-		/*
-		 * For the case of small output size (especially much less
-		 * than PAGE_SIZE), memcpy the decompressed data rather than
-		 * compressed data is preferred.
-		 */
-		if (rq->outputsize <= PAGE_SIZE * 7 / 8) {
-			dst = erofs_get_pcpubuf(1);
-			if (IS_ERR(dst))
-				return PTR_ERR(dst);
-
-			rq->inplace_io = false;
-			ret = alg->decompress(rq, dst);
-			if (!ret)
-				copy_from_pcpubuf(rq->out, dst, rq->pageofs_out,
-						  rq->outputsize);
-
-			erofs_put_pcpubuf(dst);
-			return ret;
-		}
+	/* one optimized fast path only for non bigpcluster cases yet */
+	if (rq->inputsize <= PAGE_SIZE &&
+	    nrpages_out == 1 && !rq->inplace_io) {
+		DBG_BUGON(!*rq->out);
+		dst = kmap_atomic(*rq->out);
+		dst_maptype = 0;
+		goto dstmap_out;
 	}
 
 	/* general decoding path which can be used for all cases */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] erofs: remove the fast path of per-CPU buffer decompression
@ 2021-10-14  5:57 ` Yue Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2021-10-14  5:57 UTC (permalink / raw)
  To: xiang, chao, linux-erofs; +Cc: huyue2, zhangwen, linux-kernel, zbestahu

From: Yue Hu <huyue2@yulong.com>

As Xiang mentioned, such path has no real impact to our current
decompression strategy, remove it directly. Also, update the return
value of z_erofs_lz4_decompress() to 0 if success to keep consistent
with LZMA which will return 0 as well for that case.

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 fs/erofs/decompressor.c | 64 +++++++------------------------------------------
 1 file changed, 8 insertions(+), 56 deletions(-)

diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index a5bc4b1..9905551 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -254,7 +254,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
 		DBG_BUGON(1);
 		return -EFAULT;
 	}
-	return ret;
+	return ret > 0 ? 0 : ret;
 }
 
 static struct z_erofs_decompressor decompressors[] = {
@@ -268,33 +268,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
 	},
 };
 
-static void copy_from_pcpubuf(struct page **out, const char *dst,
-			      unsigned short pageofs_out,
-			      unsigned int outputsize)
-{
-	const char *end = dst + outputsize;
-	const unsigned int righthalf = PAGE_SIZE - pageofs_out;
-	const char *cur = dst - pageofs_out;
-
-	while (cur < end) {
-		struct page *const page = *out++;
-
-		if (page) {
-			char *buf = kmap_atomic(page);
-
-			if (cur >= dst) {
-				memcpy(buf, cur, min_t(uint, PAGE_SIZE,
-						       end - cur));
-			} else {
-				memcpy(buf + pageofs_out, cur + pageofs_out,
-				       min_t(uint, righthalf, end - cur));
-			}
-			kunmap_atomic(buf);
-		}
-		cur += PAGE_SIZE;
-	}
-}
-
 static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
 				      struct list_head *pagepool)
 {
@@ -305,34 +278,13 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
 	void *dst;
 	int ret;
 
-	/* two optimized fast paths only for non bigpcluster cases yet */
-	if (rq->inputsize <= PAGE_SIZE) {
-		if (nrpages_out == 1 && !rq->inplace_io) {
-			DBG_BUGON(!*rq->out);
-			dst = kmap_atomic(*rq->out);
-			dst_maptype = 0;
-			goto dstmap_out;
-		}
-
-		/*
-		 * For the case of small output size (especially much less
-		 * than PAGE_SIZE), memcpy the decompressed data rather than
-		 * compressed data is preferred.
-		 */
-		if (rq->outputsize <= PAGE_SIZE * 7 / 8) {
-			dst = erofs_get_pcpubuf(1);
-			if (IS_ERR(dst))
-				return PTR_ERR(dst);
-
-			rq->inplace_io = false;
-			ret = alg->decompress(rq, dst);
-			if (!ret)
-				copy_from_pcpubuf(rq->out, dst, rq->pageofs_out,
-						  rq->outputsize);
-
-			erofs_put_pcpubuf(dst);
-			return ret;
-		}
+	/* one optimized fast path only for non bigpcluster cases yet */
+	if (rq->inputsize <= PAGE_SIZE &&
+	    nrpages_out == 1 && !rq->inplace_io) {
+		DBG_BUGON(!*rq->out);
+		dst = kmap_atomic(*rq->out);
+		dst_maptype = 0;
+		goto dstmap_out;
 	}
 
 	/* general decoding path which can be used for all cases */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs: remove the fast path of per-CPU buffer decompression
  2021-10-14  5:57 ` Yue Hu
@ 2021-10-14  6:16   ` Gao Xiang
  -1 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2021-10-14  6:16 UTC (permalink / raw)
  To: Yue Hu; +Cc: xiang, chao, linux-erofs, linux-kernel, huyue2, zbestahu, zhangwen

On Thu, Oct 14, 2021 at 01:57:56PM +0800, Yue Hu wrote:
> From: Yue Hu <huyue2@yulong.com>
> 
> As Xiang mentioned, such path has no real impact to our current
> decompression strategy, remove it directly. Also, update the return
> value of z_erofs_lz4_decompress() to 0 if success to keep consistent
> with LZMA which will return 0 as well for that case.
> 
> Signed-off-by: Yue Hu <huyue2@yulong.com>
> ---
>  fs/erofs/decompressor.c | 64 +++++++------------------------------------------
>  1 file changed, 8 insertions(+), 56 deletions(-)
> 
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index a5bc4b1..9905551 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -254,7 +254,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
>  		DBG_BUGON(1);
>  		return -EFAULT;
>  	}
> -	return ret;
> +	return ret > 0 ? 0 : ret;

How about just updating the else branch of "if (ret != rq->outputsize)"?

>  }
>  
>  static struct z_erofs_decompressor decompressors[] = {
> @@ -268,33 +268,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
>  	},
>  };
>  
> -static void copy_from_pcpubuf(struct page **out, const char *dst,
> -			      unsigned short pageofs_out,
> -			      unsigned int outputsize)
> -{
> -	const char *end = dst + outputsize;
> -	const unsigned int righthalf = PAGE_SIZE - pageofs_out;
> -	const char *cur = dst - pageofs_out;
> -
> -	while (cur < end) {
> -		struct page *const page = *out++;
> -
> -		if (page) {
> -			char *buf = kmap_atomic(page);
> -
> -			if (cur >= dst) {
> -				memcpy(buf, cur, min_t(uint, PAGE_SIZE,
> -						       end - cur));
> -			} else {
> -				memcpy(buf + pageofs_out, cur + pageofs_out,
> -				       min_t(uint, righthalf, end - cur));
> -			}
> -			kunmap_atomic(buf);
> -		}
> -		cur += PAGE_SIZE;
> -	}
> -}
> -
>  static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
>  				      struct list_head *pagepool)
>  {
> @@ -305,34 +278,13 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
>  	void *dst;
>  	int ret;
>  
> -	/* two optimized fast paths only for non bigpcluster cases yet */
> -	if (rq->inputsize <= PAGE_SIZE) {
> -		if (nrpages_out == 1 && !rq->inplace_io) {
> -			DBG_BUGON(!*rq->out);
> -			dst = kmap_atomic(*rq->out);
> -			dst_maptype = 0;
> -			goto dstmap_out;
> -		}
> -
> -		/*
> -		 * For the case of small output size (especially much less
> -		 * than PAGE_SIZE), memcpy the decompressed data rather than
> -		 * compressed data is preferred.
> -		 */
> -		if (rq->outputsize <= PAGE_SIZE * 7 / 8) {
> -			dst = erofs_get_pcpubuf(1);
> -			if (IS_ERR(dst))
> -				return PTR_ERR(dst);
> -
> -			rq->inplace_io = false;
> -			ret = alg->decompress(rq, dst);
> -			if (!ret)
> -				copy_from_pcpubuf(rq->out, dst, rq->pageofs_out,
> -						  rq->outputsize);
> -
> -			erofs_put_pcpubuf(dst);
> -			return ret;
> -		}
> +	/* one optimized fast path only for non bigpcluster cases yet */
> +	if (rq->inputsize <= PAGE_SIZE &&
> +	    nrpages_out == 1 && !rq->inplace_io) {

How about rearrange these into one line? (it seems just 80 char).

Otherwise looks good to me.

Thanks,
Gao Xiang

> +		DBG_BUGON(!*rq->out);
> +		dst = kmap_atomic(*rq->out);
> +		dst_maptype = 0;
> +		goto dstmap_out;
>  	}
>  
>  	/* general decoding path which can be used for all cases */
> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs: remove the fast path of per-CPU buffer decompression
@ 2021-10-14  6:16   ` Gao Xiang
  0 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2021-10-14  6:16 UTC (permalink / raw)
  To: Yue Hu; +Cc: linux-kernel, zbestahu, huyue2, linux-erofs, zhangwen

On Thu, Oct 14, 2021 at 01:57:56PM +0800, Yue Hu wrote:
> From: Yue Hu <huyue2@yulong.com>
> 
> As Xiang mentioned, such path has no real impact to our current
> decompression strategy, remove it directly. Also, update the return
> value of z_erofs_lz4_decompress() to 0 if success to keep consistent
> with LZMA which will return 0 as well for that case.
> 
> Signed-off-by: Yue Hu <huyue2@yulong.com>
> ---
>  fs/erofs/decompressor.c | 64 +++++++------------------------------------------
>  1 file changed, 8 insertions(+), 56 deletions(-)
> 
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index a5bc4b1..9905551 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -254,7 +254,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
>  		DBG_BUGON(1);
>  		return -EFAULT;
>  	}
> -	return ret;
> +	return ret > 0 ? 0 : ret;

How about just updating the else branch of "if (ret != rq->outputsize)"?

>  }
>  
>  static struct z_erofs_decompressor decompressors[] = {
> @@ -268,33 +268,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
>  	},
>  };
>  
> -static void copy_from_pcpubuf(struct page **out, const char *dst,
> -			      unsigned short pageofs_out,
> -			      unsigned int outputsize)
> -{
> -	const char *end = dst + outputsize;
> -	const unsigned int righthalf = PAGE_SIZE - pageofs_out;
> -	const char *cur = dst - pageofs_out;
> -
> -	while (cur < end) {
> -		struct page *const page = *out++;
> -
> -		if (page) {
> -			char *buf = kmap_atomic(page);
> -
> -			if (cur >= dst) {
> -				memcpy(buf, cur, min_t(uint, PAGE_SIZE,
> -						       end - cur));
> -			} else {
> -				memcpy(buf + pageofs_out, cur + pageofs_out,
> -				       min_t(uint, righthalf, end - cur));
> -			}
> -			kunmap_atomic(buf);
> -		}
> -		cur += PAGE_SIZE;
> -	}
> -}
> -
>  static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
>  				      struct list_head *pagepool)
>  {
> @@ -305,34 +278,13 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
>  	void *dst;
>  	int ret;
>  
> -	/* two optimized fast paths only for non bigpcluster cases yet */
> -	if (rq->inputsize <= PAGE_SIZE) {
> -		if (nrpages_out == 1 && !rq->inplace_io) {
> -			DBG_BUGON(!*rq->out);
> -			dst = kmap_atomic(*rq->out);
> -			dst_maptype = 0;
> -			goto dstmap_out;
> -		}
> -
> -		/*
> -		 * For the case of small output size (especially much less
> -		 * than PAGE_SIZE), memcpy the decompressed data rather than
> -		 * compressed data is preferred.
> -		 */
> -		if (rq->outputsize <= PAGE_SIZE * 7 / 8) {
> -			dst = erofs_get_pcpubuf(1);
> -			if (IS_ERR(dst))
> -				return PTR_ERR(dst);
> -
> -			rq->inplace_io = false;
> -			ret = alg->decompress(rq, dst);
> -			if (!ret)
> -				copy_from_pcpubuf(rq->out, dst, rq->pageofs_out,
> -						  rq->outputsize);
> -
> -			erofs_put_pcpubuf(dst);
> -			return ret;
> -		}
> +	/* one optimized fast path only for non bigpcluster cases yet */
> +	if (rq->inputsize <= PAGE_SIZE &&
> +	    nrpages_out == 1 && !rq->inplace_io) {

How about rearrange these into one line? (it seems just 80 char).

Otherwise looks good to me.

Thanks,
Gao Xiang

> +		DBG_BUGON(!*rq->out);
> +		dst = kmap_atomic(*rq->out);
> +		dst_maptype = 0;
> +		goto dstmap_out;
>  	}
>  
>  	/* general decoding path which can be used for all cases */
> -- 
> 1.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs: remove the fast path of per-CPU buffer decompression
  2021-10-14  6:16   ` Gao Xiang
@ 2021-10-14  6:29     ` Yue Hu
  -1 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2021-10-14  6:29 UTC (permalink / raw)
  To: Gao Xiang
  Cc: xiang, chao, linux-erofs, linux-kernel, huyue2, zbestahu, zhangwen

On Thu, 14 Oct 2021 14:16:48 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:

> On Thu, Oct 14, 2021 at 01:57:56PM +0800, Yue Hu wrote:
> > From: Yue Hu <huyue2@yulong.com>
> > 
> > As Xiang mentioned, such path has no real impact to our current
> > decompression strategy, remove it directly. Also, update the return
> > value of z_erofs_lz4_decompress() to 0 if success to keep consistent
> > with LZMA which will return 0 as well for that case.
> > 
> > Signed-off-by: Yue Hu <huyue2@yulong.com>
> > ---
> >  fs/erofs/decompressor.c | 64 +++++++------------------------------------------
> >  1 file changed, 8 insertions(+), 56 deletions(-)
> > 
> > diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> > index a5bc4b1..9905551 100644
> > --- a/fs/erofs/decompressor.c
> > +++ b/fs/erofs/decompressor.c
> > @@ -254,7 +254,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
> >  		DBG_BUGON(1);
> >  		return -EFAULT;
> >  	}
> > -	return ret;
> > +	return ret > 0 ? 0 : ret;  
> 
> How about just updating the else branch of "if (ret != rq->outputsize)"?

Agree.

> 
> >  }
> >  
> >  static struct z_erofs_decompressor decompressors[] = {
> > @@ -268,33 +268,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
> >  	},
> >  };
> >  
> > -static void copy_from_pcpubuf(struct page **out, const char *dst,
> > -			      unsigned short pageofs_out,
> > -			      unsigned int outputsize)
> > -{
> > -	const char *end = dst + outputsize;
> > -	const unsigned int righthalf = PAGE_SIZE - pageofs_out;
> > -	const char *cur = dst - pageofs_out;
> > -
> > -	while (cur < end) {
> > -		struct page *const page = *out++;
> > -
> > -		if (page) {
> > -			char *buf = kmap_atomic(page);
> > -
> > -			if (cur >= dst) {
> > -				memcpy(buf, cur, min_t(uint, PAGE_SIZE,
> > -						       end - cur));
> > -			} else {
> > -				memcpy(buf + pageofs_out, cur + pageofs_out,
> > -				       min_t(uint, righthalf, end - cur));
> > -			}
> > -			kunmap_atomic(buf);
> > -		}
> > -		cur += PAGE_SIZE;
> > -	}
> > -}
> > -
> >  static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
> >  				      struct list_head *pagepool)
> >  {
> > @@ -305,34 +278,13 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
> >  	void *dst;
> >  	int ret;
> >  
> > -	/* two optimized fast paths only for non bigpcluster cases yet */
> > -	if (rq->inputsize <= PAGE_SIZE) {
> > -		if (nrpages_out == 1 && !rq->inplace_io) {
> > -			DBG_BUGON(!*rq->out);
> > -			dst = kmap_atomic(*rq->out);
> > -			dst_maptype = 0;
> > -			goto dstmap_out;
> > -		}
> > -
> > -		/*
> > -		 * For the case of small output size (especially much less
> > -		 * than PAGE_SIZE), memcpy the decompressed data rather than
> > -		 * compressed data is preferred.
> > -		 */
> > -		if (rq->outputsize <= PAGE_SIZE * 7 / 8) {
> > -			dst = erofs_get_pcpubuf(1);
> > -			if (IS_ERR(dst))
> > -				return PTR_ERR(dst);
> > -
> > -			rq->inplace_io = false;
> > -			ret = alg->decompress(rq, dst);
> > -			if (!ret)
> > -				copy_from_pcpubuf(rq->out, dst, rq->pageofs_out,
> > -						  rq->outputsize);
> > -
> > -			erofs_put_pcpubuf(dst);
> > -			return ret;
> > -		}
> > +	/* one optimized fast path only for non bigpcluster cases yet */
> > +	if (rq->inputsize <= PAGE_SIZE &&
> > +	    nrpages_out == 1 && !rq->inplace_io) {  
> 
> How about rearrange these into one line? (it seems just 80 char).

aha, seems it's. 

v2 will fix them.

Thanks.

> 
> Otherwise looks good to me.
> 
> Thanks,
> Gao Xiang
> 
> > +		DBG_BUGON(!*rq->out);
> > +		dst = kmap_atomic(*rq->out);
> > +		dst_maptype = 0;
> > +		goto dstmap_out;
> >  	}
> >  
> >  	/* general decoding path which can be used for all cases */
> > -- 
> > 1.9.1  


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] erofs: remove the fast path of per-CPU buffer decompression
@ 2021-10-14  6:29     ` Yue Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2021-10-14  6:29 UTC (permalink / raw)
  To: Gao Xiang; +Cc: linux-kernel, zbestahu, huyue2, linux-erofs, zhangwen

On Thu, 14 Oct 2021 14:16:48 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:

> On Thu, Oct 14, 2021 at 01:57:56PM +0800, Yue Hu wrote:
> > From: Yue Hu <huyue2@yulong.com>
> > 
> > As Xiang mentioned, such path has no real impact to our current
> > decompression strategy, remove it directly. Also, update the return
> > value of z_erofs_lz4_decompress() to 0 if success to keep consistent
> > with LZMA which will return 0 as well for that case.
> > 
> > Signed-off-by: Yue Hu <huyue2@yulong.com>
> > ---
> >  fs/erofs/decompressor.c | 64 +++++++------------------------------------------
> >  1 file changed, 8 insertions(+), 56 deletions(-)
> > 
> > diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> > index a5bc4b1..9905551 100644
> > --- a/fs/erofs/decompressor.c
> > +++ b/fs/erofs/decompressor.c
> > @@ -254,7 +254,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
> >  		DBG_BUGON(1);
> >  		return -EFAULT;
> >  	}
> > -	return ret;
> > +	return ret > 0 ? 0 : ret;  
> 
> How about just updating the else branch of "if (ret != rq->outputsize)"?

Agree.

> 
> >  }
> >  
> >  static struct z_erofs_decompressor decompressors[] = {
> > @@ -268,33 +268,6 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
> >  	},
> >  };
> >  
> > -static void copy_from_pcpubuf(struct page **out, const char *dst,
> > -			      unsigned short pageofs_out,
> > -			      unsigned int outputsize)
> > -{
> > -	const char *end = dst + outputsize;
> > -	const unsigned int righthalf = PAGE_SIZE - pageofs_out;
> > -	const char *cur = dst - pageofs_out;
> > -
> > -	while (cur < end) {
> > -		struct page *const page = *out++;
> > -
> > -		if (page) {
> > -			char *buf = kmap_atomic(page);
> > -
> > -			if (cur >= dst) {
> > -				memcpy(buf, cur, min_t(uint, PAGE_SIZE,
> > -						       end - cur));
> > -			} else {
> > -				memcpy(buf + pageofs_out, cur + pageofs_out,
> > -				       min_t(uint, righthalf, end - cur));
> > -			}
> > -			kunmap_atomic(buf);
> > -		}
> > -		cur += PAGE_SIZE;
> > -	}
> > -}
> > -
> >  static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
> >  				      struct list_head *pagepool)
> >  {
> > @@ -305,34 +278,13 @@ static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
> >  	void *dst;
> >  	int ret;
> >  
> > -	/* two optimized fast paths only for non bigpcluster cases yet */
> > -	if (rq->inputsize <= PAGE_SIZE) {
> > -		if (nrpages_out == 1 && !rq->inplace_io) {
> > -			DBG_BUGON(!*rq->out);
> > -			dst = kmap_atomic(*rq->out);
> > -			dst_maptype = 0;
> > -			goto dstmap_out;
> > -		}
> > -
> > -		/*
> > -		 * For the case of small output size (especially much less
> > -		 * than PAGE_SIZE), memcpy the decompressed data rather than
> > -		 * compressed data is preferred.
> > -		 */
> > -		if (rq->outputsize <= PAGE_SIZE * 7 / 8) {
> > -			dst = erofs_get_pcpubuf(1);
> > -			if (IS_ERR(dst))
> > -				return PTR_ERR(dst);
> > -
> > -			rq->inplace_io = false;
> > -			ret = alg->decompress(rq, dst);
> > -			if (!ret)
> > -				copy_from_pcpubuf(rq->out, dst, rq->pageofs_out,
> > -						  rq->outputsize);
> > -
> > -			erofs_put_pcpubuf(dst);
> > -			return ret;
> > -		}
> > +	/* one optimized fast path only for non bigpcluster cases yet */
> > +	if (rq->inputsize <= PAGE_SIZE &&
> > +	    nrpages_out == 1 && !rq->inplace_io) {  
> 
> How about rearrange these into one line? (it seems just 80 char).

aha, seems it's. 

v2 will fix them.

Thanks.

> 
> Otherwise looks good to me.
> 
> Thanks,
> Gao Xiang
> 
> > +		DBG_BUGON(!*rq->out);
> > +		dst = kmap_atomic(*rq->out);
> > +		dst_maptype = 0;
> > +		goto dstmap_out;
> >  	}
> >  
> >  	/* general decoding path which can be used for all cases */
> > -- 
> > 1.9.1  


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-14  6:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14  5:57 [PATCH] erofs: remove the fast path of per-CPU buffer decompression Yue Hu
2021-10-14  5:57 ` Yue Hu
2021-10-14  6:16 ` Gao Xiang
2021-10-14  6:16   ` Gao Xiang
2021-10-14  6:29   ` Yue Hu
2021-10-14  6:29     ` Yue Hu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.