From: Anthony Liguori <aliguori@us.ibm.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Ryan Harper <ryanh@us.ibm.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH] Refactor AIO to allow multiple AIO implementations
Date: Tue, 16 Sep 2008 14:03:05 -0500 [thread overview]
Message-ID: <48D002E9.3070400@us.ibm.com> (raw)
In-Reply-To: <f43fc5580809161050y384d37y61c53541ceba98db@mail.gmail.com>
Blue Swirl wrote:
> On 9/16/08, Anthony Liguori <aliguori@us.ibm.com> wrote:
>
>> This patch refactors the AIO layer to allow multiple AIO implementations. It's
>> only possible because of the recent signalfd() patch.
>>
>
>
>> +/* This is a simple lock used to protect the aio_handlers list. Specifically,
>> + * it's used to ensure that no callbacks are removed while we're walking and
>> + * dispatching callbacks.
>> + */
>> +static int walking_handlers;
>>
>
> Shouldn't this be volatile and/or atomic_t?
>
No, because this is just used to protect the aio_handlers list within
the same thread. Here's the scenario we're protecting:
Walk aio_handlers list =>
call handler =>
handler calls qemu_aio_set_fd_handler() to delete aio entry
Since we're walking the list, we can't delete an entry while walking.
This is the same problem we have in vl.c with the IOHandler list.
Unlike the IOHandler list, we don't walk the aio_handler list often
enough to just set a flag on the entry. In the case where
qemu_aio_set_fd_handler() is called from something other than a handler
callback, we need to be able to directly delete the entry element. This
is why we use the "lock", to detect that case.
It's not a real lock, because two threads are never trying to access it
at the same time. This is why we don't need volatile, atomic_t, or the
real locking primitives.
Regards,
Anthony Liguori
> Just wondering, why don't you use real locking operations, for example
> those in qemu-lock.h?
>
prev parent reply other threads:[~2008-09-16 19:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-16 16:24 [Qemu-devel] [PATCH] Refactor AIO to allow multiple AIO implementations Anthony Liguori
2008-09-16 17:50 ` Blue Swirl
2008-09-16 19:03 ` Anthony Liguori [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=48D002E9.3070400@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=ryanh@us.ibm.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).