From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 5/5] ioeventfd: Introduce KVM_IOEVENTFD_FLAG_SOCKET Date: Wed, 06 Jul 2011 16:04:05 +0300 Message-ID: <4E145D45.9010000@redhat.com> References: <1309927078-5983-1-git-send-email-levinsasha928@gmail.com> <1309927078-5983-5-git-send-email-levinsasha928@gmail.com> <4E145783.2000605@redhat.com> <1309957134.15123.10.camel@sasha> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Ingo Molnar , Marcelo Tosatti , "Michael S. Tsirkin" , Pekka Enberg To: Sasha Levin Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50247 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814Ab1GFNET (ORCPT ); Wed, 6 Jul 2011 09:04:19 -0400 In-Reply-To: <1309957134.15123.10.camel@sasha> Sender: kvm-owner@vger.kernel.org List-ID: On 07/06/2011 03:58 PM, Sasha Levin wrote: > What about something as follows: > > This requires an addition of a mutex to struct ioeventfd. > > 1. When adding a new ioeventfd, scan exiting ioeventfds (we already do > it anyway) and check whether another ioeventfd is using the socket > already. > > 2. If the existing ioeventfd doesn't have a mutex assigned, create a new > mutex and assign it to both ioeventfds. That fails if there is a read already in progress on the old ioeventfd. Just create or share a mutex every time. Taking a mutex is cheap enough. > 3. If the existing ioeventfd already has a mutex assigned, copy it to > the new ioeventfd. > > 4. When removing an ioeventfd, do everything the other way around :) > > This mutex can be used to lock the write/read pair. > Not very elegant, but reasonable and simple. -- error compiling committee.c: too many arguments to function