From: David Sterba <dsterba@suse.cz>
To: Nick Terrell <terrelln@fb.com>
Cc: David Sterba <dsterba@suse.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: move some zstd work data from stack to workspace
Date: Mon, 20 Nov 2017 18:07:34 +0100 [thread overview]
Message-ID: <20171120170734.GA3553@twin.jikos.cz> (raw)
In-Reply-To: <8E453D19-A43F-4472-BAAA-0944F6ACB324@fb.com>
On Thu, Nov 16, 2017 at 01:07:19AM +0000, Nick Terrell wrote:
> On 11/15/17, 9:30 AM, "David Sterba" <dsterba@suse.com> wrote:
> > * ZSTD_inBuffer in_buf
> > * ZSTD_outBuffer out_buf
> >
> > are used in all functions to pass the compression parameters and the
> > local variables consume some space. We can move them to the workspace
> > and reduce the stack consumption:
> >
> > zstd.c:zstd_decompress -24 (136 -> 112)
> > zstd.c:zstd_decompress_bio -24 (144 -> 120)
> > zstd.c:zstd_compress_pages -24 (264 -> 240)
>
> It looks good to me, and I ran my btrfs zstd compression and
> decompression test and everything worked.
>
> Is there a case where these 24 bytes matter, or is this just an easy
> optimization?
The stacks in kernel are limited, so it's a good practice to keep them
minimal. The size used to be 4kb, 8kb and now is 16kb. Using several
IO/FS layers (DM targets like crypto/raids/integrity, NFS, ecryptfs,
iscsi, ...) can increase the stack consumption and potentially overflow
under some conditions. The compression can be typically called from a
writeout path so all the layers can be active at that point and the
overflow could happen. Also debugging features can increase the stack
consumption even without the layering fun.
The maximal stack consumption can be measured by
CONFIG_DEBUG_STACK_USAGE, the values that I've seen on my dev boxes were
near the 8kb boundary, so we'd be in a much worse situation without the
16k stacks.
prev parent reply other threads:[~2017-11-20 17:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 17:27 [PATCH] btrfs: move some zstd work data from stack to workspace David Sterba
2017-11-16 1:07 ` Nick Terrell
2017-11-20 17:07 ` David Sterba [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=20171120170734.GA3553@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=terrelln@fb.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;
as well as URLs for NNTP newsgroup(s).