All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Bo <liubo2009@cn.fujitsu.com>
To: Zach Brown <zab@zabbo.net>
Cc: linux-btrfs@vger.kernel.org, chris.mason@fusionio.com,
	jbacik@fusionio.com, dave@jikos.cz
Subject: Re: [PATCH v4] Btrfs: improve multi-thread buffer read
Date: Sat, 21 Jul 2012 11:03:23 +0800	[thread overview]
Message-ID: <500A1BFB.8070108@cn.fujitsu.com> (raw)
In-Reply-To: <20120720184208.GG3889@lenny.home.zabbo.net>

On 07/21/2012 02:42 AM, Zach Brown wrote:

>> +	struct page *page;
>> +	int i = 0;
>> +	int nr = 0;
> 
> i doesn't need to be initialized.
> 
>>  	for (page_idx = 0; page_idx < nr_pages; page_idx++) {
>> -		struct page *page = list_entry(pages->prev, struct page, lru);
>> +		page = list_entry(pages->prev, struct page, lru);
>>  
>>  		prefetchw(&page->flags);
>>  		list_del(&page->lru);
>>  		if (!add_to_page_cache_lru(page, mapping,
>>  					page->index, GFP_NOFS)) {
>> -			__extent_read_full_page(tree, page, get_extent,
>> +			page_cache_get(page);
>> +			pagepool[nr++] = page;
>> +			if (nr == 16) {
> 
> ARRAY_SIZE(pagepool) instead of duplicating 16.
> 
>> +				for (i = 0; i < nr; i++) {
>> +					__extent_read_full_page(tree,
>> +						pagepool[i], get_extent,
>>  						&bio, 0, &bio_flags);
>> +					page_cache_release(pagepool[i]);
>> +				}
>> +				nr = 0;
>> +			}
>>  		}
>>  		page_cache_release(page);
> 
> It looks like you can optimize away a page cache ref here.  Don't add a
> ref when the page is added to the pool, instead use the existing ref.
> Then only release this ref here if add_to_page_cache_lru() succeeds.
> Then always release the ref when __extent_read_full_page is called on
> the pages in the pool.
> 


Sounds good, it makes btrfs's readpages hook a little different with others' though.

> I'd also invert the nested if()s to reduce the painful indent level:
> 
>   		if (add_to_page_cache_lru(page, mapping,
>   					page->index, GFP_NOFS)) {
> 			page_cache_release(page);
> 			continue;
> 		}
> 
> 		pagepool[nr++] = page;
> 		if (nr < ARRAY_SIZE(pagepool))
> 			continue;
> 
> 		for (i = 0; i < nr; i++) {
> 			__extent_read_full_page(tree, ...
> 
> - z
> 


I'll update it.  Thanks Zach.

thanks,
liubo

      reply	other threads:[~2012-07-21  3:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20  5:46 [PATCH v4] Btrfs: improve multi-thread buffer read Liu Bo
2012-07-20 18:42 ` Zach Brown
2012-07-21  3:03   ` Liu Bo [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=500A1BFB.8070108@cn.fujitsu.com \
    --to=liubo2009@cn.fujitsu.com \
    --cc=chris.mason@fusionio.com \
    --cc=dave@jikos.cz \
    --cc=jbacik@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zab@zabbo.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.