[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/9] event poll: make epoll work for normal fd
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 3/9] event poll: make epoll work for normal fd |
Date: |
Thu, 21 Feb 2013 14:24:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
Il 21/02/2013 13:54, Liu Ping Fan ha scritto:
> From: Liu Ping Fan <address@hidden>
>
> When event poll can work with normal fd, we can port them
> onto the event loop.
Please start transitioning to the AioContext API instead. I doubt there
is any performance difference for 2-3 file descriptors between poll and
epoll, but if there were any we can introduce aio-linux.c that uses epoll.
I'll send later a patch to use AioContext instead of EventPoll for
virtio-blk dataplane.
Paolo
> Signed-off-by: Liu Ping Fan <address@hidden>
> ---
> hw/dataplane/event-poll.c | 36 ++++++++++++++++++++++++++++++++++++
> hw/dataplane/event-poll.h | 8 ++++++++
> 2 files changed, 44 insertions(+), 0 deletions(-)
>
> diff --git a/hw/dataplane/event-poll.c b/hw/dataplane/event-poll.c
> index 2b55c6e..b7dea53 100644
> --- a/hw/dataplane/event-poll.c
> +++ b/hw/dataplane/event-poll.c
> @@ -32,6 +32,42 @@ void event_poll_add(EventPoll *poll, EventHandler *handler,
> }
> }
>
> +void event_poll_add_fd(EventPoll *poll, int fd, uint32_t type,
> + EventHandler *handler)
> +{
> + struct epoll_event event = {
> + .events = type,
> + .data.ptr = handler,
> + };
> +
> + if (epoll_ctl(poll->epoll_fd, EPOLL_CTL_ADD, fd, &event) != 0) {
> + fprintf(stderr, "failed to add event fd handler to epoll: %m\n");
> + exit(1);
> + }
> +
> +}
> +void event_poll_del_fd(EventPoll *poll, int fd)
> +{
> + if (epoll_ctl(poll->epoll_fd, EPOLL_CTL_DEL, fd, NULL) != 0) {
> + fprintf(stderr, "failed to del event handler to epoll: %m\n");
> + exit(1);
> + }
> +}
> +
> +
> +void event_poll_modify_fd(EventPoll *poll, int fd, uint32_t type,
> + EventHandler *handler)
> +{
> + struct epoll_event event = {
> + .events = type,
> + .data.ptr = handler,
> + };
> + if (epoll_ctl(poll->epoll_fd, EPOLL_CTL_MOD, fd, &event) != 0) {
> + fprintf(stderr, "failed to modify event handler to epoll: %m\n");
> + exit(1);
> + }
> +}
> +
> /* Event callback for stopping event_poll() */
> static void handle_stop(EventHandler *handler)
> {
> diff --git a/hw/dataplane/event-poll.h b/hw/dataplane/event-poll.h
> index 3e8d3ec..606138c 100644
> --- a/hw/dataplane/event-poll.h
> +++ b/hw/dataplane/event-poll.h
> @@ -22,6 +22,8 @@ typedef void EventCallback(EventHandler *handler);
> struct EventHandler {
> EventNotifier *notifier; /* eventfd */
> EventCallback *callback; /* callback function */
> + void *opaque;
> + int fd; /* normal fd*/
> };
>
> typedef struct {
> @@ -32,6 +34,12 @@ typedef struct {
>
> void event_poll_add(EventPoll *poll, EventHandler *handler,
> EventNotifier *notifier, EventCallback *callback);
> +void event_poll_add_fd(EventPoll *poll, int fd, uint32_t type,
> + EventHandler *handler);
> +void event_poll_del_fd(EventPoll *poll, int fd);
> +void event_poll_modify_fd(EventPoll *poll, int fd, uint32_t type,
> + EventHandler *handler);
> +
> void event_poll_init(EventPoll *poll);
> void event_poll_cleanup(EventPoll *poll);
> void event_poll(EventPoll *poll);
>
- [Qemu-devel] [PATCH 0/9] introduce virtio net dataplane, Liu Ping Fan, 2013/02/21
- [Qemu-devel] [PATCH 2/9] vring: introduce vring_restore() to restore from img, Liu Ping Fan, 2013/02/21
- [Qemu-devel] [PATCH 3/9] event poll: make epoll work for normal fd, Liu Ping Fan, 2013/02/21
- [Qemu-devel] [PATCH 4/9] event poll: pass event type to event callback, Liu Ping Fan, 2013/02/21
- [Qemu-devel] [PATCH 5/9] event poll: enable event poll handle more than one event each time, Liu Ping Fan, 2013/02/21
- [Qemu-devel] [PATCH 6/9] virtio net: introduce dataplane for virtio net, Liu Ping Fan, 2013/02/21
- [Qemu-devel] [PATCH 7/9] tap: make tap peer work on dedicated data-plane thread, Liu Ping Fan, 2013/02/21
- [Qemu-devel] [PATCH 8/9] virtio net: enable dataplane for virtio net, Liu Ping Fan, 2013/02/21