Skip to contentSkip to conversation

xen-hvm: Allow disabling buffer_io_timer

PATCH In review Jason Andryuk 3 participants 5 messages Dec 10, 2021 – Jan 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen-hvm: Allow disabling buffer_io_timer

commit f37f29d31488 "xen: slightly simplify bufioreq handling" hard coded setting req.count = 1 during initial field setup before the main loop. This missed a subtlety that an early exit from the loop when there are no ioreqs to process, would have req.count == 0 for the return value. handle_buffered_io() would then remove state->buffered_io_timer. Instead handle_buffered_iopage() is basically always returning true and handle_buffered_io() always re-setting the timer.

Restore the disabling of the timer by introducing a new handled_ioreq boolean and use as the return value. The named variable will more clearly show the intent of the code.

---
 hw/i386/xen/xen-hvm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/i386/xen/xen-hvm.c +4 -2
index 482be95415..cf8e500514 100644
@@ -1087,10 +1087,11 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req)
     }
 }
 
-static int handle_buffered_iopage(XenIOState *state)
+static bool handle_buffered_iopage(XenIOState *state)
 {
     buffered_iopage_t *buf_page = state->buffered_io_page;
     buf_ioreq_t *buf_req = NULL;
+    bool handled_ioreq = false;
     ioreq_t req;
     int qw;
 
@@ -1144,9 +1145,10 @@ static int handle_buffered_iopage(XenIOState *state)
         assert(!req.data_is_ptr);
 
         qatomic_add(&buf_page->read_pointer, qw + 1);
+        handled_ioreq = true;
     }
 
-    return req.count;
+    return handled_ioreq;
 }
 
 static void handle_buffered_io(void *opaque)
Signature · 1 line
2.33.1
Reviewed-by Paul Durrant on v1 1/1
#1 lore raw
Quoted 8 lines · Jason Andryuk

commit f37f29d31488 "xen: slightly simplify bufioreq handling" hard coded setting req.count = 1 during initial field setup before the main loop. This missed a subtlety that an early exit from the loop when there are no ioreqs to process, would have req.count == 0 for the return value. handle_buffered_io() would then remove state->buffered_io_timer. Instead handle_buffered_iopage() is basically always returning true and handle_buffered_io() always re-setting the timer.

Quoted 5 lines

Restore the disabling of the timer by introducing a new handled_ioreq boolean and use as the return value. The named variable will more clearly show the intent of the code.

#2 lore raw
Quoted 10 lines · Paul
Quoted 8 lines · Jason Andryuk

commit f37f29d31488 "xen: slightly simplify bufioreq handling" hard coded setting req.count = 1 during initial field setup before the main loop. This missed a subtlety that an early exit from the loop when there are no ioreqs to process, would have req.count == 0 for the return value. handle_buffered_io() would then remove state->buffered_io_timer. Instead handle_buffered_iopage() is basically always returning true and handle_buffered_io() always re-setting the timer.

Quoted 7 lines
Quoted 5 lines

Restore the disabling of the timer by introducing a new handled_ioreq boolean and use as the return value. The named variable will more clearly show the intent of the code.

Thanks, Paul.

What is the next step for getting this into QEMU?

To re-state more plainly, this patch fixes a bug to let QEMU go idle for longer stretches of time. Without it, buffer_io_timer continues to re-arm and fire every 100ms even if there is nothing to do.

Regards,
Jason

#3 lore raw
Quoted 15 lines · Jason Andryuk
Quoted 14 lines · Paul
Quoted 12 lines · Jason Andryuk

commit f37f29d31488 "xen: slightly simplify bufioreq handling" hard coded setting req.count = 1 during initial field setup before the main loop. This missed a subtlety that an early exit from the loop when there are no ioreqs to process, would have req.count == 0 for the return value. handle_buffered_io() would then remove state->buffered_io_timer. Instead handle_buffered_iopage() is basically always returning true and handle_buffered_io() always re-setting the timer.

Restore the disabling of the timer by introducing a new handled_ioreq boolean and use as the return value. The named variable will more clearly show the intent of the code.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks, Paul.

What is the next step for getting this into QEMU?

Anthony, can you queue this?

Paul

Quoted 6 lines

To re-state more plainly, this patch fixes a bug to let QEMU go idle for longer stretches of time. Without it, buffer_io_timer continues to re-arm and fire every 100ms even if there is nothing to do.

Regards,
Jason

#4 lore raw
Quoted 18 lines · Paul
Quoted 17 lines · Jason Andryuk
Quoted 16 lines · Paul
Quoted 13 lines · Jason Andryuk

commit f37f29d31488 "xen: slightly simplify bufioreq handling" hard coded setting req.count = 1 during initial field setup before the main loop. This missed a subtlety that an early exit from the loop when there are no ioreqs to process, would have req.count == 0 for the return value. handle_buffered_io() would then remove state->buffered_io_timer. Instead handle_buffered_iopage() is basically always returning true and handle_buffered_io() always re-setting the timer.

Restore the disabling of the timer by introducing a new handled_ioreq boolean and use as the return value. The named variable will more clearly show the intent of the code.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Thanks, Paul.

What is the next step for getting this into QEMU?

Anthony, can you queue this?

Yes, I'll send a pull request soon.

Sorry I tend to wait a while before preparing pull requests, especially when there's only one patch. But there's another one now.

Cheers,

Signature · 1 line
Anthony PERARD