From: Paolo Bonzini <pbonzini@redhat.com>
To: Eric Blake <eblake@redhat.com>,
Emanuele Giuseppe Esposito <eesposit@redhat.com>,
qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a lock
Date: Tue, 11 May 2021 10:37:14 +0200 [thread overview]
Message-ID: <b53155c7-a332-79f3-0798-abf128a06f3c@redhat.com> (raw)
In-Reply-To: <55310f7a-583c-3001-141c-4eac4afd185c@redhat.com>
On 07/05/21 17:29, Eric Blake wrote:
>> + qemu_mutex_lock(&s->lock);
>> QLIST_FOREACH(r, &s->suspended_reqs, next) {
>> if (!strcmp(r->tag, tag)) {
>> + qemu_mutex_unlock(&s->lock);
>> return true;
>> }
>> }
>> + qemu_mutex_unlock(&s->lock);
>> return false;
> Would code like this be easier to write by using QEMU_LOCK_GUARD from
> lockable.h?
Yes, this one would. In other cases (rule_check) it's not so clear cut.
It depends whether you prefer to have the simplest code, or rather to
have homogeneous use of either guards or lock/unlock.
Paolo
next prev parent reply other threads:[~2021-05-11 9:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2021-05-11 9:08 ` Emanuele Giuseppe Esposito
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=b53155c7-a332-79f3-0798-abf128a06f3c@redhat.com \
--to=pbonzini@redhat.com \
--cc=eblake@redhat.com \
--cc=eesposit@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).