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 <changyuanl@google.com>
This commit is contained in:
Changyuan Lyu 2024-09-14 10:30:24 -07:00 committed by Lencerf
parent 608fb13e3d
commit b306c1a7b2

View file

@ -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(())
}