Skip to content

Commit 9d8fdb5

Browse files
committed
refactor(queue): remove mem from prepare_kick method
`mem` parameter was not used for anything. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 6afc248 commit 9d8fdb5

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,14 @@ impl VirtioBlock {
388388
queue: &mut Queue,
389389
index: u16,
390390
len: u32,
391-
mem: &GuestMemoryMmap,
392391
irq_trigger: &IrqTrigger,
393392
block_metrics: &BlockDeviceMetrics,
394393
) {
395394
queue.add_used(index, len).unwrap_or_else(|err| {
396395
error!("Failed to add available descriptor head {}: {}", index, err)
397396
});
398397

399-
if queue.prepare_kick(mem) {
398+
if queue.prepare_kick() {
400399
irq_trigger.trigger_irq(IrqType::Vring).unwrap_or_else(|_| {
401400
block_metrics.event_fails.inc();
402401
});
@@ -448,7 +447,6 @@ impl VirtioBlock {
448447
queue,
449448
head.index,
450449
finished.num_bytes_to_mem,
451-
mem,
452450
&self.irq_trigger,
453451
&self.metrics,
454452
);
@@ -500,7 +498,6 @@ impl VirtioBlock {
500498
queue,
501499
finished.desc_idx,
502500
finished.num_bytes_to_mem,
503-
mem,
504501
&self.irq_trigger,
505502
&self.metrics,
506503
);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,12 @@ impl Net {
272272
/// https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html#x1-320005
273273
/// 2.6.7.1 Driver Requirements: Used Buffer Notification Suppression
274274
fn try_signal_queue(&mut self, queue_type: NetQueue) -> Result<(), DeviceError> {
275-
// This is safe since we checked in the event handler that the device is activated.
276-
let mem = self.device_state.mem().unwrap();
277-
278275
let queue = match queue_type {
279276
NetQueue::Rx => &mut self.queues[RX_INDEX],
280277
NetQueue::Tx => &mut self.queues[TX_INDEX],
281278
};
282279

283-
if queue.prepare_kick(mem) {
280+
if queue.prepare_kick() {
284281
self.irq_trigger
285282
.trigger_irq(IrqType::Vring)
286283
.map_err(|err| {

src/vmm/src/devices/virtio/queue.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,7 @@ impl Queue {
657657
/// updates `used_event` and/or the notification conditions hold once more.
658658
///
659659
/// This is similar to the `vring_need_event()` method implemented by the Linux kernel.
660-
pub fn prepare_kick<M: GuestMemory>(&mut self, mem: &M) -> bool {
661-
debug_assert!(self.is_valid(mem));
662-
660+
pub fn prepare_kick(&mut self) -> bool {
663661
// If the device doesn't use notification suppression, always return true
664662
if !self.uses_notif_suppression {
665663
return true;
@@ -954,10 +952,10 @@ mod verification {
954952
// has been processed. This is done by the driver
955953
// defining a "used_event" index, which tells the device "please do not notify me until
956954
// used.ring[used_event] has been written to by you".
957-
let ProofContext(mut queue, mem) = ProofContext::bounded_queue();
955+
let ProofContext(mut queue, _) = ProofContext::bounded_queue();
958956

959957
let num_added_old = queue.num_added.0;
960-
let needs_notification = queue.prepare_kick(&mem);
958+
let needs_notification = queue.prepare_kick();
961959

962960
// uses_notif_suppression equivalent to VIRTIO_F_EVENT_IDX negotiated
963961
if !queue.uses_notif_suppression {
@@ -995,7 +993,7 @@ mod verification {
995993
// number of added descriptors being counted in Queue.num_added), and then use
996994
// "prepare_kick" to check if any of those descriptors should have triggered a
997995
// notification.
998-
let ProofContext(mut queue, mem) = ProofContext::bounded_queue();
996+
let ProofContext(mut queue, _) = ProofContext::bounded_queue();
999997

1000998
queue.enable_notif_suppression();
1001999
assert!(queue.uses_notif_suppression);
@@ -1023,7 +1021,7 @@ mod verification {
10231021
used_event >= interval_start && used_event <= interval_end
10241022
};
10251023

1026-
assert_eq!(queue.prepare_kick(&mem), needs_notification);
1024+
assert_eq!(queue.prepare_kick(), needs_notification);
10271025
}
10281026

10291027
#[kani::proof]
@@ -1529,7 +1527,7 @@ mod tests {
15291527
q.next_used = Wrapping(used_idx);
15301528
vq.avail.event.set(used_event);
15311529
q.num_added = Wrapping(num_added);
1532-
assert!(q.prepare_kick(m));
1530+
assert!(q.prepare_kick());
15331531
}
15341532
}
15351533
}
@@ -1541,23 +1539,23 @@ mod tests {
15411539
q.next_used = Wrapping(10);
15421540
vq.avail.event.set(6);
15431541
q.num_added = Wrapping(5);
1544-
assert!(q.prepare_kick(m));
1542+
assert!(q.prepare_kick());
15451543
}
15461544

15471545
{
15481546
// old used idx = used_event < next_used
15491547
q.next_used = Wrapping(10);
15501548
vq.avail.event.set(6);
15511549
q.num_added = Wrapping(4);
1552-
assert!(q.prepare_kick(m));
1550+
assert!(q.prepare_kick());
15531551
}
15541552

15551553
{
15561554
// used_event < old used idx < next_used
15571555
q.next_used = Wrapping(10);
15581556
vq.avail.event.set(6);
15591557
q.num_added = Wrapping(3);
1560-
assert!(!q.prepare_kick(m));
1558+
assert!(!q.prepare_kick());
15611559
}
15621560
}
15631561

0 commit comments

Comments
 (0)