[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/9] aio-posix: move RCU_READ_LOCK() into run_poll_handlers()
From: |
Stefan Hajnoczi |
Subject: |
[PULL 4/9] aio-posix: move RCU_READ_LOCK() into run_poll_handlers() |
Date: |
Wed, 11 Mar 2020 12:40:40 +0000 |
Now that run_poll_handlers_once() is only called by run_poll_handlers()
we can improve the CPU time profile by moving the expensive
RCU_READ_LOCK() out of the polling loop.
This reduces the run_poll_handlers() from 40% CPU to 10% CPU in perf's
sampling profiler output.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Link: https://lore.kernel.org/r/address@hidden
Message-Id: <address@hidden>
---
util/aio-posix.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/util/aio-posix.c b/util/aio-posix.c
index 65964a2597..11a4971955 100644
--- a/util/aio-posix.c
+++ b/util/aio-posix.c
@@ -583,16 +583,6 @@ static bool run_poll_handlers_once(AioContext *ctx,
int64_t *timeout)
bool progress = false;
AioHandler *node;
- /*
- * Optimization: ->io_poll() handlers often contain RCU read critical
- * sections and we therefore see many rcu_read_lock() -> rcu_read_unlock()
- * -> rcu_read_lock() -> ... sequences with expensive memory
- * synchronization primitives. Make the entire polling loop an RCU
- * critical section because nested rcu_read_lock()/rcu_read_unlock() calls
- * are cheap.
- */
- RCU_READ_LOCK_GUARD();
-
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
if (!QLIST_IS_INSERTED(node, node_deleted) && node->io_poll &&
aio_node_check(ctx, node->is_external) &&
@@ -636,6 +626,16 @@ static bool run_poll_handlers(AioContext *ctx, int64_t
max_ns, int64_t *timeout)
trace_run_poll_handlers_begin(ctx, max_ns, *timeout);
+ /*
+ * Optimization: ->io_poll() handlers often contain RCU read critical
+ * sections and we therefore see many rcu_read_lock() -> rcu_read_unlock()
+ * -> rcu_read_lock() -> ... sequences with expensive memory
+ * synchronization primitives. Make the entire polling loop an RCU
+ * critical section because nested rcu_read_lock()/rcu_read_unlock() calls
+ * are cheap.
+ */
+ RCU_READ_LOCK_GUARD();
+
start_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
do {
progress = run_poll_handlers_once(ctx, timeout);
--
2.24.1
- [PULL 0/9] Block patches, Stefan Hajnoczi, 2020/03/11
- [PULL 1/9] qemu/queue.h: clear linked list pointers on remove, Stefan Hajnoczi, 2020/03/11
- [PULL 2/9] aio-posix: remove confusing QLIST_SAFE_REMOVE(), Stefan Hajnoczi, 2020/03/11
- [PULL 3/9] aio-posix: completely stop polling when disabled, Stefan Hajnoczi, 2020/03/11
- [PULL 4/9] aio-posix: move RCU_READ_LOCK() into run_poll_handlers(),
Stefan Hajnoczi <=
- [PULL 6/9] aio-posix: simplify FDMonOps->update() prototype, Stefan Hajnoczi, 2020/03/11
- [PULL 7/9] aio-posix: add io_uring fd monitoring implementation, Stefan Hajnoczi, 2020/03/11
- [PULL 9/9] aio-posix: remove idle poll handlers to improve scalability, Stefan Hajnoczi, 2020/03/11
- [PULL 8/9] aio-posix: support userspace polling of fd monitoring, Stefan Hajnoczi, 2020/03/11
- [PULL 5/9] aio-posix: extract ppoll(2) and epoll(7) fd monitoring, Stefan Hajnoczi, 2020/03/11
- Re: [PULL 0/9] Block patches, no-reply, 2020/03/11
- Re: [PULL 0/9] Block patches, no-reply, 2020/03/11
- Re: [PULL 0/9] Block patches, Peter Maydell, 2020/03/11