On Mon, 14 May 2007, Gregory Haskins wrote:

> >>> On Mon, May 14, 2007 at  1:23 PM, in message <[EMAIL PROTECTED]>,
> Avi Kivity <[EMAIL PROTECTED]> 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 <sys/syscall.h>

#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



-------------------------------------------------------------------------
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/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to