linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Fan Li <fanofcode.li@samsung.com>, 'Chao Yu' <chao@kernel.org>,
	'Jaegeuk Kim' <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: optimize the way of traversing free_nid_bitmap
Date: Wed, 8 Nov 2017 16:52:21 +0800	[thread overview]
Message-ID: <17b70863-a406-45c5-c94a-27fda486c66e@huawei.com> (raw)
In-Reply-To: <002201d357b9$adf558a0$09e009e0$@samsung.com>

On 2017/11/7 19:14, Fan Li wrote:
> We call scan_free_nid_bits only when there isn't many
> free nids left, it means that marked bits in free_nid_bitmap
> are supposed to be few, use find_next_bit_le is more
> efficient in such case.
> According to my tests, use find_next_bit_le instead of
> test_bit_le will cut down the traversal time to one
> third of its original.
> 
> Signed-off-by: Fan li <fanofcode.li@samsung.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> ---
>  fs/f2fs/node.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index fef5c68..d234c6e 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1955,6 +1955,7 @@ static void scan_free_nid_bits(struct f2fs_sb_info *sbi)
>  	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
>  	struct f2fs_journal *journal = curseg->journal;
>  	unsigned int i, idx;
> +	nid_t nid;
>  
>  	down_read(&nm_i->nat_tree_lock);
>  
> @@ -1964,10 +1965,10 @@ static void scan_free_nid_bits(struct f2fs_sb_info *sbi)
>  		if (!nm_i->free_nid_count[i])
>  			continue;
>  		for (idx = 0; idx < NAT_ENTRY_PER_BLOCK; idx++) {
> -			nid_t nid;
> -
> -			if (!test_bit_le(idx, nm_i->free_nid_bitmap[i]))
> -				continue;
> +			idx = find_next_bit_le(nm_i->free_nid_bitmap[i],
> +						NAT_ENTRY_PER_BLOCK, idx);
> +			if (idx >= NAT_ENTRY_PER_BLOCK)
> +				break;
>  
>  			nid = i * NAT_ENTRY_PER_BLOCK + idx;
>  			add_free_nid(sbi, nid, true);
> @@ -1980,7 +1981,6 @@ static void scan_free_nid_bits(struct f2fs_sb_info *sbi)
>  	down_read(&curseg->journal_rwsem);
>  	for (i = 0; i < nats_in_cursum(journal); i++) {
>  		block_t addr;
> -		nid_t nid;
>  
>  		addr = le32_to_cpu(nat_in_journal(journal, i).block_addr);
>  		nid = le32_to_cpu(nid_in_journal(journal, i));
> 

      reply	other threads:[~2017-11-08  8:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171107111512epcas2p2bb846cc19c3d8fa6f2858874183c446c@epcas2p2.samsung.com>
2017-11-07 11:14 ` [f2fs-dev] [PATCH] f2fs: optimize the way of traversing free_nid_bitmap Fan Li
2017-11-08  8:52   ` Chao Yu [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=17b70863-a406-45c5-c94a-27fda486c66e@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=chao@kernel.org \
    --cc=fanofcode.li@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@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).