From: Nick Terrell <terrelln@fb.com>
To: Vaneet Narang <v.narang@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"dsterba@suse.cz" <dsterba@suse.cz>,
Maninder Singh <maninder1.s@samsung.com>,
"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
"davem@davemloft.net" <davem@davemloft.net>,
"keescook@chromium.org" <keescook@chromium.org>,
"gustavo@embeddedor.com" <gustavo@embeddedor.com>,
"joe@perches.com" <joe@perches.com>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
AMIT SAHRAWAT <a.sahrawat@samsung.com>,
PANKAJ MISHRA <pankaj.m@samsung.com>, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: (2) [PATCH 1/4] zstd: pass pointer rathen than structure to functions
Date: Thu, 6 Jun 2019 20:14:36 +0000 [thread overview]
Message-ID: <673B6F9E-5BB7-4EB2-9E6C-A44E09367ADE@fb.com> (raw)
In-Reply-To: <20190606141019epcms5p1e9c394d2c2ef37506c8004fe48edd29f@epcms5p1>
> On Jun 6, 2019, at 7:10 AM, Vaneet Narang <v.narang@samsung.com> wrote:
>
> Hi Andrew / David,
>
>
>>> > > - 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?
>
> There is no need to make static for btrfs. We can keep it as a stack variable.
> This patch set focussed on reducing stack usage of zstd compression when triggered
> through zram. ZRAM internally uses crypto and currently crpto uses fixed level and also
> not dependent upon source length.
Can we measure the performance of these patches on btrfs and/or zram? See the benchmarks
I ran on my original patch to btrfs for reference https://lore.kernel.org/patchwork/patch/802866/.
I don't expect a speed difference, but I think it is worth measuring.
> crypto/zstd.c:
> static ZSTD_parameters zstd_params(void)
> {
> return ZSTD_getParams(ZSTD_DEF_LEVEL, 0, 0);
> }
>
>
> Actually high stack usage problem with zstd compression patch gets exploited more incase of
> shrink path which gets triggered randomly from any call flow in case of low memory and adds overhead
> of more than 2000 byte of stack and results in stack overflow.
>
> Stack usage of alloc_page in case of low memory
>
> 72 HUF_compressWeights_wksp+0x140/0x200
> 64 HUF_writeCTable_wksp+0xdc/0x1c8
> 88 HUF_compress4X_repeat+0x214/0x450
> 208 ZSTD_compressBlock_internal+0x224/0x137c
> 136 ZSTD_compressContinue_internal+0x210/0x3b0
> 192 ZSTD_compressCCtx+0x6c/0x144
> 144 zstd_compress+0x40/0x58
> 32 crypto_compress+0x2c/0x34
> 32 zcomp_compress+0x3c/0x44
> 80 zram_bvec_rw+0x2f8/0xa7c
> 64 zram_rw_page+0x104/0x170
> 48 bdev_write_page+0x80/0xb4
> 112 __swap_writepage+0x160/0x29c
> 24 swap_writepage+0x3c/0x58
> 160 shrink_page_list+0x788/0xae0
> 128 shrink_inactive_list+0x210/0x4a8
> 184 shrink_zone+0x53c/0x7c0
> 160 try_to_free_pages+0x2fc/0x7cc
> 80 __alloc_pages_nodemask+0x534/0x91c
>
> Thanks & Regards,
> Vaneet Narang
>
prev parent reply other threads:[~2019-06-06 20:19 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 ` [PATCH 1/4] zstd: pass pointer rathen than structure to functions Andrew Morton
2019-06-05 11:57 ` 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 ` Nick Terrell [this message]
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=673B6F9E-5BB7-4EB2-9E6C-A44E09367ADE@fb.com \
--to=terrelln@fb.com \
--cc=a.sahrawat@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=clm@fb.com \
--cc=davem@davemloft.net \
--cc=dsterba@suse.com \
--cc=dsterba@suse.cz \
--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