From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: dsterba@suse.cz, Christoph Hellwig <hch@infradead.org>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org,
"Gustavo A . R . Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH] btrfs: add special case to setget helpers for 64k pages
Date: Wed, 14 Jul 2021 18:37:01 -0500 [thread overview]
Message-ID: <333c5709-0d10-635e-656f-32263ec7f0a5@embeddedor.com> (raw)
In-Reply-To: <20210708143412.GC2610@twin.jikos.cz>
David,
Is it OK with you if we proceed to enable -Warray-bounds in linux-next,
in the meantime?
Apparently, these are the last warnings remaining to be fixed before we
can globally enable that compiler option and, it will be really helpful
to at least have it enabled in linux-next for the rest of the development
cycle, in case there are some other corner cases that we are not aware of
yet.
Thanks
--
Gustavo
On 7/8/21 09:34, David Sterba wrote:
> On Mon, Jul 05, 2021 at 09:33:34AM +0100, Christoph Hellwig wrote:
>> On Fri, Jul 02, 2021 at 01:06:30PM +0200, David Sterba wrote:
>>> On Fri, Jul 02, 2021 at 08:10:50AM +0100, Christoph Hellwig wrote:
>>>>> + if (INLINE_EXTENT_BUFFER_PAGES == 1) { \
>>>>> return get_unaligned_le##bits(token->kaddr + oip); \
>>>>> + } else { \
>>>>
>>>> No need for an else after the return and thus no need for all the
>>>> reformatting.
>>>
>>> That leads to worse code, compiler does not eliminate the block that
>>> would otherwise be in the else block. Measured on x86_64 with
>>> instrumented code to force INLINE_EXTENT_BUFFER_PAGES = 1 this adds
>>> +1100 bytes of code and has impact on stack consumption.
>>>
>>> That the code that is in two branches that do not share any code is
>>> maybe not pretty but the compiler did what I expected. The set/get
>>> helpers get called a lot and are performance sensitive.
>>>
>>> This patch pre (original version), post (with dropped else):
>>>
>>> 1156210 19305 14912 1190427 122a1b pre/btrfs.ko
>>> 1157386 19305 14912 1191603 122eb3 post/btrfs.ko
>>
>> For the obvious trivial patch (see below) I see the following
>> difference, which actually makes the simple change smaller:
>>
>> text data bss dec hex filename
>> 1322580 112183 27600 1462363 16505b fs/btrfs/btrfs.o.hch
>> 1322832 112183 27600 1462615 165157 fs/btrfs/btrfs.o.dave
>
> This was on x86_64 and without any further changes to the
> extent_buffer::pages, right?
>
> I've tested your version with the following diff emulating the single
> page that would be on ppc:
>
> --- a/fs/btrfs/extent_io.h
> +++ b/fs/btrfs/extent_io.h
> @@ -94,7 +94,8 @@ struct extent_buffer {
>
> struct rw_semaphore lock;
>
> - struct page *pages[INLINE_EXTENT_BUFFER_PAGES];
> + struct page *pages[1];
> + /* struct page *pages[INLINE_EXTENT_BUFFER_PAGES]; */
> struct list_head release_list;
> #ifdef CONFIG_BTRFS_DEBUG
> struct list_head leak_list;
> diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c
> index 8260f8bb3ff0..4f8e8f7b29d1 100644
> --- a/fs/btrfs/struct-funcs.c
> +++ b/fs/btrfs/struct-funcs.c
> @@ -52,6 +52,8 @@ static bool check_setget_bounds(const struct extent_buffer *eb,
> * from 0 to metadata node size.
> */
>
> +#define _INLINE_EXTENT_BUFFER_PAGES 1
> ...
> ---
>
> And replacing _INLINE_EXTENT_BUFFER_PAGES in the checks. This leads to
> the same result as in my original version with the copied blocks:
>
> text data bss dec hex filename
> 1161350 19305 14912 1195567 123e2f pre/btrfs.ko
> 1156090 19305 14912 1190307 1229a3 post/btrfs.ko
>
> DELTA: -5260
>
> ie. compiler properly removed the dead code after evaluating the
> conditions. As your change is simpler code I'll take it, tahnks for the
> suggestion.
>
next prev parent reply other threads:[~2021-07-14 23:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-01 16:00 [PATCH] btrfs: add special case to setget helpers for 64k pages David Sterba
2021-07-01 21:57 ` Gustavo A. R. Silva
2021-07-01 23:59 ` Qu Wenruo
2021-07-02 0:09 ` Gustavo A. R. Silva
2021-07-02 0:21 ` Qu Wenruo
2021-07-02 0:39 ` Gustavo A. R. Silva
2021-07-02 0:39 ` Qu Wenruo
2021-07-02 1:09 ` Gustavo A. R. Silva
2021-07-02 10:22 ` David Sterba
2021-07-02 7:10 ` Christoph Hellwig
2021-07-02 11:06 ` David Sterba
2021-07-05 8:33 ` Christoph Hellwig
2021-07-08 14:34 ` David Sterba
2021-07-14 23:37 ` Gustavo A. R. Silva [this message]
2021-07-28 15:32 ` David Sterba
2021-07-28 16:00 ` David Sterba
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=333c5709-0d10-635e-656f-32263ec7f0a5@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=dsterba@suse.com \
--cc=dsterba@suse.cz \
--cc=gustavoars@kernel.org \
--cc=hch@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
/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).