From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Gregory Haskins" Subject: Re: [PATCH 05/10] KVM: Adds ability to signal userspace using a file-descriptor Date: Mon, 14 May 2007 16:18:59 -0400 Message-ID: <46488BCD.BA47.005A.0@novell.com> References: <20070510123831.10200.4769.stgit@novell1.haskins.net> <20070510124706.10200.68571.stgit@novell1.haskins.net> <46470BF7.5080108@qumranet.com> <46481A61.BA47.005A.0@novell.com> <46485488.2010608@qumranet.com> <4648986B.9090403@qumranet.com> <46489B12.8030807@qumranet.com> <464879A3.BA47.005A.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: "Davide Libenzi" Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org >>> On Mon, May 14, 2007 at 3:12 PM, in message , Davide Libenzi wrote: > On Mon, 14 May 2007, Gregory Haskins wrote: > >> >>> On Mon, May 14, 2007 at 1:23 PM, in message <46489B12.8030807-atKUWr5tajBWk0Htik3J/w@public.gmane.org>, >> Avi Kivity wrote: >> > >> >> Do you close the signaled fd after receiving the signal/event? If you >> >> don't close it, eventfd will always return ready (POLLIN). >> >> >> > >> > We don't. Anyway, that's what we thought. Thanks for the confirmation. >> > >> >> And plus I just finished converting to Davide's eventfd, so its moot ;) >> >> On that topic, I could use some advice: >> >> I was originally planning on adding a new ioctl like KVM_VCPU_CREATE_EVENTFD > which would allocate a new eventfd and return it. However, I soon realized > that the only method to create an eventfd is sys_eventfd(), which is not > exported by the eventfd.h headerfile (presumably this must be a new system > call). >> >> So based on that, I figured I would change the model so that the usermode > app should call the eventfd open() call on its own, and then they could > register the fd with me. So KVM_VCPU_CREATE_EVENTFD becomes > KVM_VCPU_SET_EVENTFD (where - 1 "unregisters" it). >> >> Does this sound like a reasonable approach? If so, how does the usermode > app actually open the eventfd today? Is there a new glibc that I need to get > the new system call? Or can the app use open() somehow? If open(), what is > the path that should be specified? >> >> Conversely, if my first approach was the right one how do I invoke the > sys_eventfd()? Is there a way to invoke system calls in kernel mode? A > better way? >> >> Any advice appreciated. > > The eventfd syscall is defined in include/linux/syscalls.h > From userspace, till glibc aligns: > > #include > > #ifndef __NR_eventfd > #if defined(__x86_64__) > #define __NR_eventfd 283 > #elif defined(__i386__) > #define __NR_eventfd 323 > #else > #error Cannot detect your architecture! > #endif > #endif > > static int eventfd(int count) { > > return syscall(__NR_eventfd, count); > } > > > If the kernel side receives an fd from userspace, it must use: > > file = eventfd_fget(fd); > if (IS_ERR(file)) > .... > eventfd_signal(file, 1); > fput(file); > > > > - Davide Thanks Davide, That is very helpful. Is there any reason why we can't export eventfd_signal() and eventfd_fget() to modules? -Greg ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/