Skip to content

Commit 25d2e72

Browse files
committed
refactor: only notify rx if there are processed packets
There is no point of notifing guest if there are no fully processed packets. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 8179d35 commit 25d2e72

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/vmm/src/devices/virtio/net/device.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,16 @@ impl Net {
523523
}
524524

525525
fn process_rx(&mut self) -> Result<(), DeviceError> {
526+
let mut signal_queue = false;
526527
// Read as many frames as possible.
527528
loop {
528529
match self.read_from_mmds_or_tap() {
529530
Ok(count) => {
530531
self.rx_bytes_read = count;
531532
self.metrics.rx_count.inc();
532-
if !self.rate_limited_rx_single_frame() {
533+
if self.rate_limited_rx_single_frame() {
534+
signal_queue = true;
535+
} else {
533536
self.rx_deferred_frame = true;
534537
break;
535538
}
@@ -553,9 +556,12 @@ impl Net {
553556
}
554557
}
555558

556-
// At this point we processed as many Rx frames as possible.
557-
// We have to wake the guest if at least one descriptor chain has been used.
558-
self.signal_used_queue(NetQueue::Rx)
559+
// We only notify guest if there is at least one packet processed successfully.
560+
if signal_queue {
561+
self.signal_used_queue(NetQueue::Rx)
562+
} else {
563+
Ok(())
564+
}
559565
}
560566

561567
// Process the deferred frame first, then continue reading from tap.

0 commit comments

Comments
 (0)