LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Maninder Singh <maninder1.s@samsung.com>,
	terrelln@fb.com, herbert@gondor.apana.org.au,
	davem@davemloft.net, keescook@chromium.org,
	gustavo@embeddedor.com
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	a.sahrawat@samsung.com, pankaj.m@samsung.com,
	Vaneet Narang <v.narang@samsung.com>
Subject: Re: [PATCH 1/2] zstd: pass pointer rathen than structure to functions
Date: Fri, 10 May 2019 10:39:57 -0700	[thread overview]
Message-ID: <10021f43dc5b377340fde9a7716e083f6f1261c1.camel@perches.com> (raw)
In-Reply-To: <1557468704-3014-1-git-send-email-maninder1.s@samsung.com>

On Fri, 2019-05-10 at 11:41 +0530, Maninder Singh 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.
[]
> diff --git a/lib/zstd/compress.c b/lib/zstd/compress.c
[]
> @@ -206,18 +206,18 @@ ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, u
>  	return cPar;
>  }
>  
> -static U32 ZSTD_equivalentParams(ZSTD_parameters param1, ZSTD_parameters param2)
> +static U32 ZSTD_equivalentParams(const ZSTD_parameters *param1, const ZSTD_parameters *param2)
>  {
> -	return (param1.cParams.hashLog == param2.cParams.hashLog) & (param1.cParams.chainLog == param2.cParams.chainLog) &
> -	       (param1.cParams.strategy == param2.cParams.strategy) & ((param1.cParams.searchLength == 3) == (param2.cParams.searchLength == 3));
> +	return (param1->cParams.hashLog == param2->cParams.hashLog) & (param1->cParams.chainLog == param2->cParams.chainLog) &
> +	       (param1->cParams.strategy == param2->cParams.strategy) & ((param1->cParams.searchLength == 3) == (param2->cParams.searchLength == 3));
>  }

trivia:

Using & instead of && makes this somewhat difficult to read.
It's hard to believe this is a performance optimization.

It might be better as

	return param1->cParams.hashLog == param2->cParams.hashLog &&
	       param1->cParams.chainLog == param2->cParams.chainLog &&
	       param1->cParams.strategy == param2->cParams.strategy &&
	       param1->cParams.searchLength == 3 &&
	       param1->cParams.searchLength == param2->cParams.searchLength;



  reply	other threads:[~2019-05-10 17:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190510061311epcas5p19e9bf3d08319ac99890e03e0bd59e478@epcas5p1.samsung.com>
2019-05-10  6:11 ` Maninder Singh
2019-05-10 17:39   ` Joe Perches [this message]
     [not found]   ` <CGME20190510061311epcas5p19e9bf3d08319ac99890e03e0bd59e478@epcms5p1>
2019-05-30  9:13     ` Vaneet Narang
2019-05-30 13:35       ` Herbert Xu
2019-06-01  0:12         ` Andrew Morton

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=10021f43dc5b377340fde9a7716e083f6f1261c1.camel@perches.com \
    --to=joe@perches.com \
    --cc=a.sahrawat@samsung.com \
    --cc=davem@davemloft.net \
    --cc=gustavo@embeddedor.com \
    --cc=herbert@gondor.apana.org.au \
    --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=terrelln@fb.com \
    --cc=v.narang@samsung.com \
    --subject='Re: [PATCH 1/2] zstd: pass pointer rathen than structure to functions' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).