public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>, Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 08/10] btrfs: relocation: Remove the open-coded goto loop for breadth-first search
Date: Thu, 5 Mar 2020 10:17:49 +0200	[thread overview]
Message-ID: <09fa33e1-740d-b4b0-2ff6-467cee674feb@suse.com> (raw)
In-Reply-To: <e76f9a62-6c7c-b1fc-e1fe-c985ff395b9d@gmx.com>



On 5.03.20 г. 2:40 ч., Qu Wenruo wrote:
> 
> 
> On 2020/3/4 下午10:24, Nikolay Borisov wrote:
>>
> [...]
>>> +	int err = 0;
>>> +
>>> +	iter = btrfs_backref_iter_alloc(rc->extent_root->fs_info, GFP_NOFS);
>>> +	if (!iter)
>>> +		return ERR_PTR(-ENOMEM);
>>
>> This iterator can be made private to handle_one_tree_block as I don't see it being used outside of that function.
> 
> It's kinda a performance optimization.
> 
> Instead of allocating memory for each loop, we allocate the memory just
> once, and reuse it until the whole backref map for the bytenr is built.
>>
>>> +	path = btrfs_alloc_path();
>>> +	if (!path) {
>>> +		err = -ENOMEM;
>>> +		goto out;
>>> +	}
>>
>> Same thing with this path. Overall this will reduce the argument to handle_one_tree_block by 2.
> 
> Same performance optimization here.

Ok, fair point.
> 
>>

<snip>

>>
>> or simply if (!edge)
>> break;
>>
>> Also this loop can be rewritten as a do {} while() and it will look:
> 
> Yep, but I'm not sure if such do {} while() loop is preferred.
> IIRC there are some docs saying to avoid such loop?

I'm not aware of any such docs, can you point me to them?

> 
> If there is no such restriction, I would be pretty happy to go that way.
> 
> Thanks,
> Qu
> 

<snip>

  reply	other threads:[~2020-03-05  8:17 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02  9:45 [PATCH v2 00/10] btrfs: relocation: Refactor build_backref_tree() Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 01/10] btrfs: backref: Introduce the skeleton of btrfs_backref_iter Qu Wenruo
2020-03-03 17:19   ` David Sterba
2020-03-04  0:50     ` Qu Wenruo
2020-03-03 17:25   ` David Sterba
2020-03-04  0:52     ` Qu Wenruo
2020-03-04  7:41   ` Nikolay Borisov
2020-03-02  9:45 ` [PATCH v2 02/10] btrfs: backref: Implement btrfs_backref_iter_next() Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 03/10] btrfs: relocation: Use btrfs_backref_iter infrastructure Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 04/10] btrfs: relocation: Rename mark_block_processed() and __mark_block_processed() Qu Wenruo
2020-03-02 17:21   ` Nikolay Borisov
2020-03-02  9:45 ` [PATCH v2 05/10] btrfs: relocation: Refactor tree backref processing into its own function Qu Wenruo
2020-03-03 17:29   ` David Sterba
2020-03-04  1:00     ` Qu Wenruo
2020-03-04 12:23   ` Nikolay Borisov
2020-03-04 12:33     ` Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 06/10] btrfs: relocation: Use wrapper to replace open-coded edge linking Qu Wenruo
2020-03-03 17:30   ` David Sterba
2020-03-04  1:02     ` Qu Wenruo
2020-03-04 13:02   ` Nikolay Borisov
2020-03-02  9:45 ` [PATCH v2 07/10] btrfs: relocation: Specify essential members for alloc_backref_node() Qu Wenruo
2020-03-04 13:06   ` Nikolay Borisov
2020-03-04 13:09     ` Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 08/10] btrfs: relocation: Remove the open-coded goto loop for breadth-first search Qu Wenruo
2020-03-04 14:24   ` Nikolay Borisov
2020-03-05  0:40     ` Qu Wenruo
2020-03-05  8:17       ` Nikolay Borisov [this message]
2020-03-05  8:37         ` Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 09/10] btrfs: relocation: Refactor the finishing part of upper linkage into finish_upper_links() Qu Wenruo
2020-03-02  9:45 ` [PATCH v2 10/10] btrfs: relocation: Refactor the useless nodes handling into its own function 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=09fa33e1-740d-b4b0-2ff6-467cee674feb@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=wqu@suse.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