qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] blkdebug: fix racing condition when iterating on
@ 2021-05-07 15:11 Emanuele Giuseppe Esposito
  2021-05-07 15:11 ` [PATCH v2 1/5] blkdebug: refactor removal of a suspended request Emanuele Giuseppe Esposito
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Emanuele Giuseppe Esposito @ 2021-05-07 15:11 UTC (permalink / raw)
  To: qemu-block
  Cc: Kevin Wolf, Paolo Bonzini, Emanuele Giuseppe Esposito,
	qemu-devel, Max Reitz

When qemu_coroutine_enter is executed in a loop
(even QEMU_FOREACH_SAFE), the new routine can modify the list,
for example removing an element, causing problem when control
is given back to the caller that continues iterating on the same list. 

Patch 1 solves the issue in blkdebug_debug_resume by restarting
the list walk after every coroutine_enter if list has to be fully iterated.
Patches 2,3,4 aim to fix blkdebug_debug_event by gathering
all actions that the rules make in a counter and invoking 
the respective coroutine_yeld only after processing all requests.

Patch 5 is somewhat independent of the others, it adds a lock to
protect rules and suspended_reqs; right now everything works because
it's protected by the AioContext lock.
This is a preparation for the current proposal of removing the AioContext
lock and instead using smaller granularity locks to allow multiple
iothread execution in the same block device.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
v1 -> v2
* Change commit message of patch 4 and cover letter

Emanuele Giuseppe Esposito (5):
  blkdebug: refactor removal of a suspended request
  blkdebug: move post-resume handling to resume_req_by_tag
  blkdebug: track all actions
  blkdebug: do not suspend in the middle of QLIST_FOREACH_SAFE
  blkdebug: protect rules and suspended_reqs with a lock

 block/blkdebug.c | 113 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 79 insertions(+), 34 deletions(-)

-- 
2.30.2



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

end of thread, other threads:[~2021-05-11  9:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 15:11 [PATCH v2 0/5] blkdebug: fix racing condition when iterating on Emanuele Giuseppe Esposito
2021-05-07 15:11 ` [PATCH v2 1/5] blkdebug: refactor removal of a suspended request Emanuele Giuseppe Esposito
2021-05-07 15:12 ` [PATCH v2 2/5] blkdebug: move post-resume handling to resume_req_by_tag Emanuele Giuseppe Esposito
2021-05-07 15:12 ` [PATCH v2 3/5] blkdebug: track all actions Emanuele Giuseppe Esposito
2021-05-07 15:25   ` Eric Blake
2021-05-07 15:12 ` [PATCH v2 4/5] blkdebug: do not suspend in the middle of QLIST_FOREACH_SAFE Emanuele Giuseppe Esposito
2021-05-07 15:25   ` Eric Blake
2021-05-07 15:12 ` [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a lock Emanuele Giuseppe Esposito
2021-05-07 15:29   ` Eric Blake
2021-05-11  8:37     ` Paolo Bonzini
2021-05-11  9:08       ` Emanuele Giuseppe Esposito

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