Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-21 Thread Paolo Bonzini
On 21/02/20 16:29, Stefan Hajnoczi wrote: >> Yes. Let's keep the Q*_REMOVE cleanup on the todo list. I'd keep >> Q*_SAFE_REMOVE, but clear the pointer unconditionally in Q*_REMOVE so >> that we can have something like Q*_IN_LIST too. > QLIST_IS_INSERTED() is part of this patch series, although I

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-21 Thread Stefan Hajnoczi
On Fri, Feb 21, 2020 at 04:04:10PM +0100, Paolo Bonzini wrote: > On 21/02/20 15:47, Stefan Hajnoczi wrote: > >>> QLIST_SAFE_REMOVE(node, node_ready); /* remove from nested parent's > >>> list */ > >>> ^ would cause corruption if node->node_ready was stale! > >>> > >>> Would you lik

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-21 Thread Paolo Bonzini
On 21/02/20 15:47, Stefan Hajnoczi wrote: >>> QLIST_SAFE_REMOVE(node, node_ready); /* remove from nested parent's >>> list */ >>> ^ would cause corruption if node->node_ready was stale! >>> >>> Would you like me to add a comment? >> No, it's okay. > Are you happy with this series?

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-21 Thread Stefan Hajnoczi
On Fri, Feb 21, 2020 at 02:06:26PM +0100, Paolo Bonzini wrote: > On 21/02/20 13:59, Stefan Hajnoczi wrote: > > /* Add a handler to a ready list */ > > static void add_ready_handler(AioHandlerList *ready_list, > > AioHandler *node, > >

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-21 Thread Stefan Hajnoczi
On Fri, Feb 21, 2020 at 02:06:26PM +0100, Paolo Bonzini wrote: > On 21/02/20 13:59, Stefan Hajnoczi wrote: > > 1. It doesn't crash if the node is currently not on a list. > > 2. It clears the node's linked list pointers so that future linked > >list operations (like QLIST_SAFE_REMOVE()) aren't

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-21 Thread Paolo Bonzini
On 21/02/20 13:59, Stefan Hajnoczi wrote: > 1. It doesn't crash if the node is currently not on a list. > 2. It clears the node's linked list pointers so that future linked >list operations (like QLIST_SAFE_REMOVE()) aren't accidentally >performed on stale pointers. > > The node has a long

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-21 Thread Stefan Hajnoczi
On Wed, Feb 19, 2020 at 12:13:40PM +0100, Paolo Bonzini wrote: > On 14/02/20 18:17, Stefan Hajnoczi wrote: > > +while ((node = QLIST_FIRST(ready_list))) { > > +QLIST_SAFE_REMOVE(node, node_ready); > > Why does this need safe remove? Yes, it's necessary. QLIST_SAFE_REMOVE() has two pr

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-19 Thread Paolo Bonzini
On 14/02/20 18:17, Stefan Hajnoczi wrote: > +while ((node = QLIST_FIRST(ready_list))) { > +QLIST_SAFE_REMOVE(node, node_ready); Why does this need safe remove? Paolo > +progress = aio_dispatch_handler(ctx, node) || progress; > +}

Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-19 Thread Sergio Lopez
On Fri, Feb 14, 2020 at 05:17:12PM +, Stefan Hajnoczi wrote: > File descriptor monitoring is O(1) with epoll(7), but > aio_dispatch_handlers() still scans all AioHandlers instead of > dispatching just those that are ready. This makes aio_poll() O(n) with > respect to the total number of regist

[PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll

2020-02-14 Thread Stefan Hajnoczi
File descriptor monitoring is O(1) with epoll(7), but aio_dispatch_handlers() still scans all AioHandlers instead of dispatching just those that are ready. This makes aio_poll() O(n) with respect to the total number of registered handlers. Add a local ready_list to aio_poll() so that each nested