* [PATCH] btrfs: remove redundant local var in read_block_for_search
@ 2020-05-27 10:10 Nikolay Borisov
2020-05-27 11:57 ` Johannes Thumshirn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nikolay Borisov @ 2020-05-27 10:10 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
The local 'b' variable is only used to directly read values from passed
extent buffer. So eliminate it and directly use the input parameter. Furthermore
this shrinks the size of the following functions:
./scripts/bloat-o-meter ctree.orig fs/btrfs/ctree.o
add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-73 (-73)
Function old new delta
read_block_for_search.isra 876 871 -5
push_node_left 1112 1044 -68
Total: Before=50348, After=50275, chg -0.14%
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 3ab307b4b294..72a3389d2d87 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2335,16 +2335,15 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
struct btrfs_fs_info *fs_info = root->fs_info;
u64 blocknr;
u64 gen;
- struct extent_buffer *b = *eb_ret;
struct extent_buffer *tmp;
struct btrfs_key first_key;
int ret;
int parent_level;
- blocknr = btrfs_node_blockptr(b, slot);
- gen = btrfs_node_ptr_generation(b, slot);
- parent_level = btrfs_header_level(b);
- btrfs_node_key_to_cpu(b, &first_key, slot);
+ blocknr = btrfs_node_blockptr(*eb_ret, slot);
+ gen = btrfs_node_ptr_generation(*eb_ret, slot);
+ parent_level = btrfs_header_level(*eb_ret);
+ btrfs_node_key_to_cpu(*eb_ret, &first_key, slot);
tmp = find_extent_buffer(fs_info, blocknr);
if (tmp) {
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: remove redundant local var in read_block_for_search
2020-05-27 10:10 [PATCH] btrfs: remove redundant local var in read_block_for_search Nikolay Borisov
@ 2020-05-27 11:57 ` Johannes Thumshirn
2020-05-27 13:56 ` David Sterba
2020-05-27 14:02 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2020-05-27 11:57 UTC (permalink / raw)
To: Nikolay Borisov, linux-btrfs
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: remove redundant local var in read_block_for_search
2020-05-27 10:10 [PATCH] btrfs: remove redundant local var in read_block_for_search Nikolay Borisov
2020-05-27 11:57 ` Johannes Thumshirn
@ 2020-05-27 13:56 ` David Sterba
2020-05-27 14:02 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2020-05-27 13:56 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Wed, May 27, 2020 at 01:10:59PM +0300, Nikolay Borisov wrote:
> The local 'b' variable is only used to directly read values from passed
> extent buffer. So eliminate it and directly use the input parameter. Furthermore
> this shrinks the size of the following functions:
>
> ./scripts/bloat-o-meter ctree.orig fs/btrfs/ctree.o
> add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-73 (-73)
> Function old new delta
> read_block_for_search.isra 876 871 -5
> push_node_left 1112 1044 -68
> Total: Before=50348, After=50275, chg -0.14%
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: remove redundant local var in read_block_for_search
2020-05-27 10:10 [PATCH] btrfs: remove redundant local var in read_block_for_search Nikolay Borisov
2020-05-27 11:57 ` Johannes Thumshirn
2020-05-27 13:56 ` David Sterba
@ 2020-05-27 14:02 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2020-05-27 14:02 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Wed, May 27, 2020 at 01:10:59PM +0300, Nikolay Borisov wrote:
> The local 'b' variable is only used to directly read values from passed
> extent buffer. So eliminate it and directly use the input parameter. Furthermore
> this shrinks the size of the following functions:
>
> ./scripts/bloat-o-meter ctree.orig fs/btrfs/ctree.o
> add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-73 (-73)
> Function old new delta
> read_block_for_search.isra 876 871 -5
> push_node_left 1112 1044 -68
> - struct extent_buffer *b = *eb_ret;
> - blocknr = btrfs_node_blockptr(b, slot);
> - gen = btrfs_node_ptr_generation(b, slot);
> - parent_level = btrfs_header_level(b);
> - btrfs_node_key_to_cpu(b, &first_key, slot);
> + blocknr = btrfs_node_blockptr(*eb_ret, slot);
> + gen = btrfs_node_ptr_generation(*eb_ret, slot);
> + parent_level = btrfs_header_level(*eb_ret);
> + btrfs_node_key_to_cpu(*eb_ret, &first_key, slot);
It's interesting how such trivial and obvious change can improve the
code generation. The removed indirection resulted in smaller function
push_node_left that is not even called directly, but as there are lot of
static helpers it's some intra-procedural pass that can utilize the
reduced variable indirection.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-27 14:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 10:10 [PATCH] btrfs: remove redundant local var in read_block_for_search Nikolay Borisov
2020-05-27 11:57 ` Johannes Thumshirn
2020-05-27 13:56 ` David Sterba
2020-05-27 14:02 ` David Sterba
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).