From: Paolo Bonzini <pbonzini@redhat.com>
To: Emanuele Giuseppe Esposito <eesposit@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH v4 6/6] blkdebug: protect rules and suspended_reqs with a lock
Date: Mon, 7 Jun 2021 11:29:57 +0200 [thread overview]
Message-ID: <88a81cbc-fbe7-08b6-f6f0-5a050dfc89f2@redhat.com> (raw)
In-Reply-To: <20210604100741.18966-7-eesposit@redhat.com>
On 04/06/21 12:07, Emanuele Giuseppe Esposito wrote:
> + WITH_QEMU_LOCK_GUARD(&s->lock) {
> + new_state = s->state;
> + QLIST_FOREACH_SAFE(rule, &s->rules[event], next, next) {
> + process_rule(bs, rule, actions_count, &new_state);
> + }
> + s->state = new_state;
> }
>
> while (actions_count[ACTION_SUSPEND] > 0) {
> qemu_coroutine_yield();
> actions_count[ACTION_SUSPEND]--;
> }
> -
> - s->state = new_state;
This changes the semantics by moving the state change *before* the yield
instead of after:
- before the series, the new state was assigned after all yields (and
could be overwritten by other coroutines during the yield). Until patch
4, the situation is more or less the same even though the ordering
changed in the processing of actions (suspend actions are processed last).
- with patch 5 new_state became a local variable, so it couldn't be
overwritten by the yields
- now it is a local variable and is assigned before the yields. The
yields can write s->state just like before.
So it's a bit messy. Moving s->state = new_state before the yields
makes sense, but I'd do that in patch 5 to avoid the temporary change in
semantics.
Paolo
prev parent reply other threads:[~2021-06-07 9:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=88a81cbc-fbe7-08b6-f6f0-5a050dfc89f2@redhat.com \
--to=pbonzini@redhat.com \
--cc=eesposit@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).