Re: [PATCH 3/4] virtio_ring: introduce a per virtqueue waitqueue
From: Jason Wang <hidden>
Date: 2023-01-30 04:01:06
Also in:
lkml
On Sun, Jan 29, 2023 at 3:37 PM Hillf Danton [off-list ref] wrote:
On Mon, 26 Dec 2022 15:49:07 +0800 Jason Wang [off-list ref]quoted
@@ -2654,6 +2663,8 @@ static void vring_free(struct virtqueue *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); + wake_up_interruptible(&vq->wq); + if (vq->we_own_ring) { if (vq->packed_ring) { vring_free_queue(vq->vq.vdev,@@ -2863,4 +2874,22 @@ const struct vring *virtqueue_get_vring(struct virtqueue *vq) } EXPORT_SYMBOL_GPL(virtqueue_get_vring); +int virtqueue_wait_for_used(struct virtqueue *_vq) +{ + struct vring_virtqueue *vq = to_vvq(_vq); + + /* TODO: Tweak the timeout. */ + return wait_event_interruptible_timeout(vq->wq, + virtqueue_is_broken(_vq) || more_used(vq), HZ); +} +EXPORT_SYMBOL_GPL(virtqueue_wait_for_used);waker waiter --- --- vring_del_virtqueue vring_free(_vq); wakeup kfree(vq); get on CPU a tick later uaf ?
Exactly, this wakeup of vring_free is not needed. It's up to the driver to do the proper wake up to avoid race when subsystem un registration. Thanks