All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Overstreet <kmo@daterainc.com>
To: Zach Brown <zab@redhat.com>
Cc: hch@infradead.org, axboe@kernel.dk,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] block: Introduce bio_for_each_page()
Date: Wed, 25 Sep 2013 14:49:10 -0700	[thread overview]
Message-ID: <20130925214910.GA8993@kmo-pixel> (raw)
In-Reply-To: <20130925211702.GH30372@lenny.home.zabbo.net>

On Wed, Sep 25, 2013 at 02:17:02PM -0700, Zach Brown wrote:
> >  void zero_fill_bio(struct bio *bio)
> >  {
> > -	unsigned long flags;
> >  	struct bio_vec bv;
> >  	struct bvec_iter iter;
> >  
> > -	bio_for_each_segment(bv, bio, iter) {
> > +#if defined(CONFIG_HIGHMEM) || defined(ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE)
> > +	bio_for_each_page(bv, bio, iter) {
> > +		unsigned long flags;
> >  		char *data = bvec_kmap_irq(&bv, &flags);
> >  		memset(data, 0, bv.bv_len);
> >  		flush_dcache_page(bv.bv_page);
> >  		bvec_kunmap_irq(data, &flags);
> >  	}
> > +#else
> > +	bio_for_each_segment(bv, bio, iter)
> > +		memset(page_address(bv.bv_page) + bv.bv_offset,
> > +		       0, bv.bv_len);
> > +#endif
> 
> This looks pretty sketchy.  I'd expect this to be doable with one loop
> and that bvec_kmap_irq() and flush_dcache_page() would fall back to
> page_address() and nops when they're not needed.
> 
> Where did this come from?

It's just that if we need the kmap or the flush_dcache_page we have to
process the bio one 4k page at a time - if not, we can process 64k (or
whatever) bvecs all at once. That doesn't just save us memcpy calls, we
can also avoid all the machinery in bio_for_each_page() for chunking up
large bvecs into single page bvecs.

I can definitely think of better ways to do this, but I figured I'd wait
and see if other code ends up wanting to switch between
bio_for_each_page() and bio_for_each_segment() and why.

  reply	other threads:[~2013-09-25 21:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-25 20:22 [PATCH WIP] Multipage biovecs Kent Overstreet
2013-09-25 20:22 ` [PATCH 1/6] block: Introduce bio_for_each_page() Kent Overstreet
2013-09-25 21:17   ` Zach Brown
2013-09-25 21:49     ` Kent Overstreet [this message]
2013-09-25 22:47       ` Zach Brown
2013-09-25 20:22 ` [PATCH 2/6] block: Convert various code to bio_for_each_page() Kent Overstreet
2013-09-25 20:22 ` [PATCH 3/6] Introduce blk_max_segment() Kent Overstreet
2013-09-25 20:22 ` [PATCH 4/6] convert nvme to blk_max_segment() Kent Overstreet
2013-09-25 20:22 ` [PATCH 5/6] convert integrity to new merging Kent Overstreet
2013-09-25 20:22 ` [PATCH 6/6] Multipage bvecs Kent Overstreet

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=20130925214910.GA8993@kmo-pixel \
    --to=kmo@daterainc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zab@redhat.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 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.