qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] AioContext: fix broken placement of event_no


From: Fam Zheng
Subject: Re: [Qemu-devel] [PATCH v2] AioContext: fix broken placement of event_notifier_test_and_clear
Date: Mon, 20 Jul 2015 18:06:48 +0800
User-agent: Mutt/1.5.23 (2014-03-12)

On Mon, 07/20 15:46, Fam Zheng wrote:
> On Mon, 07/20 07:27, Paolo Bonzini wrote:
> > diff --git a/aio-win32.c b/aio-win32.c
> > index ea655b0..7afc999 100644
> > --- a/aio-win32.c
> > +++ b/aio-win32.c
> > @@ -337,10 +337,11 @@ bool aio_poll(AioContext *ctx, bool blocking)
> >              aio_context_acquire(ctx);
> >          }
> >  
> > -        if (first && aio_bh_poll(ctx)) {
> > -            progress = true;
> > +        if (first) {
> > +            event_notifier_test_and_clear(&ctx->notifier);
> 
> I'm looking at optimizing it but I don't fully understand the relationship
> between aio_prepare and WaitForMultipleObjects. Do they get the same set of
> events? What if a new event comes in between, for example, thread worker calls
> aio_notify()?
> 

After some reading I think WaitForMultipleObjects is for event notifiers and
aio_prepare is for select() on fd events.

It's a bit trickier than aio-posix, in the first iteration there could be
another event masking ctx->notifier so we don't know if we need to clear it.
But since MSDN says:

"""
... the return value minus WAIT_OBJECT_0 indicates the lpHandles array index of
the object that satisfied the wait. If more than one object became signaled
during the call, this is the array index of the signaled object with the
smallest index value of all the signaled objects.
"""

Maybe we can reverse events[] so that ctx->notifier will be the 0th one. And I
think we can always remove it after first iteration, am I right?

Fam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]