Skip to content

Commit 0d197a1

Browse files
jasowangmstsirkin
authored andcommitted
virtio-net: add cond_resched() to the command waiting loop
Adding cond_resched() to the command waiting loop for a better co-operation with the scheduler. This allows to give CPU a breath to run other task(workqueue) instead of busy looping when preemption is not allowed on a device whose CVQ might be slow. Signed-off-by: Jason Wang <jasowang@redhat.com> Message-Id: <20230720083839.481487-3-jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
1 parent b9f7425 commit 0d197a1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/net/virtio_net.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,8 +2570,10 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
25702570
* into the hypervisor, so the request should be handled immediately.
25712571
*/
25722572
while (!virtqueue_get_buf(vi->cvq, &tmp) &&
2573-
!virtqueue_is_broken(vi->cvq))
2573+
!virtqueue_is_broken(vi->cvq)) {
2574+
cond_resched();
25742575
cpu_relax();
2576+
}
25752577

25762578
return vi->ctrl->status == VIRTIO_NET_OK;
25772579
}

0 commit comments

Comments
 (0)