public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] dm: empty flush optimization
@ 2024-05-14  9:04 Yang Yang
  2024-05-14  9:04 ` [PATCH 1/5] dm: introduce flush_pass_around flag Yang Yang
                   ` (4 more replies)
  0 siblings, 5 replies; 24+ messages in thread
From: Yang Yang @ 2024-05-14  9:04 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka, dm-devel,
	linux-kernel
  Cc: Yang Yang

__send_empty_flush() sends empty flush bios to every target in the
dm_table. However, if the num_targets exceeds the number of block
devices in the dm_table's device list, it could lead to multiple
invocations of __send_duplicate_bios() for the same block device.
Typically, a single thread sending numerous empty flush bios to one
block device is redundant, as these bios are likely to be merged by the
flush state machine. In scenarios where num_targets significantly
outweighs the number of block devices, such behavior may result in a
noteworthy decrease in performance.

This is a real-world scenario that we have encountered:
1) Call fallocate(file_fd, 0, 0, SZ_8G)
2) Call ioctl(file_fd, FS_IOC_FIEMAP, fiemap). In situations of severe
file system fragmentation, fiemap->fm_mapped_extents may exceed 1000.
3) Create a dm-linear device based on fiemap->fm_extents
4) Create a snapshot-cow device based on the dm-linear device 

Perf diff of fio test:
  fio --group_reporting --name=benchmark --filename=/dev/mapper/example \
      --ioengine=sync --invalidate=1 --numjobs=16 --rw=randwrite \
      --blocksize=4k --size=2G --time_based --runtime=30 --fdatasync=1

Scenario one:
  for i in {0..1023}; do
    echo $((8000*$i)) 8000 linear /dev/sda2 $((16384*$i))
  done | sudo dmsetup create example

  Before: bw=857KiB/
  After:  bw=30.8MiB/s    +3580%

Scenario two:
  for i in {0..1023}; do
    if [[ $i -gt 511 ]]; then
      echo $((8000*$i)) 8000 linear /dev/nvme0n1p6 $((16384*$i))
    else
      echo $((8000*$i)) 8000 linear /dev/sda2 $((16384*$i))
    fi
  done | sudo dmsetup create example

  Before: bw=1470KiB/
  After:  bw=33.9MiB/s    +2261%

Any comments are welcome!

V2:
-- Split into smaller pieces that are easier to review
-- Add flush_pass_around, suggested by Mikulas Patocka
-- Handling different target types separately

Yang Yang (5):
  dm: introduce flush_pass_around flag
  dm: add __send_empty_flush_bios() helper
  dm: support retrieving struct dm_target from struct dm_dev
  dm: Avoid sending redundant empty flush bios to the same block device
  dm linear: enable flush optimization function

 drivers/md/dm-core.h          |  3 +++
 drivers/md/dm-ioctl.c         |  4 ++++
 drivers/md/dm-linear.c        |  1 +
 drivers/md/dm-table.c         | 39 +++++++++++++++++++++++++++++++++++
 drivers/md/dm.c               | 37 +++++++++++++++++++++++++--------
 include/linux/device-mapper.h |  8 +++++++
 6 files changed, 83 insertions(+), 9 deletions(-)

-- 
2.34.1


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

end of thread, other threads:[~2024-05-28 11:37 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-14  9:04 [PATCH 0/5] dm: empty flush optimization Yang Yang
2024-05-14  9:04 ` [PATCH 1/5] dm: introduce flush_pass_around flag Yang Yang
2024-05-14  9:04 ` [PATCH 2/5] dm: add __send_empty_flush_bios() helper Yang Yang
2024-05-14  9:04 ` [PATCH 3/5] dm: support retrieving struct dm_target from struct dm_dev Yang Yang
2024-05-15 15:42   ` Benjamin Marzinski
2024-05-15 15:53     ` Mikulas Patocka
2024-05-16 20:49       ` [PATCH] dm: optimize flushes Mikulas Patocka
2024-05-17  8:55         ` YangYang
2024-05-22 16:10         ` Mike Snitzer
2024-05-22 21:05           ` Mikulas Patocka
2024-05-23 17:46           ` [PATCH v2] " Mikulas Patocka
2024-05-23 18:02             ` Mike Snitzer
2024-05-28 11:37               ` Mikulas Patocka
2024-05-23 22:17           ` Eric Wheeler
2024-05-15 16:00     ` [PATCH 3/5] dm: support retrieving struct dm_target from struct dm_dev Benjamin Marzinski
2024-05-16  2:12       ` YangYang
2024-05-16 16:39         ` Benjamin Marzinski
2024-05-16  1:55     ` YangYang
2024-05-16 15:29       ` Benjamin Marzinski
2024-05-17  7:48         ` YangYang
2024-05-17 14:33           ` Benjamin Marzinski
2024-05-20  3:12             ` YangYang
2024-05-14  9:04 ` [PATCH 4/5] dm: Avoid sending redundant empty flush bios to the same block device Yang Yang
2024-05-14  9:04 ` [PATCH 5/5] dm linear: enable flush optimization function Yang Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox