linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V6 00/30] block: support multipage bvec
@ 2018-06-09 12:29 Ming Lei
  2018-06-09 12:29 ` [PATCH V6 01/30] block: simplify bio_check_pages_dirty Ming Lei
                   ` (32 more replies)
  0 siblings, 33 replies; 57+ messages in thread
From: Ming Lei @ 2018-06-09 12:29 UTC (permalink / raw)
  To: Jens Axboe, Christoph Hellwig, Alexander Viro, Kent Overstreet
  Cc: David Sterba, Huang Ying, linux-kernel, linux-block,
	linux-fsdevel, linux-mm, Theodore Ts'o, Darrick J . Wong,
	Coly Li, Filipe Manana, Randy Dunlap, Ming Lei

Hi,

This patchset brings multipage bvec into block layer:

1) what is multipage bvec?

Multipage bvecs means that one 'struct bio_bvec' can hold multiple pages
which are physically contiguous instead of one single page used in linux
kernel for long time.

2) why is multipage bvec introduced?

Kent proposed the idea[1] first. 

As system's RAM becomes much bigger than before, and huge page, transparent
huge page and memory compaction are widely used, it is a bit easy now
to see physically contiguous pages from fs in I/O. On the other hand, from
block layer's view, it isn't necessary to store intermediate pages into bvec,
and it is enough to just store the physicallly contiguous 'segment' in each
io vector.

Also huge pages are being brought to filesystem and swap [2][6], we can
do IO on a hugepage each time[3], which requires that one bio can transfer
at least one huge page one time. Turns out it isn't flexiable to change
BIO_MAX_PAGES simply[3][5]. Multipage bvec can fit in this case very well.
As we saw, if CONFIG_THP_SWAP is enabled, BIO_MAX_PAGES can be configured
as much bigger, such as 512, which requires at least two 4K pages for holding
the bvec table.

With multipage bvec:

- Inside block layer, both bio splitting and sg map can become more
efficient than before by just traversing the physically contiguous
'segment' instead of each page.

- segment handling in block layer can be improved much in future since it
should be quite easy to convert multipage bvec into segment easily. For
example, we might just store segment in each bvec directly in future.

- bio size can be increased and it should improve some high-bandwidth IO
case in theory[4].

- there is opportunity in future to improve memory footprint of bvecs. 

3) how is multipage bvec implemented in this patchset?

The 1st 3 patches are prepare patches for multipage bvec, from Christoph.

The patches of 4~28 implement multipage bvec in block layer:

	- put all tricks into bvec/bio/rq iterators, and as far as
	drivers and fs use these standard iterators, they are happy
	with multipage bvec

	- use multipage bvec to split bio and map sg

	- introduce bio_for_each_chunk*() for iterating bio segment by
	  segment

	- make current bio_for_each_segment*() to itereate page by page and
	make sure current uses won't be broken

The patch 29 redefines BIO_MAX_PAGES as 256.

The patch 30 documents usages of bio iterator helpers.

These patches can be found in the following git tree:

	gitweb: https://github.com/ming1/linux/commits/v4.18-pre-rc-mp-bvec-V6
	git:  https://github.com/ming1/linux.git  #v4.18-pre-rc-mp-bvec-V6

Lots of test(blktest, xfstests, ltp io, ...) have been run with this patchset,
and not see regression.

Thanks Christoph for reviewing the early version and providing very good
suggestions, such as: introduce bio_init_with_vec_table(), remove another
unnecessary helpers for cleanup and so on.

Any comments are welcome!

V6:
	- avoid to introduce lots of renaming, follow Jen's suggestion of
	using the name of chunk for multipage io vector
	- include Christoph's three prepare patches
	- decrease stack usage for using bio_for_each_chunk_segment_all()
	- address Kent and Randy's comment

V5:
	- remove some of prepare patches, which have been merged already
	- add bio_clone_seg_bioset() to fix DM's bio clone, which
	is introduced by 18a25da84354c6b (dm: ensure bio submission follows
	a depth-first tree walk)
	- rebase on the latest block for-v4.18

V4:
	- rename bio_for_each_segment*() as bio_for_each_page*(), rename
	bio_segments() as bio_pages(), rename rq_for_each_segment() as
	rq_for_each_pages(), because these helpers never return real
	segment, and they always return single page bvec
	
	- introducing segment_for_each_page_all()

	- introduce new bio_for_each_segment*()/rq_for_each_segment()/bio_segments()
	for returning real multipage segment

	- rewrite segment_last_page()

	- rename bvec iterator helper as suggested by Christoph

	- replace comment with applying bio helpers as suggested by Christoph

	- document usage of bio iterator helpers

	- redefine BIO_MAX_PAGES as 256 to make the biggest bvec table
	accommodated in 4K page

	- move bio_alloc_pages() into bcache as suggested by Christoph

V3:
	- rebase on v4.13-rc3 with for-next of block tree
	- run more xfstests: xfs/ext4 over NVMe, Sata, DM(linear),
	MD(raid1), and not see regressions triggered
	- add Reviewed-by on some btrfs patches
	- remove two MD patches because both are merged to linus tree
	  already

V2:
	- bvec table direct access in raid has been cleaned, so NO_MP
	flag is dropped
	- rebase on recent Neil Brown's change on bio and bounce code
	- reorganize the patchset

V1:
	- against v4.10-rc1 and some cleanup in V0 are in -linus already
	- handle queue_virt_boundary() in mp bvec change and make NVMe happy
	- further BTRFS cleanup
	- remove QUEUE_FLAG_SPLIT_MP
	- rename for two new helpers of bio_for_each_segment_all()
	- fix bounce convertion
	- address comments in V0

[1], http://marc.info/?l=linux-kernel&m=141680246629547&w=2
[2], https://patchwork.kernel.org/patch/9451523/
[3], http://marc.info/?t=147735447100001&r=1&w=2
[4], http://marc.info/?l=linux-mm&m=147745525801433&w=2
[5], http://marc.info/?t=149569484500007&r=1&w=2
[6], http://marc.info/?t=149820215300004&r=1&w=2


Christoph Hellwig (3):
  block: simplify bio_check_pages_dirty
  block: bio_set_pages_dirty can't see NULL bv_page in a valid bio_vec
  block: use bio_add_page in bio_iov_iter_get_pages

Ming Lei (27):
  block: introduce multipage page bvec helpers
  block: introduce bio_for_each_chunk()
  block: use bio_for_each_chunk() to compute multipage bvec count
  block: use bio_for_each_chunk() to map sg
  block: introduce chunk_last_segment()
  fs/buffer.c: use bvec iterator to truncate the bio
  btrfs: use chunk_last_segment to get bio's last page
  block: implement bio_pages_all() via bio_for_each_segment_all()
  block: introduce bio_chunks()
  block: introduce rq_for_each_chunk()
  block: loop: pass multipage chunks to iov_iter
  block: introduce bio_clone_chunk_bioset()
  dm: clone bio via bio_clone_chunk_bioset
  block: introduce bio_for_each_chunk_all and
    bio_for_each_chunk_segment_all
  block: convert to bio_for_each_chunk_segment_all()
  md/dm/bcache: conver to bio_for_each_chunk_segment_all and
    bio_for_each_chunk_all
  fs: conver to bio_for_each_chunk_segment_all()
  btrfs: conver to bio_for_each_chunk_segment_all
  ext4: conver to bio_for_each_chunk_segment_all
  f2fs: conver to bio_for_each_chunk_segment_all
  xfs: conver to bio_for_each_chunk_segment_all
  exofs: conver to bio_for_each_chunk_segment_all
  gfs2: conver to bio_for_each_chunk_segment_all
  block: kill bio_for_each_segment_all()
  block: enable multipage bvecs
  block: always define BIO_MAX_PAGES as 256
  block: document usage of bio iterator helpers

 Documentation/block/biovecs.txt |  30 ++++++
 block/bio.c                     | 211 +++++++++++++++++++++++-----------------
 block/blk-merge.c               | 162 +++++++++++++++++++++++-------
 block/blk-zoned.c               |   5 +-
 block/bounce.c                  |   6 +-
 drivers/block/loop.c            |   6 +-
 drivers/md/bcache/btree.c       |   3 +-
 drivers/md/bcache/util.c        |   2 +-
 drivers/md/dm-crypt.c           |   3 +-
 drivers/md/dm.c                 |   4 +-
 drivers/md/raid1.c              |   3 +-
 fs/block_dev.c                  |   6 +-
 fs/btrfs/compression.c          |   8 +-
 fs/btrfs/disk-io.c              |   3 +-
 fs/btrfs/extent_io.c            |  14 ++-
 fs/btrfs/inode.c                |   6 +-
 fs/btrfs/raid56.c               |   3 +-
 fs/buffer.c                     |   5 +-
 fs/crypto/bio.c                 |   3 +-
 fs/direct-io.c                  |   4 +-
 fs/exofs/ore.c                  |   3 +-
 fs/exofs/ore_raid.c             |   3 +-
 fs/ext4/page-io.c               |   3 +-
 fs/ext4/readpage.c              |   3 +-
 fs/f2fs/data.c                  |   9 +-
 fs/gfs2/lops.c                  |   6 +-
 fs/gfs2/meta_io.c               |   3 +-
 fs/iomap.c                      |   3 +-
 fs/mpage.c                      |   3 +-
 fs/xfs/xfs_aops.c               |   5 +-
 include/linux/bio.h             |  94 ++++++++++++++----
 include/linux/blkdev.h          |   4 +
 include/linux/bvec.h            | 155 +++++++++++++++++++++++++++--
 33 files changed, 588 insertions(+), 193 deletions(-)

-- 
2.9.5

^ permalink raw reply	[flat|nested] 57+ messages in thread

end of thread, other threads:[~2018-06-21  8:40 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-09 12:29 [PATCH V6 00/30] block: support multipage bvec Ming Lei
2018-06-09 12:29 ` [PATCH V6 01/30] block: simplify bio_check_pages_dirty Ming Lei
2018-06-09 12:29 ` [PATCH V6 02/30] block: bio_set_pages_dirty can't see NULL bv_page in a valid bio_vec Ming Lei
2018-06-09 12:29 ` [PATCH V6 03/30] block: use bio_add_page in bio_iov_iter_get_pages Ming Lei
2018-06-09 12:29 ` [PATCH V6 04/30] block: introduce multipage page bvec helpers Ming Lei
2018-06-09 12:29 ` [PATCH V6 05/30] block: introduce bio_for_each_chunk() Ming Lei
2018-06-09 12:29 ` [PATCH V6 06/30] block: use bio_for_each_chunk() to compute multipage bvec count Ming Lei
2018-06-09 12:29 ` [PATCH V6 07/30] block: use bio_for_each_chunk() to map sg Ming Lei
2018-06-09 12:29 ` [PATCH V6 08/30] block: introduce chunk_last_segment() Ming Lei
2018-06-11 17:19   ` Christoph Hellwig
2018-06-12  3:24     ` Ming Lei
2018-06-09 12:29 ` [PATCH V6 09/30] fs/buffer.c: use bvec iterator to truncate the bio Ming Lei
2018-06-09 12:29 ` [PATCH V6 10/30] btrfs: use chunk_last_segment to get bio's last page Ming Lei
2018-06-09 12:29 ` [PATCH V6 11/30] block: implement bio_pages_all() via bio_for_each_segment_all() Ming Lei
2018-06-13 14:44   ` Christoph Hellwig
2018-06-14  1:23     ` Ming Lei
2018-06-14  6:20       ` Christoph Hellwig
2018-06-09 12:29 ` [PATCH V6 12/30] block: introduce bio_chunks() Ming Lei
2018-06-13 14:47   ` Christoph Hellwig
2018-06-13 14:57     ` Kent Overstreet
2018-06-09 12:29 ` [PATCH V6 13/30] block: introduce rq_for_each_chunk() Ming Lei
2018-06-13 14:48   ` Christoph Hellwig
2018-06-14  1:52     ` Ming Lei
2018-06-09 12:29 ` [PATCH V6 14/30] block: loop: pass multipage chunks to iov_iter Ming Lei
2018-06-09 12:29 ` [PATCH V6 15/30] block: introduce bio_clone_chunk_bioset() Ming Lei
2018-06-13 14:56   ` Christoph Hellwig
2018-06-14  2:01     ` Ming Lei
2018-06-14  6:39       ` Christoph Hellwig
2018-06-14  7:28         ` Ming Lei
2018-06-09 12:30 ` [PATCH V6 16/30] dm: clone bio via bio_clone_chunk_bioset Ming Lei
2018-06-09 12:30 ` [PATCH V6 17/30] block: introduce bio_for_each_chunk_all and bio_for_each_chunk_segment_all Ming Lei
2018-06-09 12:30 ` [PATCH V6 18/30] block: convert to bio_for_each_chunk_segment_all() Ming Lei
2018-06-09 12:30 ` [PATCH V6 19/30] md/dm/bcache: conver to bio_for_each_chunk_segment_all and bio_for_each_chunk_all Ming Lei
2018-06-10 12:38   ` Coly Li
2018-06-13 14:57   ` Christoph Hellwig
2018-06-09 12:30 ` [PATCH V6 20/30] fs: conver to bio_for_each_chunk_segment_all() Ming Lei
2018-06-09 12:30 ` [PATCH V6 21/30] btrfs: conver to bio_for_each_chunk_segment_all Ming Lei
2018-06-09 12:30 ` [PATCH V6 22/30] ext4: " Ming Lei
2018-06-09 12:30 ` [PATCH V6 23/30] f2fs: " Ming Lei
2018-06-09 12:30 ` [PATCH V6 24/30] xfs: " Ming Lei
2018-06-09 12:30 ` [PATCH V6 25/30] exofs: " Ming Lei
2018-06-09 12:30 ` [PATCH V6 26/30] gfs2: " Ming Lei
2018-06-09 12:30 ` [PATCH V6 27/30] block: kill bio_for_each_segment_all() Ming Lei
2018-06-09 12:30 ` [PATCH V6 28/30] block: enable multipage bvecs Ming Lei
2018-06-09 12:30 ` [PATCH V6 29/30] block: always define BIO_MAX_PAGES as 256 Ming Lei
2018-06-09 12:30 ` [PATCH V6 30/30] block: document usage of bio iterator helpers Ming Lei
2018-06-15 15:43   ` Gi-Oh Kim
2018-06-11 16:48 ` [PATCH V6 00/30] block: support multipage bvec Christoph Hellwig
2018-06-12  3:42   ` Ming Lei
2018-06-13 14:42     ` Christoph Hellwig
2018-06-14  1:18       ` Ming Lei
2018-06-14  6:18         ` Christoph Hellwig
2018-06-13 14:59 ` Kent Overstreet
2018-06-14  1:20   ` Ming Lei
2018-06-15 12:59 ` Gi-Oh Kim
2018-06-21  1:17   ` Ming Lei
2018-06-21  8:40     ` Gi-Oh Kim

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).