[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll |
Date: |
Fri, 21 Feb 2020 12:59:48 +0000 |
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 properties that make
it "safe":
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 lifespan and will be inserted into ready_lists
multiple times. We need to safely remove it from ready_list to protect
against a corruption the next time the node is inserted into a
ready_list again:
/* Add a handler to a ready list */
static void add_ready_handler(AioHandlerList *ready_list,
AioHandler *node,
int revents)
{
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?
Stefan
signature.asc
Description: PGP signature
- [PATCH 0/5] aio-posix: towards an O(1) event loop, Stefan Hajnoczi, 2020/02/14
- [PATCH 1/5] aio-posix: fix use after leaving scope in aio_poll(), Stefan Hajnoczi, 2020/02/14
- [PATCH 2/5] aio-posix: don't pass ns timeout to epoll_wait(), Stefan Hajnoczi, 2020/02/14
- [PATCH 3/5] qemu/queue.h: add QLIST_SAFE_REMOVE(), Stefan Hajnoczi, 2020/02/14
- [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Stefan Hajnoczi, 2020/02/14
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Sergio Lopez, 2020/02/19
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Paolo Bonzini, 2020/02/19
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll,
Stefan Hajnoczi <=
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Paolo Bonzini, 2020/02/21
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Stefan Hajnoczi, 2020/02/21
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Stefan Hajnoczi, 2020/02/21
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Paolo Bonzini, 2020/02/21
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Stefan Hajnoczi, 2020/02/21
- Re: [PATCH 5/5] aio-posix: make AioHandler dispatch O(1) with epoll, Paolo Bonzini, 2020/02/21
[PATCH 4/5] aio-posix: make AioHandler deletion O(1), Stefan Hajnoczi, 2020/02/14
Re: [PATCH 0/5] aio-posix: towards an O(1) event loop, Stefan Hajnoczi, 2020/02/21