mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Maninder Singh <maninder1.s@samsung.com>
Cc: herbert@gondor.apana.org.au, davem@davemloft.net,
	keescook@chromium.org, gustavo@embeddedor.com, joe@perches.com,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	a.sahrawat@samsung.com, pankaj.m@samsung.com,
	v.narang@samsung.com
Subject: Re: [PATCH 1/4] zstd: pass pointer rathen than structure to functions
Date: Mon, 3 Jun 2019 14:41:32 -0700	[thread overview]
Message-ID: <20190603144132.7611b8fe3cf6928d8391a24a@linux-foundation.org> (raw)
In-Reply-To: <1559552526-4317-2-git-send-email-maninder1.s@samsung.com>

On Mon,  3 Jun 2019 14:32:03 +0530 Maninder Singh <maninder1.s@samsung.com> wrote:

> currently params structure is passed in all functions, which increases
> stack usage in all the function and lead to stack overflow on target like
> ARM with kernel stack size of 8 KB so better to pass pointer.
> 
> Checked for ARM:
> 
>                                 Original               Patched
> Call FLow Size:                  1264                   1040
> ....
> (HUF_sort)                      -> 296
> (HUF_buildCTable_wksp)          -> 144
> (HUF_compress4X_repeat)         -> 88
> (ZSTD_compressBlock_internal)   -> 200
> (ZSTD_compressContinue_internal)-> 136                  -> 88
> (ZSTD_compressCCtx)             -> 192                  -> 64
> (zstd_compress)                 -> 144                  -> 96
> (crypto_compress)               -> 32
> (zcomp_compress)                -> 32
> ....
> 
> ...
>
> --- a/crypto/zstd.c
> +++ b/crypto/zstd.c
> @@ -162,7 +162,7 @@ static int __zstd_compress(const u8 *src, unsigned int slen,
>  	struct zstd_ctx *zctx = ctx;
>  	const ZSTD_parameters params = zstd_params();
>  
> -	out_len = ZSTD_compressCCtx(zctx->cctx, dst, *dlen, src, slen, params);
> +	out_len = ZSTD_compressCCtx(zctx->cctx, dst, *dlen, src, slen, &params);
>  	if (ZSTD_isError(out_len))
>  		return -EINVAL;
>  	*dlen = out_len;
> diff --git a/include/linux/zstd.h b/include/linux/zstd.h
> index 249575e..5103efa 100644
> --- a/include/linux/zstd.h
> +++ b/include/linux/zstd.h
> @@ -254,7 +254,7 @@ ZSTD_CCtx *ZSTD_initCCtx(void *workspace, size_t workspaceSize);
>   *               ZSTD_isError().
>   */
>  size_t ZSTD_compressCCtx(ZSTD_CCtx *ctx, void *dst, size_t dstCapacity,
> -	const void *src, size_t srcSize, ZSTD_parameters params);
> +	const void *src, size_t srcSize, const ZSTD_parameters *params);

Making the params poniter const made review a lot easier ;)

But struct ZSTD_CCtx_s.params is still a copied structure.  Could we
make it `const ZSTD_parameters *params'?  Probably not, due to lifetime
issues?



  reply	other threads:[~2019-06-03 21:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190603090227epcas5p348327061a3facbb9dfcf662bf2bc196e@epcas5p3.samsung.com>
2019-06-03  9:02 ` [PATCH 0/4] zstd: reduce stack usage Maninder Singh
     [not found]   ` <CGME20190603090232epcas5p1630d0584e8a1aa9495edc819605664fc@epcas5p1.samsung.com>
2019-06-03  9:02     ` [PATCH 1/4] zstd: pass pointer rathen than structure to functions Maninder Singh
2019-06-03 21:41       ` Andrew Morton [this message]
     [not found]       ` <CGME20190603090232epcas5p1630d0584e8a1aa9495edc819605664fc@epcms5p1>
2019-06-04 13:19         ` Vaneet Narang
2019-06-06 14:10         ` Vaneet Narang
2019-06-06 20:14           ` (2) " Nick Terrell
2019-06-04 22:43       ` Andrew Morton
2019-06-05 11:57         ` David Sterba
2019-06-05 12:32           ` David Sterba
2019-06-05 21:32             ` Andrew Morton
     [not found]   ` <CGME20190603090236epcas5p1bf0733024f7fb52f8129157b11c8f882@epcas5p1.samsung.com>
2019-06-03  9:02     ` [PATCH 2/4] zstd: use U16 data type for rankPos Maninder Singh
     [not found]   ` <CGME20190603090240epcas5p17d0881686df3fa3042d0b2d659e925b3@epcas5p1.samsung.com>
2019-06-03  9:02     ` [PATCH 3/4] zstd: move params structure to global variable to reduce stack usage Maninder Singh
2019-06-03 21:47       ` Andrew Morton
     [not found]   ` <CGME20190603090245epcas5p4a6cdfdb7ef72bfd36472f43bb4e1e0f1@epcas5p4.samsung.com>
2019-06-03  9:02     ` [PATCH 4/4] zstd: change structure variable from int to char Maninder Singh
2019-06-03 21:49   ` [PATCH 0/4] zstd: reduce stack usage Andrew Morton
     [not found]   ` <CGME20190603090227epcas5p348327061a3facbb9dfcf662bf2bc196e@epcms5p3>
2019-06-04 12:06     ` Vaneet Narang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190603144132.7611b8fe3cf6928d8391a24a@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=a.sahrawat@samsung.com \
    --cc=davem@davemloft.net \
    --cc=gustavo@embeddedor.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maninder1.s@samsung.com \
    --cc=pankaj.m@samsung.com \
    --cc=v.narang@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®