[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <10021f43dc5b377340fde9a7716e083f6f1261c1.camel@perches.com>
Date: Fri, 10 May 2019 10:39:57 -0700
From: Joe Perches <joe@...ches.com>
To: Maninder Singh <maninder1.s@...sung.com>, terrelln@...com,
herbert@...dor.apana.org.au, davem@...emloft.net,
keescook@...omium.org, gustavo@...eddedor.com
Cc: linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
a.sahrawat@...sung.com, pankaj.m@...sung.com,
Vaneet Narang <v.narang@...sung.com>
Subject: Re: [PATCH 1/2] zstd: pass pointer rathen than structure to
functions
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;
Powered by blists - more mailing lists