qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 8.0 regression 0/8] block: remove bdrv_co_get_geometry coroutines from I/O hot path
@ 2023-04-07 15:32 Paolo Bonzini
  2023-04-07 15:32 ` [PATCH 1/8] block: move has_variable_length to BlockLimits Paolo Bonzini
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Paolo Bonzini @ 2023-04-07 15:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, kwolf, qemu-block, hreitz

The introduction of the graph lock is causing blk_get_geometry, a hot
function used in the I/O path, to create a coroutine for the call to
bdrv_co_refresh_total_sectors.

In theory the call to bdrv_co_refresh_total_sectors should only matter
in the rare case of host CD-ROM devices, whose size changes when a medium
is added or removed.  However, the call is actually keyed by a field in
BlockDriver, drv->has_variable_length, and the field is true in the common
case of the raw driver!  This is because the host CD-ROM is usually
layered below the raw driver.

So, this series starts by moving has_variable_length from BlockDriver to
BlockLimits.  This is patches 1-4, which also include a fix for a small
latent bug (patch 3).

The second half of the series then cleans up the functions to retrieve
the BlockDriverState's size (patches 5-7) to limit the amount of duplicated
code introduced by the hand-written wrappers of patch 8.  The final result
is that blk_get_geometry will not anymore create a coroutine.

This series applies to qemu.git, or to the block-next branch if commit
d8fbf9aa85ae ("block/export: Fix graph locking in blk_get_geometry()
call", 2023-03-27) is cherry picked.  Commit d8fbf9aa85ae is also where
bdrv_co_get_geometry() was introduced and with it the performance
regression.  It is quite a recent change, and therefore this is
probably a regression in 8.0 that had not been detected yet (except by
Stefan who talked to Kevin and me about it yesterday).  I'm not sure how
we can avoid the regression, if not by disabling completely the graph lock
(!) or applying this large series.

I'm throwing this out before disappearing for a couple days for Easter;
I have only tested it with qemu-iotests and "make check-unit".

Thanks,

Paolo

Paolo Bonzini (8):
  block: move has_variable_length to BlockLimits
  block: remove has_variable_length from filters
  block: refresh bs->total_sectors on reopen
  block: remove has_variable_length from BlockDriver
  migration/block: replace uses of blk_nb_sectors that do not check
    result
  block-backend: inline bdrv_co_get_geometry
  block-backend: ignore inserted state in blk_co_nb_sectors
  block, block-backend: write some hot coroutine wrappers by hand

 block.c                           | 35 ++++++++++++++++++--------
 block/block-backend.c             | 42 ++++++++++++++++++++++++-------
 block/copy-on-read.c              |  1 -
 block/file-posix.c                | 12 ++++++---
 block/file-win32.c                |  2 +-
 block/filter-compress.c           |  1 -
 block/io.c                        |  4 +++
 block/preallocate.c               |  1 -
 block/raw-format.c                |  3 ++-
 block/replication.c               |  1 -
 include/block/block-io.h          |  5 +---
 include/block/block_int-common.h  | 10 ++++++--
 include/sysemu/block-backend-io.h |  5 ++--
 migration/block.c                 |  5 ++--
 14 files changed, 85 insertions(+), 42 deletions(-)

-- 
2.39.2



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

end of thread, other threads:[~2023-04-11 15:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-07 15:32 [PATCH 8.0 regression 0/8] block: remove bdrv_co_get_geometry coroutines from I/O hot path Paolo Bonzini
2023-04-07 15:32 ` [PATCH 1/8] block: move has_variable_length to BlockLimits Paolo Bonzini
2023-04-07 19:38   ` Eric Blake
2023-04-07 15:32 ` [PATCH 2/8] block: remove has_variable_length from filters Paolo Bonzini
2023-04-07 19:40   ` Eric Blake
2023-04-07 15:32 ` [PATCH 3/8] block: refresh bs->total_sectors on reopen Paolo Bonzini
2023-04-07 19:42   ` Eric Blake
2023-04-07 15:32 ` [PATCH 4/8] block: remove has_variable_length from BlockDriver Paolo Bonzini
2023-04-07 19:48   ` Eric Blake
2023-04-07 15:33 ` [PATCH 5/8] migration/block: replace uses of blk_nb_sectors that do not check result Paolo Bonzini
2023-04-07 19:49   ` Eric Blake
2023-04-07 15:33 ` [PATCH 6/8] block-backend: inline bdrv_co_get_geometry Paolo Bonzini
2023-04-07 19:58   ` Eric Blake
2023-04-07 15:33 ` [PATCH 7/8] block-backend: ignore inserted state in blk_co_nb_sectors Paolo Bonzini
2023-04-07 20:00   ` Eric Blake
2023-04-07 15:33 ` [PATCH 8/8] block, block-backend: write some hot coroutine wrappers by hand Paolo Bonzini
2023-04-07 20:04   ` Eric Blake
2023-04-07 20:32     ` Paolo Bonzini
2023-04-11 15:01 ` [PATCH 8.0 regression 0/8] block: remove bdrv_co_get_geometry coroutines from I/O hot path Kevin Wolf

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