mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* include/linux/aio_abi.h and IOCB_CMD_POLL
@ 2009-06-03 23:18 Goswin von Brederlow
  2009-06-04 13:16 ` Miklos Szeredi
  0 siblings, 1 reply; 5+ messages in thread
From: Goswin von Brederlow @ 2009-06-03 23:18 UTC (permalink / raw)
  To: LKML; +Cc: Goswin von Brederlow

Hi,

please CC me on replies.

I'm trying to write a fuse filesystem in ocaml using asynchronous
IO. For that to work nicely I need to poll /dev/fuse for incoming
requests without reading data from it (libfuse does that when called,
I just need to know when I can call it without it blocking).

Now to my problem. The header file for libaio says:

| /* Jeff Moyer says this was implemented in Red Hat AS2.1 and RHEL3.
|  * AFAICT, it was never in mainline, and should not be used. --RR */
| static inline void io_prep_poll(struct iocb *iocb, int fd, int events)

I tried using it anyway but all I got was an error that /dev/fuse is
not seekable. I also looked in the kernel source and didn't see any
implementation for poll there.

So my questions now are:

1) Why was this never adapted into mainline?
2) Do you know if there is any patch for it against a recent kernel?
3) Are there any alternatives to libaio that don't use threads and
   support polling?

MfG
        Goswin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: include/linux/aio_abi.h and IOCB_CMD_POLL
  2009-06-03 23:18 include/linux/aio_abi.h and IOCB_CMD_POLL Goswin von Brederlow
@ 2009-06-04 13:16 ` Miklos Szeredi
  2009-06-04 15:18   ` Goswin von Brederlow
  0 siblings, 1 reply; 5+ messages in thread
From: Miklos Szeredi @ 2009-06-04 13:16 UTC (permalink / raw)
  To: goswin-v-b; +Cc: linux-kernel, goswin-v-b

On Thu, 04 Jun 2009, Goswin von Brederlow wrote:
> 3) Are there any alternatives to libaio that don't use threads and
>    support polling?

There are the poll, select and epoll interfaces that block, but are
able to multiplex events from many file descriptors.

And there's the O_ASYNC flag that can be set with an fcntl(), that
sends a SIGIO signal on an I/O event.

All of these work on /dev/fuse.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: include/linux/aio_abi.h and IOCB_CMD_POLL
  2009-06-04 13:16 ` Miklos Szeredi
@ 2009-06-04 15:18   ` Goswin von Brederlow
  2009-06-04 15:19     ` Davide Libenzi
  0 siblings, 1 reply; 5+ messages in thread
From: Goswin von Brederlow @ 2009-06-04 15:18 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: goswin-v-b, linux-kernel

Miklos Szeredi <miklos@szeredi.hu> writes:

> On Thu, 04 Jun 2009, Goswin von Brederlow wrote:
>> 3) Are there any alternatives to libaio that don't use threads and
>>    support polling?
>
> There are the poll, select and epoll interfaces that block, but are
> able to multiplex events from many file descriptors.

Unfortunately libaio does not use an fd to pass events between user
and kernel space so one can't use poll, select or epoll to wait for
/dev/fuse or libaio to have some work pending. And none of them
replace libaio functionality in respect to read/write.

And alternating between io_getevents and e.g. select with a tiny
timeout seems like a verry bad idea efficiency wise.

> And there's the O_ASYNC flag that can be set with an fcntl(), that
> sends a SIGIO signal on an I/O event.

This might work together with libaio. Never used SIGIO though but I
will try. Thanks for the idea.

> All of these work on /dev/fuse.
>
> Thanks,
> Miklos

MfG
        Goswin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: include/linux/aio_abi.h and IOCB_CMD_POLL
  2009-06-04 15:18   ` Goswin von Brederlow
@ 2009-06-04 15:19     ` Davide Libenzi
  2009-06-04 22:53       ` Goswin von Brederlow
  0 siblings, 1 reply; 5+ messages in thread
From: Davide Libenzi @ 2009-06-04 15:19 UTC (permalink / raw)
  To: Goswin von Brederlow; +Cc: Miklos Szeredi, linux-kernel

On Thu, 4 Jun 2009, Goswin von Brederlow wrote:

> Miklos Szeredi <miklos@szeredi.hu> writes:
> 
> > On Thu, 04 Jun 2009, Goswin von Brederlow wrote:
> >> 3) Are there any alternatives to libaio that don't use threads and
> >>    support polling?
> >
> > There are the poll, select and epoll interfaces that block, but are
> > able to multiplex events from many file descriptors.
> 
> Unfortunately libaio does not use an fd to pass events between user
> and kernel space so one can't use poll, select or epoll to wait for
> /dev/fuse or libaio to have some work pending. And none of them
> replace libaio functionality in respect to read/write.

You can use the eventfd bridge between epoll/poll/select and AIO, that is 
available by quite some time.
This is an old example I made when the patch was posted:

http://www.xmailserver.org/eventfd-aio-test.c

This uses direct syscall interface, but you get the idea on how to do that 
with libaio (that I never used).


- Davide



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: include/linux/aio_abi.h and IOCB_CMD_POLL
  2009-06-04 15:19     ` Davide Libenzi
@ 2009-06-04 22:53       ` Goswin von Brederlow
  0 siblings, 0 replies; 5+ messages in thread
From: Goswin von Brederlow @ 2009-06-04 22:53 UTC (permalink / raw)
  To: Davide Libenzi; +Cc: Goswin von Brederlow, Miklos Szeredi, linux-kernel

Davide Libenzi <davidel@xmailserver.org> writes:

> On Thu, 4 Jun 2009, Goswin von Brederlow wrote:
>
>> Miklos Szeredi <miklos@szeredi.hu> writes:
>> 
>> > On Thu, 04 Jun 2009, Goswin von Brederlow wrote:
>> >> 3) Are there any alternatives to libaio that don't use threads and
>> >>    support polling?
>> >
>> > There are the poll, select and epoll interfaces that block, but are
>> > able to multiplex events from many file descriptors.
>> 
>> Unfortunately libaio does not use an fd to pass events between user
>> and kernel space so one can't use poll, select or epoll to wait for
>> /dev/fuse or libaio to have some work pending. And none of them
>> replace libaio functionality in respect to read/write.
>
> You can use the eventfd bridge between epoll/poll/select and AIO, that is 
> available by quite some time.
> This is an old example I made when the patch was posted:
>
> http://www.xmailserver.org/eventfd-aio-test.c
>
> This uses direct syscall interface, but you get the idea on how to do that 
> with libaio (that I never used).

Thanks. That example explains it nicely. There really should be
comments in libaio.h and an /usr/share/doc/libaio/examples/.

In case you wonder the libaio just wraps the system calls and provides
helpers in libaio.h. Basically the first 200 lines of the example are
libaio.h. Not 1:1 but nearly. The only difference is that io_prep_* do
not take an eventfd argument but there is

static inline void io_set_eventfd(struct iocb *iocb, int eventfd)

instead.


Now I have 2 ways of doing this. Always with the choices. :)

MfG
        Goswin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-04 22:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-03 23:18 include/linux/aio_abi.h and IOCB_CMD_POLL Goswin von Brederlow
2009-06-04 13:16 ` Miklos Szeredi
2009-06-04 15:18   ` Goswin von Brederlow
2009-06-04 15:19     ` Davide Libenzi
2009-06-04 22:53       ` Goswin von Brederlow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®