linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: Refactor main loop in extent_readpages
Date: Wed, 12 Dec 2018 15:40:53 +0100	[thread overview]
Message-ID: <20181212144052.GX23615@twin.jikos.cz> (raw)
In-Reply-To: <20181129164131.4716-1-nborisov@suse.com>

On Thu, Nov 29, 2018 at 06:41:31PM +0200, Nikolay Borisov wrote:
> extent_readpages processes all pages in the readlist in batches of 16,
> this is implemented by a single for loop but thanks to an if condition
> the loop does 2 things based on whether we've filled the batch or not.
> Additionally due to the structure of the code there is an additional
> check which deals with partial batches.
> 
> Streamline all of this by explicitly using two loops. The outter one is
> used to process all pages while the inner one just fills in the batch
> of 16 (currently). Due to this new structure the code guarantees that
> all pages are processed in the loop hence the code to deal with any
> leftovers is eliminated.
> 
> This also enable the compiler to inline __extent_readpages:
> 
> 	./scripts/bloat-o-meter fs/btrfs/extent_io.o extent_io.for
> 
> 	add/remove: 0/1 grow/shrink: 1/0 up/down: 660/-820 (-160)
> 	Function                                     old     new   delta
> 	extent_readpages                             476    1136    +660
> 	__extent_readpages                           820       -    -820
> 	Total: Before=44315, After=44155, chg -0.36%
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  fs/btrfs/extent_io.c | 37 ++++++++++++++++---------------------
>  1 file changed, 16 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 8332c5f4b1c3..233f835dd6f8 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -4093,43 +4093,38 @@ int extent_writepages(struct address_space *mapping,
>  int extent_readpages(struct address_space *mapping, struct list_head *pages,
>  		     unsigned nr_pages)

nr_pages becomes unused now. I've checked the MM code that calls here
and it's guaranteed that the number of list 'pages' members is same as
nr_pages.

>  {
> +#define BTRFS_PAGES_BATCH 16
> +
>  	struct bio *bio = NULL;
> -	unsigned page_idx;
>  	unsigned long bio_flags = 0;
> -	struct page *pagepool[16];
> -	struct page *page;
> +	struct page *pagepool[BTRFS_PAGES_BATCH];

I don't think we need the extra define, if

	struct page *pagepool[16];

	...

	for (nr = 0; nr < ARRAY_SIZE(pagepool) ...

Otherwise ok, nice cleanup.

Reviewed-by: David Sterba <dsterba@suse.com>

  reply	other threads:[~2018-12-12 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 16:41 [PATCH] btrfs: Refactor main loop in extent_readpages Nikolay Borisov
2018-12-12 14:40 ` David Sterba [this message]
2018-12-12 15:16   ` Nikolay Borisov

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=20181212144052.GX23615@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@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;
as well as URLs for NNTP newsgroup(s).