summaryrefslogtreecommitdiff
path: root/sys/dev/pv
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-05-31 08:10:25 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-05-31 08:10:25 +0000
commit45cb99fa0a7a72242054490f38272bbd720a7d48 (patch)
tree4125e9efcb8f0192ca02ba24f9eff94a3f19afc8 /sys/dev/pv
parent2da473ff11689e73cf400af461cf0566219c06cd (diff)
Optimize virtio_enqueue_trim() a bit by nuking unneeded
re-initializations of statically set fields. Move a common chunk out of both clauses of if/else. No intentional functional change. ok sf@
Diffstat (limited to 'sys/dev/pv')
-rw-r--r--sys/dev/pv/virtio.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/sys/dev/pv/virtio.c b/sys/dev/pv/virtio.c
index 116e1002d09..3107ee8c9ac 100644
--- a/sys/dev/pv/virtio.c
+++ b/sys/dev/pv/virtio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: virtio.c,v 1.9 2017/05/30 19:28:09 sf Exp $ */
+/* $OpenBSD: virtio.c,v 1.10 2017/05/31 08:10:24 krw Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/*
@@ -735,37 +735,27 @@ virtio_enqueue_trim(struct virtqueue *vq, int slot, int nsegs)
{
struct vq_entry *qe1 = &vq->vq_entries[slot];
struct vring_desc *vd = &vq->vq_desc[0];
- struct vq_entry *qe;
- int i, s;
+ int i;
if ((vd[slot].flags & VRING_DESC_F_INDIRECT) == 0) {
- qe1->qe_indirect = 0;
- qe1->qe_desc_base = vd;
qe1->qe_next = qe1->qe_index;
-
/*
* N.B.: the vq_entries are ASSUMED to be a contiguous
* block with slot being the index to the first one.
*/
- s = slot;
- for (i = 0; i < nsegs - 1; i++) {
- qe = &vq->vq_entries[s+1];
- vd[s].flags = VRING_DESC_F_NEXT;
- vd[s].next = qe->qe_index;
- s = qe->qe_index;
- }
- vd[s].flags = 0;
} else {
+ qe1->qe_next = 0;
vd = &vq->vq_desc[qe1->qe_index];
vd->len = sizeof(struct vring_desc) * nsegs;
vd = qe1->qe_desc_base;
- for (i = 0; i < nsegs; i++) {
- vd[i].flags = VRING_DESC_F_NEXT;
- if (i == (nsegs - 1))
- vd[i].flags = 0;
- }
- qe1->qe_next = 0;
+ slot = 0;
+ }
+
+ for (i = 0; i < nsegs -1 ; i++) {
+ vd[slot].flags = VRING_DESC_F_NEXT;
+ slot++;
}
+ vd[slot].flags = 0;
}
/*