Re: [PATCH 3/3] eventfd: add internal reference counting to fix notifier race conditions

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

 



Davide Libenzi wrote:
> On Sun, 21 Jun 2009, Gregory Haskins wrote:
>
>   
>> This looks great, Davide.  I am fairly certain I can now solve the races
>> and even implement Michael's DEASSIGN feature with this patch in place. 
>> I will actually fire it up tomorrow when I am back in the office and
>> give it a spin, but I do not spy any more races via visual inspection.
>>
>> Kind Regards,
>> -Greg
>>
>> PS: I was wrong with my previous statement about requiring an embeddable
>> object (eventfd_notifier for me, eventfd_pollcb for you).  I think you
>> can technically solve this issue minimally by merely locking the POLLHUP
>> and exposing the kref.  However, I think that leads to an more awkward
>> interface (e.g. we already have eventfd_fget() plus we add a new one
>> like eventfd_refget(), which might confuse users), so I prefer what you
>> did here.  Just thought I would throw that out there in case you would
>> prefer to change even fewer lines.
>>     
>
> I actually ended up exposing the eventfd context anyway, since IMO is a 
> better option instead of holding references to the eventfd file (that 
> makes VFS people uneasy).
>   

I liked "version - 1"  better ;)

I think ultimately we still want to hold the fget() for
eventfd_signal(), as it is the producer side.  Without it, we have no
way of knowing when the last producer goes away if they happen to be an
in-kernel user.

Also, thinking about it some more, I think I like the non-wrapped pollcb
variant better now.  This is because I can uhook the wqh in the POLLHUP
and defer the kref_put() until later.  I think this combination gives me
the most ideal environment (even though technically I should not expect
more activity on the wait-queue after the POLLHUP).

In either case, I whipped up a super-lite patch with just the bare
minimum and then developed the KVM solution on top.  Things look really
good, now, and I am happy with the result.  As an aside, it only has the
following impact on the eventfd core:

 fs/eventfd.c            |   43 ++++++++++++++++++++++++++++++++++++-------
 include/linux/eventfd.h |    7 +++++++
 2 files changed, 43 insertions(+), 7 deletions(-)

Ill post the series, including the KVM portions, for review.

Thanks Davide,
-Greg



Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux