Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4651187ybi; Mon, 3 Jun 2019 14:48:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyC9jLkSguwwDteNIlffSugk86CBw0PJkOCT7NXOCDzsfjSGffsN5mJpITORCT2nFfQp419 X-Received: by 2002:a17:90a:35c:: with SMTP id 28mr31621118pjf.110.1559598515912; Mon, 03 Jun 2019 14:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559598515; cv=none; d=google.com; s=arc-20160816; b=bs5U3lmPCGcCCMvgVAlJ2HLnOJt86cgT9siH/15dAfnhsXaYKOjlUHC0LzEepoiH8T gJpFQH5jXfgKYnZ4k8wDo9md9xf7w8iMzctaN2vpt/u5CFZhpNnGSORiS9XpS9dD8hDJ rLb9+NnKk99GFAFKFAz0IJ3EOfsrmuel9SWf0DJELJ9DzpQRGOUVUibsNma05p6Um7M0 qlnNIjwo77//pKVDw5Vry0S9HmQBLQXr4ohEF4Uj+Ahy1bzauoN/hC4coVSARw8WGCcM 8/WsHilBeNwl189EvP2BIghB+aAYmk44puNrw73a2+BveVWP1DhATwDxwhUW97cMrPWY terQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=5UZxjkFMWbdou8DXxDr1mmoUkJ8G9LYmEqI5wd1jq80=; b=PIkLky0YepXQFchIc8HJqx+W2+vKEP2m7czF+dxvCl8tx8Du3k6CzZK98pPjerSi4s EYqSJgsFcNEdRS9IfxpctgetqYsaofCWJorGcNyO/5R+JfBx67iEuRn0oHrmLvVSx6iB vpdTOzOS8RRWl2BXAFq7z+Bg02796YkJFu7tiaPUbymoWPcb2goMPpNC4HHPdH0cIe1d RObEfyPMp7hNMYGS8iKRnUCFQophuYVuRz/52IpScg8JDR4bm2dH/Da70iJo84pULedR 2MFZUjd7qrUzDMF0TH8WJKZDzyKUJ9hOP4/XoWkKSMdPvAccQi2RoscimhQYmnbK/o1+ 1lDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ts63bHho; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si19338205plr.412.2019.06.03.14.48.21; Mon, 03 Jun 2019 14:48:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ts63bHho; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726538AbfFCVr0 (ORCPT + 99 others); Mon, 3 Jun 2019 17:47:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:36838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726223AbfFCVrZ (ORCPT ); Mon, 3 Jun 2019 17:47:25 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 25E4224695; Mon, 3 Jun 2019 21:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559598093; bh=IZXCj5jxf9eAYQwNueq6BzltjAUhCFsFwTi0mTPxogE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ts63bHhoHjEwHoguPS98FOlJlHULP9xS3Oy1wcT2MEqZrFAeXOpn3JlufH7Eef2pe ebYDM7je/lskiEV548m5LQpSvFwVrW5LJtk/f/QJ2udr71wF1m41GGZCC3hyChJZMB u+bdKxm2Nu+VwtMbYyqwJpCcxnq+j6gRC4KL67I0= Date: Mon, 3 Jun 2019 14:41:32 -0700 From: Andrew Morton To: Maninder Singh 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 Message-Id: <20190603144132.7611b8fe3cf6928d8391a24a@linux-foundation.org> In-Reply-To: <1559552526-4317-2-git-send-email-maninder1.s@samsung.com> References: <1559552526-4317-1-git-send-email-maninder1.s@samsung.com> <1559552526-4317-2-git-send-email-maninder1.s@samsung.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, 3 Jun 2019 14:32:03 +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. > > 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, ¶ms); > 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?