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, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/4] zstd: pass pointer rathen than structure to functions
Date: Tue, 4 Jun 2019 15:43:26 -0700 [thread overview]
Message-ID: <20190604154326.8868a10f896c148a0ce804d1@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
> ....
>
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
>
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);
if (params.cParams.windowLog > ZSTD_BTRFS_MAX_WINDOWLOG)
params.cParams.windowLog = ZSTD_BTRFS_MAX_WINDOWLOG;
WARN_ON(src_len > ZSTD_BTRFS_MAX_INPUT);
- return params;
+ return ¶ms;
}
struct workspace {
@@ -155,11 +157,12 @@ static void zstd_calc_ws_mem_sizes(void)
unsigned int level;
for (level = 1; level <= ZSTD_BTRFS_MAX_LEVEL; level++) {
- ZSTD_parameters params =
- zstd_get_btrfs_parameters(level, ZSTD_BTRFS_MAX_INPUT);
- size_t level_size =
- max_t(size_t,
- ZSTD_CStreamWorkspaceBound(params.cParams),
+ ZSTD_parameters *params;
+ size_t level_size;
+
+ params = zstd_get_btrfs_parameters(level, ZSTD_BTRFS_MAX_INPUT);
+ level_size = max_t(size_t,
+ ZSTD_CStreamWorkspaceBound(params->cParams),
ZSTD_DStreamWorkspaceBound(ZSTD_BTRFS_MAX_INPUT));
max_size = max_t(size_t, max_size, level_size);
@@ -385,8 +388,9 @@ static int zstd_compress_pages(struct li
unsigned long len = *total_out;
const unsigned long nr_dest_pages = *out_pages;
unsigned long max_out = nr_dest_pages * PAGE_SIZE;
- ZSTD_parameters params = zstd_get_btrfs_parameters(workspace->req_level,
- len);
+ ZSTD_parameters *params;
+
+ params = zstd_get_btrfs_parameters(workspace->req_level, len);
*out_pages = 0;
*total_out = 0;
_
next parent reply other threads:[~2019-06-04 22:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1559552526-4317-1-git-send-email-maninder1.s@samsung.com>
[not found] ` <CGME20190603090232epcas5p1630d0584e8a1aa9495edc819605664fc@epcas5p1.samsung.com>
[not found] ` <1559552526-4317-2-git-send-email-maninder1.s@samsung.com>
2019-06-04 22:43 ` Andrew Morton [this message]
2019-06-05 11:57 ` [PATCH 1/4] zstd: pass pointer rathen than structure to functions David Sterba
2019-06-05 12:32 ` David Sterba
2019-06-05 21:32 ` Andrew Morton
2019-06-06 14:10 ` Vaneet Narang
2019-06-06 20:14 ` (2) " Nick Terrell
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=20190604154326.8868a10f896c148a0ce804d1@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.sahrawat@samsung.com \
--cc=clm@fb.com \
--cc=davem@davemloft.net \
--cc=dsterba@suse.com \
--cc=gustavo@embeddedor.com \
--cc=herbert@gondor.apana.org.au \
--cc=joe@perches.com \
--cc=josef@toxicpanda.com \
--cc=keescook@chromium.org \
--cc=linux-btrfs@vger.kernel.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