Skip to content

Commit 93a2744

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "virtio,vhost: last minute fixes More small fixes. Most notably this fixes crashes and hangs in vhost-net" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: MAINTAINERS, mailmap: Update address for Peter Hilber virtio_config: clarify output parameters uapi: vduse: fix typo in comment vhost: Take a reference on the task in struct vhost_task. vhost-net: flush batched before enabling notifications Revert "vhost/net: Defer TX queue re-enable until after sendmsg" vhost-net: unbreak busy polling vhost-scsi: fix argument order in tport allocation error message
2 parents bf40f4b + cde7e7c commit 93a2744

File tree

7 files changed

+29
-32
lines changed

7 files changed

+29
-32
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ Paulo Alcantara <pc@manguebit.org> <palcantara@suse.com>
623623
Paulo Alcantara <pc@manguebit.org> <pc@manguebit.com>
624624
Pavankumar Kondeti <quic_pkondeti@quicinc.com> <pkondeti@codeaurora.org>
625625
Peter A Jonsson <pj@ludd.ltu.se>
626+
Peter Hilber <peter.hilber@oss.qualcomm.com> <quic_philber@quicinc.com>
626627
Peter Oruba <peter.oruba@amd.com>
627628
Peter Oruba <peter@oruba.de>
628629
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev> <pierre-louis.bossart@linux.intel.com>

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26785,7 +26785,7 @@ F: drivers/nvdimm/nd_virtio.c
2678526785
F: drivers/nvdimm/virtio_pmem.c
2678626786

2678726787
VIRTIO RTC DRIVER
26788-
M: Peter Hilber <quic_philber@quicinc.com>
26788+
M: Peter Hilber <peter.hilber@oss.qualcomm.com>
2678926789
L: virtualization@lists.linux.dev
2679026790
S: Maintained
2679126791
F: drivers/virtio/virtio_rtc_*

drivers/vhost/net.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -765,11 +765,11 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
765765
int err;
766766
int sent_pkts = 0;
767767
bool sock_can_batch = (sock->sk->sk_sndbuf == INT_MAX);
768-
bool busyloop_intr;
769768
bool in_order = vhost_has_feature(vq, VIRTIO_F_IN_ORDER);
770769

771770
do {
772-
busyloop_intr = false;
771+
bool busyloop_intr = false;
772+
773773
if (nvq->done_idx == VHOST_NET_BATCH)
774774
vhost_tx_batch(net, nvq, sock, &msg);
775775

@@ -780,10 +780,18 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
780780
break;
781781
/* Nothing new? Wait for eventfd to tell us they refilled. */
782782
if (head == vq->num) {
783-
/* Kicks are disabled at this point, break loop and
784-
* process any remaining batched packets. Queue will
785-
* be re-enabled afterwards.
783+
/* Flush batched packets to handle pending RX
784+
* work (if busyloop_intr is set) and to avoid
785+
* unnecessary virtqueue kicks.
786786
*/
787+
vhost_tx_batch(net, nvq, sock, &msg);
788+
if (unlikely(busyloop_intr)) {
789+
vhost_poll_queue(&vq->poll);
790+
} else if (unlikely(vhost_enable_notify(&net->dev,
791+
vq))) {
792+
vhost_disable_notify(&net->dev, vq);
793+
continue;
794+
}
787795
break;
788796
}
789797

@@ -839,22 +847,7 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
839847
++nvq->done_idx;
840848
} while (likely(!vhost_exceeds_weight(vq, ++sent_pkts, total_len)));
841849

842-
/* Kicks are still disabled, dispatch any remaining batched msgs. */
843850
vhost_tx_batch(net, nvq, sock, &msg);
844-
845-
if (unlikely(busyloop_intr))
846-
/* If interrupted while doing busy polling, requeue the
847-
* handler to be fair handle_rx as well as other tasks
848-
* waiting on cpu.
849-
*/
850-
vhost_poll_queue(&vq->poll);
851-
else
852-
/* All of our work has been completed; however, before
853-
* leaving the TX handler, do one last check for work,
854-
* and requeue handler if necessary. If there is no work,
855-
* queue will be reenabled.
856-
*/
857-
vhost_net_busy_poll_try_queue(net, vq);
858851
}
859852

860853
static void handle_tx_zerocopy(struct vhost_net *net, struct socket *sock)
@@ -1014,7 +1007,7 @@ static int peek_head_len(struct vhost_net_virtqueue *rvq, struct sock *sk)
10141007
}
10151008

10161009
static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk,
1017-
bool *busyloop_intr, unsigned int count)
1010+
bool *busyloop_intr, unsigned int *count)
10181011
{
10191012
struct vhost_net_virtqueue *rnvq = &net->vqs[VHOST_NET_VQ_RX];
10201013
struct vhost_net_virtqueue *tnvq = &net->vqs[VHOST_NET_VQ_TX];
@@ -1024,7 +1017,8 @@ static int vhost_net_rx_peek_head_len(struct vhost_net *net, struct sock *sk,
10241017

10251018
if (!len && rvq->busyloop_timeout) {
10261019
/* Flush batched heads first */
1027-
vhost_net_signal_used(rnvq, count);
1020+
vhost_net_signal_used(rnvq, *count);
1021+
*count = 0;
10281022
/* Both tx vq and rx socket were polled here */
10291023
vhost_net_busy_poll(net, rvq, tvq, busyloop_intr, true);
10301024

@@ -1180,7 +1174,7 @@ static void handle_rx(struct vhost_net *net)
11801174

11811175
do {
11821176
sock_len = vhost_net_rx_peek_head_len(net, sock->sk,
1183-
&busyloop_intr, count);
1177+
&busyloop_intr, &count);
11841178
if (!sock_len)
11851179
break;
11861180
sock_len += sock_hlen;

drivers/vhost/scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,7 @@ vhost_scsi_make_tport(struct target_fabric_configfs *tf,
28842884
check_len:
28852885
if (strlen(name) >= VHOST_SCSI_NAMELEN) {
28862886
pr_err("Emulated %s Address: %s, exceeds"
2887-
" max: %d\n", name, vhost_scsi_dump_proto_id(tport),
2887+
" max: %d\n", vhost_scsi_dump_proto_id(tport), name,
28882888
VHOST_SCSI_NAMELEN);
28892889
kfree(tport);
28902890
return ERR_PTR(-EINVAL);

include/linux/virtio_config.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,15 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
193193
}
194194

195195
static inline void virtio_get_features(struct virtio_device *vdev,
196-
u64 *features)
196+
u64 *features_out)
197197
{
198198
if (vdev->config->get_extended_features) {
199-
vdev->config->get_extended_features(vdev, features);
199+
vdev->config->get_extended_features(vdev, features_out);
200200
return;
201201
}
202202

203-
virtio_features_from_u64(features, vdev->config->get_features(vdev));
203+
virtio_features_from_u64(features_out,
204+
vdev->config->get_features(vdev));
204205
}
205206

206207
/**
@@ -326,11 +327,11 @@ int virtqueue_set_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask)
326327

327328
static inline
328329
bool virtio_get_shm_region(struct virtio_device *vdev,
329-
struct virtio_shm_region *region, u8 id)
330+
struct virtio_shm_region *region_out, u8 id)
330331
{
331332
if (!vdev->config->get_shm_region)
332333
return false;
333-
return vdev->config->get_shm_region(vdev, region, id);
334+
return vdev->config->get_shm_region(vdev, region_out, id);
334335
}
335336

336337
static inline bool virtio_is_little_endian(struct virtio_device *vdev)

include/uapi/linux/vduse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ struct vduse_iova_umem {
237237
* struct vduse_iova_info - information of one IOVA region
238238
* @start: start of the IOVA region
239239
* @last: last of the IOVA region
240-
* @capability: capability of the IOVA regsion
240+
* @capability: capability of the IOVA region
241241
* @reserved: for future use, needs to be initialized to zero
242242
*
243243
* Structure used by VDUSE_IOTLB_GET_INFO ioctl to get information of

kernel/vhost_task.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void vhost_task_stop(struct vhost_task *vtsk)
100100
* freeing it below.
101101
*/
102102
wait_for_completion(&vtsk->exited);
103+
put_task_struct(vtsk->task);
103104
kfree(vtsk);
104105
}
105106
EXPORT_SYMBOL_GPL(vhost_task_stop);
@@ -148,7 +149,7 @@ struct vhost_task *vhost_task_create(bool (*fn)(void *),
148149
return ERR_CAST(tsk);
149150
}
150151

151-
vtsk->task = tsk;
152+
vtsk->task = get_task_struct(tsk);
152153
return vtsk;
153154
}
154155
EXPORT_SYMBOL_GPL(vhost_task_create);

0 commit comments

Comments
 (0)