[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080307161854.E920@desktop>
Date: Fri, 7 Mar 2008 16:32:38 -1000 (HST)
From: Jeff Roberson <jroberson@...sapeake.net>
To: linux-kernel@...r.kernel.org
cc: riel@...hat.com
Subject: [PATCH] eventfd signal race in aio_complete()
Hello,
I have an application that makes use of eventfd to merge socket and aio
blocking with epoll in one thread. Under heavy loads the application
sometimes hangs when we receive notification from epoll that the eventfd
has an event ready but reading the aio completions produces no results.
Further investigation revealed that the aiocb was later ready with no
new event and completing it based on a timer resolved the application
hang.
This pointed to the eventfd being signaled prematurely and I verified that
this was indeed the problem. aio_complete() calls eventfd_signal() before
the event is actually placed on the completion ring. On a multi-processor
system it is possible to read the event from epoll and return to userspace
before aio_complete() finishes.
The enclosed patch simply moves the signaling to the bottom of the
function. I'm not 100% familiar with this code and it looks like it may
be possible to have spurious wakeups now but there will be no missed
wakeups. An application may also race the other way now and receive aio
completion before the signal, thus still leaving it with a signal with no
completion. signaling while the kioctx is locked would resolve this but I
was hesitant to introduce further nesting of spinlocks that might have
another order elsewhere.
Please keep me in the cc line for any necessary replies.
Thanks,
Jeff
Signed-off-by: Jeff Roberson <jeff@...ebsd.org>
View attachment "aiorace.diff" of type "TEXT/x-diff" (892 bytes)
Powered by blists - more mailing lists