All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/6] blkdebug: fix racing condition when iterating on
@ 2021-06-04 10:07 Emanuele Giuseppe Esposito
  2021-06-04 10:07 ` [PATCH v4 1/6] blkdebug: refactor removal of a suspended request Emanuele Giuseppe Esposito
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Emanuele Giuseppe Esposito @ 2021-06-04 10:07 UTC (permalink / raw)
  To: qemu-block
  Cc: Kevin Wolf, Emanuele Giuseppe Esposito,
	Vladimir Sementsov-Ogievskiy, qemu-devel, Max Reitz,
	Paolo Bonzini

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-6 are somewhat independent of the others, patch 5 removes the need
of new_state field, and patch 6 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>
---
v4:
* Patch 5 (new): get rid of new_state and instead use a local variable
* Patch 6: move the state update inside the same guard lock where the new
  one is decided, to have a single critical section and avoid use-before-update. 

Emanuele Giuseppe Esposito (6):
  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
  block/blkdebug: remove new_state field and instead use a local
    variable
  blkdebug: protect rules and suspended_reqs with a lock

 block/blkdebug.c | 128 +++++++++++++++++++++++++++++++----------------
 1 file changed, 84 insertions(+), 44 deletions(-)

-- 
2.30.2



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

end of thread, other threads:[~2021-06-08 14:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04 10:07 [PATCH v4 0/6] blkdebug: fix racing condition when iterating on Emanuele Giuseppe Esposito
2021-06-04 10:07 ` [PATCH v4 1/6] blkdebug: refactor removal of a suspended request Emanuele Giuseppe Esposito
2021-06-04 16:16   ` Eric Blake
2021-06-07  9:23     ` Paolo Bonzini
2021-06-08  8:00       ` Emanuele Giuseppe Esposito
2021-06-08 14:16         ` Eric Blake
2021-06-04 10:07 ` [PATCH v4 2/6] blkdebug: move post-resume handling to resume_req_by_tag Emanuele Giuseppe Esposito
2021-06-04 10:07 ` [PATCH v4 3/6] blkdebug: track all actions Emanuele Giuseppe Esposito
2021-06-04 10:07 ` [PATCH v4 4/6] blkdebug: do not suspend in the middle of QLIST_FOREACH_SAFE Emanuele Giuseppe Esposito
2021-06-04 10:07 ` [PATCH v4 5/6] block/blkdebug: remove new_state field and instead use a local variable Emanuele Giuseppe Esposito
2021-06-05 14:32   ` Vladimir Sementsov-Ogievskiy
2021-06-04 10:07 ` [PATCH v4 6/6] blkdebug: protect rules and suspended_reqs with a lock Emanuele Giuseppe Esposito
2021-06-05 15:15   ` Vladimir Sementsov-Ogievskiy
2021-06-05 17:53     ` Emanuele Giuseppe Esposito
2021-06-05 19:40       ` Vladimir Sementsov-Ogievskiy
2021-06-07  9:29   ` Paolo Bonzini

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.