Skip to content

Commit 1ab5d13

Browse files
jasowangmstsirkin
authored andcommitted
vhost: generalize adding used elem
Use one generic vhost_copy_to_user() instead of two dedicated accessor. This will simplify the conversion to fine grain accessors. About 2% improvement of PPS were seen during vitio-user txonly test. Signed-off-by: Jason Wang <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent c1ea02f commit 1ab5d13

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

drivers/vhost/vhost.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,16 +2273,7 @@ static int __vhost_add_used_n(struct vhost_virtqueue *vq,
22732273

22742274
start = vq->last_used_idx & (vq->num - 1);
22752275
used = vq->used->ring + start;
2276-
if (count == 1) {
2277-
if (vhost_put_user(vq, heads[0].id, &used->id)) {
2278-
vq_err(vq, "Failed to write used id");
2279-
return -EFAULT;
2280-
}
2281-
if (vhost_put_user(vq, heads[0].len, &used->len)) {
2282-
vq_err(vq, "Failed to write used len");
2283-
return -EFAULT;
2284-
}
2285-
} else if (vhost_copy_to_user(vq, used, heads, count * sizeof *used)) {
2276+
if (vhost_copy_to_user(vq, used, heads, count * sizeof *used)) {
22862277
vq_err(vq, "Failed to write used");
22872278
return -EFAULT;
22882279
}

0 commit comments

Comments
 (0)