From b306c1a7b2483b2a91af3d4a324ddba49f653cdf Mon Sep 17 00:00:00 2001 From: Changyuan Lyu Date: Sat, 14 Sep 2024 10:30:24 -0700 Subject: [PATCH] perf(virtio): send 1 interrupt in a single loop virtio-net benchmark data (Gbits/sec) with iperf3 AMD | before | after ----|--------|------- TX | 53.77 | 55.64 RX | 49.18 | 57.6 Intel | before | after ----|--------|------- TX | 37.68 | 36.32 RX | 44.17 | 47.07 Signed-off-by: Changyuan Lyu --- alioth/src/virtio/queue/handlers.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/alioth/src/virtio/queue/handlers.rs b/alioth/src/virtio/queue/handlers.rs index a2317b8..6ff38cd 100644 --- a/alioth/src/virtio/queue/handlers.rs +++ b/alioth/src/virtio/queue/handlers.rs @@ -28,6 +28,7 @@ pub fn handle_desc<'m, Q>( where Q: VirtQueue<'m>, { + let mut send_irq = false; 'out: loop { if !queue.has_next_desc() { break; @@ -44,16 +45,17 @@ where Ok(None) => break 'out, Ok(Some(len)) => { queue.push_used(desc, len); - if queue.interrupt_enabled() { - fence(Ordering::SeqCst); - irq_sender.queue_irq(q_index) - } + send_irq = send_irq || queue.interrupt_enabled(); } } } queue.enable_notification(true); fence(Ordering::SeqCst); } + if send_irq { + fence(Ordering::SeqCst); + irq_sender.queue_irq(q_index) + } Ok(()) }