Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6725628ybi; Wed, 5 Jun 2019 05:34:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8Y6pSSH3mV7XiQqkytn6/NMSoP2m2mge7VQmWJpfTCb3G42zeh5xgGjvfxHbKTdKxxciN X-Received: by 2002:a63:6e48:: with SMTP id j69mr4018707pgc.34.1559738070977; Wed, 05 Jun 2019 05:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559738070; cv=none; d=google.com; s=arc-20160816; b=xH5dG/J5GzO++N0O/XZs6W1qsST8+e1uIzEUA4DaOZVKiegmJLuQvHV3XQSOlDo+tc RUIrXFtXLhLYZcXjR5gP2jJGXKUy8ZuOTFsPZeiDUCTgchh6PyhpevPHoBtazdKN/uji BDdRuoK/lrwbWpEAagJC9nlVW27+GxQISnOdXvxDbaT4L27pxc1CZ0iuEMX5ZMYWexFI 8YLQpZKt4ehR90caFNU1FAzjBaLJ/OPF31hZLnAcJK22cfWpONOtbxgEBBKUMlXkc2ti 6qSLEJ8WH08EpXLiIbE5WyHJwAVxZBf3m87vIdIcr9crnPLCoWWKJtiey9We9OIG0idr 5Mgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:to:from:date; bh=+yIAVJvPBkelglFyY1bIbSfA6sHX9fhCJbwf9PSatf4=; b=eERoN8kyNQ0+QzOrQvkSnWEYmGOgXLoubSF0UgWmg6IMT5kD76j9SaOFbKb9mpjpFL qHdqmHsv/diylzMet8r4kdUqnm9EWK5v1hDRGN9ka9xYIziDubT5kNCKv51BVu0H0s/t XG1oJA1ewvyrRtstYq63dBu7bn/cucGVXSBjkIbkIGIvMbhdtWy5SeGLzZi0Jjv/Nv3e Bly8PxHU53/EXg+KA505/wiztCx8fq0cD3GbQSMMNnyOkvdFtVWDkqJ9iMparNCz2kB4 LhcUQqcpm5rck7Z3nHIt69K/W5PHudH0EBKIxsw2gqsWV2d8drer/NEoyxvYBcpL138P V+UQ== ARC-Authentication-Results: i=1; mx.google.com; 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 c6si13326078pgn.427.2019.06.05.05.34.10; Wed, 05 Jun 2019 05:34:30 -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; 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 S1727589AbfFEMcG (ORCPT + 99 others); Wed, 5 Jun 2019 08:32:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:41920 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727461AbfFEMcF (ORCPT ); Wed, 5 Jun 2019 08:32:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8D62CAE8B; Wed, 5 Jun 2019 12:32:03 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 1D58EDA843; Wed, 5 Jun 2019 14:32:54 +0200 (CEST) Date: Wed, 5 Jun 2019 14:32:53 +0200 From: David Sterba To: Andrew Morton , Maninder Singh , 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, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, terrelln@fb.com Subject: Re: [PATCH 1/4] zstd: pass pointer rathen than structure to functions Message-ID: <20190605123253.GZ15290@suse.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Andrew Morton , Maninder Singh , 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, Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, terrelln@fb.com References: <1559552526-4317-1-git-send-email-maninder1.s@samsung.com> <1559552526-4317-2-git-send-email-maninder1.s@samsung.com> <20190604154326.8868a10f896c148a0ce804d1@linux-foundation.org> <20190605115703.GY15290@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190605115703.GY15290@twin.jikos.cz> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jun 05, 2019 at 01:57:03PM +0200, David Sterba wrote: > On Tue, Jun 04, 2019 at 03:43:26PM -0700, Andrew Morton wrote: > > 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 > > > .... > > > > > > Signed-off-by: Maninder Singh > > > Signed-off-by: Vaneet Narang > > > > > > > You missed btrfs. This needs review, please - particularly the > > kernel-wide static ZSTD_parameters in zstd_get_btrfs_parameters(). > > > > > The base patch is here: > > > > http://lkml.kernel.org/r/1559552526-4317-2-git-send-email-maninder1.s@samsung.com > > > > --- a/fs/btrfs/zstd.c~zstd-pass-pointer-rathen-than-structure-to-functions-fix > > +++ a/fs/btrfs/zstd.c > > @@ -27,15 +27,17 @@ > > /* 307s to avoid pathologically clashing with transaction commit */ > > #define ZSTD_BTRFS_RECLAIM_JIFFIES (307 * HZ) > > > > -static ZSTD_parameters zstd_get_btrfs_parameters(unsigned int level, > > +static ZSTD_parameters *zstd_get_btrfs_parameters(unsigned int level, > > size_t src_len) > > { > > - ZSTD_parameters params = ZSTD_getParams(level, src_len, 0); > > + static ZSTD_parameters params; > > > + > > + params = ZSTD_getParams(level, src_len, 0); > > No thats' broken, the params can't be static as it depends on level and > src_len. What happens if there are several requests in parallel with > eg. different levels? > > Would be really great if the mailinglist is CCed when the code is > changed in a non-trivial way. So this does not compile fs/btrfs/zstd.o which Andrew probably found too, otherwise btrfs is the only in-tree user of the function outside of lib/ and crypto/. I think that Nick Terrell should have been CCed too, as he ported zstd to linux.