linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 06/10] btrfs: uninline btrfs_bg_flags_to_raid_index
Date: Mon, 26 Jul 2021 17:06:04 +0200	[thread overview]
Message-ID: <20210726150604.GE5047@twin.jikos.cz> (raw)
In-Reply-To: <cea44339-1e8b-0066-86a6-3980bbc00e1d@gmx.com>

On Mon, Jul 26, 2021 at 08:34:20PM +0800, Qu Wenruo wrote:
> 
> 
> On 2021/7/26 下午8:15, David Sterba wrote:
> > The helper does a simple translation from block group flags to index to
> > the btrfs_raid_array table. There's no apparent reason to inline the
> > function, the translation happens usually once per function and is not
> > called in a loop.
> >
> > Making it a proper function saves quite some binary code (x86_64,
> > release config):
> >
> >     text    data     bss     dec     hex filename
> > 1164011   19253   14912 1198176  124860 pre/btrfs.ko
> > 1161559   19253   14912 1195724  123ecc post/btrfs.ko
> >
> > DELTA: -2451
> 
> My memory says there used to be some option to allow the compiler to
> uninline some functions, but I can't find it in the latest kernel.

Inlining is the compiler magic, the inline annotations are taken as
hints (that's what compiler people say) but they mostly work as written
in the source.

> It looks to me that this should really be something dependent on kernel
> config/compiler optimization.

Leaving the optimizations to the compiler is a good idea in general,
recompiling the same sources on a newer CPU target can lead to better
code compared to some hand-crafted code that may prevent the
optimizations. The one I uninlined here was an obvious "too big for
inline" and it was not a hot path. I'd rather remove such obvious cases
as we see them, the size and scope of the change is measurable.

> E.g. to allow -Os optimization to uninline such functions.

IIRC -Os is not recommended for kernel as it could generate worse code.
Also I don't think it's not a common default option so we'd have to live
with the worse code for most builds.

  reply	other threads:[~2021-07-26 15:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 12:15 [PATCH 00/10] Misc small cleanups David Sterba
2021-07-26 12:15 ` [PATCH 01/10] btrfs: switch uptodate to bool in btrfs_writepage_endio_finish_ordered David Sterba
2021-07-26 12:23   ` Qu Wenruo
2021-07-26 12:15 ` [PATCH 02/10] btrfs: remove uptodate parameter from btrfs_dec_test_first_ordered_pending David Sterba
2021-07-26 12:24   ` Qu Wenruo
2021-07-26 12:15 ` [PATCH 03/10] btrfs: make btrfs_next_leaf static inline David Sterba
2021-07-26 12:25   ` Qu Wenruo
2021-07-26 12:15 ` [PATCH 04/10] btrfs: tree-checker: use table values for stripe checks David Sterba
2021-07-26 12:29   ` Qu Wenruo
2021-07-26 14:47     ` David Sterba
2021-07-26 12:15 ` [PATCH 05/10] btrfs: tree-checker: add missing stripe checks for raid1c3/4 profiles David Sterba
2021-07-26 12:29   ` Qu Wenruo
2021-07-26 12:15 ` [PATCH 06/10] btrfs: uninline btrfs_bg_flags_to_raid_index David Sterba
2021-07-26 12:34   ` Qu Wenruo
2021-07-26 15:06     ` David Sterba [this message]
2021-07-26 12:15 ` [PATCH 07/10] btrfs: merge alloc_device helpers David Sterba
2021-07-26 12:35   ` Qu Wenruo
2021-07-26 12:15 ` [PATCH 08/10] btrfs: simplify data stripe calculation helpers David Sterba
2021-07-26 12:38   ` Qu Wenruo
2021-07-26 15:06     ` David Sterba
2021-07-26 22:23       ` Qu Wenruo
2021-07-27  8:39         ` David Sterba
2021-07-27  9:32           ` Qu Wenruo
2021-07-26 12:15 ` [PATCH 09/10] btrfs: constify and cleanup variables comparators David Sterba
2021-07-26 12:15 ` [PATCH 10/10] btrfs: add and use simple page/bio to inode/fs_info helpers David Sterba
2021-07-26 12:41   ` Qu Wenruo
2021-07-26 15:09     ` David Sterba
2021-07-26 22:26       ` Qu Wenruo
2021-07-27  8:45         ` David Sterba
2021-07-27  9:42           ` Qu Wenruo
2021-07-27 14:44             ` David Sterba
2021-07-27 15:03   ` [PATCH v2 " David Sterba
2021-07-28  0:12     ` Qu Wenruo

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=20210726150604.GE5047@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.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).