Displaying 20 results from an estimated 146 matches for "work_list".
2016 Apr 26
2
[PATCH 1/2] vhost: simplify work flushing
...p;flush.wait_event);
+ }
}
EXPORT_SYMBOL_GPL(vhost_work_flush);
@@ -254,7 +251,6 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
spin_lock_irqsave(&dev->work_lock, flags);
if (list_empty(&work->node)) {
list_add_tail(&work->node, &dev->work_list);
- work->queue_seq++;
spin_unlock_irqrestore(&dev->work_lock, flags);
wake_up_process(dev->worker);
} else {
@@ -310,7 +306,6 @@ static int vhost_worker(void *data)
{
struct vhost_dev *dev = data;
struct vhost_work *work = NULL;
- unsigned uninitialized_var(seq);
mm_se...
2016 Apr 26
2
[PATCH 1/2] vhost: simplify work flushing
...p;flush.wait_event);
+ }
}
EXPORT_SYMBOL_GPL(vhost_work_flush);
@@ -254,7 +251,6 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
spin_lock_irqsave(&dev->work_lock, flags);
if (list_empty(&work->node)) {
list_add_tail(&work->node, &dev->work_list);
- work->queue_seq++;
spin_unlock_irqrestore(&dev->work_lock, flags);
wake_up_process(dev->worker);
} else {
@@ -310,7 +306,6 @@ static int vhost_worker(void *data)
{
struct vhost_dev *dev = data;
struct vhost_work *work = NULL;
- unsigned uninitialized_var(seq);
mm_se...
2016 Apr 26
0
[PATCH 2/2] vhost: lockless enqueuing
...GPL(vhost_poll_flush);
void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
{
- unsigned long flags;
+ if (!dev->worker)
+ return;
- spin_lock_irqsave(&dev->work_lock, flags);
- if (list_empty(&work->node)) {
- list_add_tail(&work->node, &dev->work_list);
- spin_unlock_irqrestore(&dev->work_lock, flags);
+ if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) {
+ /* We can only add the work to the list after we're
+ * sure it was not in the list.
+ */
+ smp_mb();
+ llist_add(&work->node, &dev->work_list);...
2016 Apr 26
2
[PATCH 2/2] vhost: lockless enqueuing
...k_queue(struct vhost_dev *dev, struct vhost_work *work)
> {
> - unsigned long flags;
> + if (!dev->worker)
> + return;
>
> - spin_lock_irqsave(&dev->work_lock, flags);
> - if (list_empty(&work->node)) {
> - list_add_tail(&work->node, &dev->work_list);
> - spin_unlock_irqrestore(&dev->work_lock, flags);
> + if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) {
> + /* We can only add the work to the list after we're
> + * sure it was not in the list.
> + */
> + smp_mb();
> + llist_add(&work-...
2016 Apr 26
2
[PATCH 2/2] vhost: lockless enqueuing
...k_queue(struct vhost_dev *dev, struct vhost_work *work)
> {
> - unsigned long flags;
> + if (!dev->worker)
> + return;
>
> - spin_lock_irqsave(&dev->work_lock, flags);
> - if (list_empty(&work->node)) {
> - list_add_tail(&work->node, &dev->work_list);
> - spin_unlock_irqrestore(&dev->work_lock, flags);
> + if (!test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) {
> + /* We can only add the work to the list after we're
> + * sure it was not in the list.
> + */
> + smp_mb();
> + llist_add(&work-...
2023 Jun 05
1
[PATCH 1/1] vhost: Fix crash during early vhost_transport_send_pkt calls
...test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) {
@@ -255,8 +255,8 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
* sure it was not in the list.
* test_and_set_bit() implies a memory barrier.
*/
- llist_add(&work->node, &dev->worker->work_list);
- vhost_task_wake(dev->worker->vtsk);
+ llist_add(&work->node, &dev->worker.work_list);
+ vhost_task_wake(dev->worker.vtsk);
}
}
EXPORT_SYMBOL_GPL(vhost_work_queue);
@@ -264,7 +264,7 @@ EXPORT_SYMBOL_GPL(vhost_work_queue);
/* A lockless hint for busy polling code to...
2023 Jun 05
1
[PATCH 1/1] vhost: Fix crash during early vhost_transport_send_pkt calls
...test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) {
@@ -255,8 +255,8 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
* sure it was not in the list.
* test_and_set_bit() implies a memory barrier.
*/
- llist_add(&work->node, &dev->worker->work_list);
- vhost_task_wake(dev->worker->vtsk);
+ llist_add(&work->node, &dev->worker.work_list);
+ vhost_task_wake(dev->worker.vtsk);
}
}
EXPORT_SYMBOL_GPL(vhost_work_queue);
@@ -264,7 +264,7 @@ EXPORT_SYMBOL_GPL(vhost_work_queue);
/* A lockless hint for busy polling code to...
2023 May 31
1
[syzbot] [kvm?] [net?] [virt?] general protection fault in vhost_work_queue
...test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) {
@@ -255,8 +257,8 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
* sure it was not in the list.
* test_and_set_bit() implies a memory barrier.
*/
- llist_add(&work->node, &dev->worker->work_list);
- wake_up_process(dev->worker->vtsk->task);
+ llist_add(&work->node, &dev->worker.work_list);
+ wake_up_process(vtsk->task);
}
}
EXPORT_SYMBOL_GPL(vhost_work_queue);
@@ -264,7 +266,7 @@ EXPORT_SYMBOL_GPL(vhost_work_queue);
/* A lockless hint for busy polling code...
2023 Jun 01
1
[syzbot] [kvm?] [net?] [virt?] general protection fault in vhost_work_queue
...ST_WORK_QUEUED, &work->flags)) {
>@@ -255,8 +257,8 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
> * sure it was not in the list.
> * test_and_set_bit() implies a memory barrier.
> */
>- llist_add(&work->node, &dev->worker->work_list);
>- wake_up_process(dev->worker->vtsk->task);
>+ llist_add(&work->node, &dev->worker.work_list);
>+ wake_up_process(vtsk->task);
> }
> }
> EXPORT_SYMBOL_GPL(vhost_work_queue);
>@@ -264,7 +266,7 @@ EXPORT_SYMBOL_GPL(vhost_work_queue);
> /* A loc...
2023 Jun 06
1
[PATCH 1/1] vhost: Fix crash during early vhost_transport_send_pkt calls
...ST_WORK_QUEUED, &work->flags)) {
>@@ -255,8 +255,8 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
> * sure it was not in the list.
> * test_and_set_bit() implies a memory barrier.
> */
>- llist_add(&work->node, &dev->worker->work_list);
>- vhost_task_wake(dev->worker->vtsk);
>+ llist_add(&work->node, &dev->worker.work_list);
>+ vhost_task_wake(dev->worker.vtsk);
> }
> }
> EXPORT_SYMBOL_GPL(vhost_work_queue);
>@@ -264,7 +264,7 @@ EXPORT_SYMBOL_GPL(vhost_work_queue);
> /* A lockle...
2020 Mar 18
4
[PATCH 1/9] drm/vblank: Add vblank works
..., *next;
> + LIST_HEAD(list);
> + u64 count;
> + int ret;
> +
> + spin_lock_irq(&vblank->dev->event_lock);
> +
> + ret = wait_event_interruptible_lock_irq(vblank->queue,
> + kthread_should_stop() ||
> + !list_empty(&vblank->vblank_work.work_list),
> + vblank->dev->event_lock);
> +
> + WARN_ON(ret && !kthread_should_stop() &&
> + list_empty(&vblank->vblank_work.irq_list) &&
> + list_empty(&vblank->vblank_work.work_list));
> +
> + list_for_each_entry_safe(work, next...
2020 Mar 18
0
[PATCH 1/9] drm/vblank: Add vblank works
...uld_stop()) {
+ struct drm_vblank_work *work, *next;
+ LIST_HEAD(list);
+ u64 count;
+ int ret;
+
+ spin_lock_irq(&vblank->dev->event_lock);
+
+ ret = wait_event_interruptible_lock_irq(vblank->queue,
+ kthread_should_stop() ||
+ !list_empty(&vblank->vblank_work.work_list),
+ vblank->dev->event_lock);
+
+ WARN_ON(ret && !kthread_should_stop() &&
+ list_empty(&vblank->vblank_work.irq_list) &&
+ list_empty(&vblank->vblank_work.work_list));
+
+ list_for_each_entry_safe(work, next,
+ &vblank->vblank_wor...
2023 Jun 06
2
[CFT][PATCH v3] fork, vhost: Use CLONE_THREAD to fix freezer/ps regression
...you spell to explain why this can't work (again, in this simple case) ?
My current (and I know, very poor) understanding is that .release() should
roughly do the following:
1. Ensure that vhost_work_queue() can't add the new callbacks
2. Call vhost_dev_flush() to ensure that worker->work_list is empty
3. Call vhost_task_stop()
so why this sequence can't work if we turn vhost_dev_flush() into something like
void vhost_dev_flush(struct vhost_dev *dev)
{
struct vhost_flush_struct flush;
if (dev->worker) {
// this assumes that vhost_task_create() uses CLONE_THREAD
if...
2020 Mar 27
2
[PATCH 1/9] drm/vblank: Add vblank works
...> > +
> > > + spin_lock_irq(&vblank->dev->event_lock);
> > > +
> > > + ret = wait_event_interruptible_lock_irq(vblank->queue,
> > > + kthread_should_stop()
> > > + !list_empty(&vblank-
> > > > vblank_work.work_list),
> > > + vblank->dev-
> > > > event_lock);
> > > +
> > > + WARN_ON(ret && !kthread_should_stop() &&
> > > + list_empty(&vblank->vblank_work.irq_list) &&
> > > + list_empty(&vblank->vblank_w...
2023 May 23
4
[PATCH 3/3] fork, vhost: Use CLONE_THREAD to fix freezer/ps regression
...probably we shouldn't call get_signal() if we have already dequeued SIGKILL.
> but let me think tomorrow.
May be something like this... I don't like it but I can't suggest anything better
right now.
bool killed = false;
for (;;) {
...
node = llist_del_all(&worker->work_list);
if (!node) {
schedule();
/*
* When we get a SIGKILL our release function will
* be called. That will stop new IOs from being queued
* and check for outstanding cmd responses. It will then
* call vhost_task_stop to tell us to return and exit.
*/
if (signal_pending(cu...
2010 Jul 29
1
[PATCH] vhost: locking/rcu cleanup
I saw WARN_ON(!list_empty(&dev->work_list)) trigger
so our custom flush is not as airtight as need be.
This patch switches to a simple atomic counter + srcu instead of
the custom locked queue + flush implementation.
This will slow down the setup ioctls, which should not matter -
it's slow path anyway. We use the expedited flush to at...
2010 Jul 29
1
[PATCH] vhost: locking/rcu cleanup
I saw WARN_ON(!list_empty(&dev->work_list)) trigger
so our custom flush is not as airtight as need be.
This patch switches to a simple atomic counter + srcu instead of
the custom locked queue + flush implementation.
This will slow down the setup ioctls, which should not matter -
it's slow path anyway. We use the expedited flush to at...
2020 Mar 27
0
[PATCH 1/9] drm/vblank: Add vblank works
...; > + int ret;
> > +
> > + spin_lock_irq(&vblank->dev->event_lock);
> > +
> > + ret = wait_event_interruptible_lock_irq(vblank->queue,
> > + kthread_should_stop()
> > ||
> > + !list_empty(&vblank-
> > >vblank_work.work_list),
> > + vblank->dev-
> > >event_lock);
> > +
> > + WARN_ON(ret && !kthread_should_stop() &&
> > + list_empty(&vblank->vblank_work.irq_list) &&
> > + list_empty(&vblank->vblank_work.work_list));
> > +
&g...
2020 Apr 13
0
[PATCH 1/9] drm/vblank: Add vblank works
...t;event_lock);
> > > > +
> > > > + ret = wait_event_interruptible_lock_irq(vblank->queue,
> > > > + kthread_should
> > > > _stop()
> > > > + !list_empty(&v
> > > > blank-
> > > > > vblank_work.work_list),
> > > > + vblank->dev-
> > > > > event_lock);
> > > > +
> > > > + WARN_ON(ret && !kthread_should_stop() &&
> > > > + list_empty(&vblank->vblank_work.irq_list) &&
> > > > + list_...
2023 Mar 28
1
[PATCH v6 02/11] vhost, vhost-net: add helper to check if vq has work
..., struct vhost_work *work)
EXPORT_SYMBOL_GPL(vhost_work_queue);
/* A lockless hint for busy polling code to exit the loop */
-bool vhost_has_work(struct vhost_dev *dev)
+bool vhost_vq_has_work(struct vhost_virtqueue *vq)
{
- return dev->worker && !llist_empty(&dev->worker->work_list);
+ return vq->worker && !llist_empty(&vq->worker->work_list);
}
-EXPORT_SYMBOL_GPL(vhost_has_work);
+EXPORT_SYMBOL_GPL(vhost_vq_has_work);
void vhost_poll_queue(struct vhost_poll *poll)
{
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index e72b665ba3a5..0dde1...