Re: [PATCH 2/2] vhost: Avoid that vhost_work_flush() returns early

Bart Van Assche
2013-08-14T15:19:10Z

On 08/14/13 13:46, Michael S. Tsirkin wrote:
> I'm confused by this explanation.
> done_seq is set here:
> if (work) {
> work->done_seq = seq;
> if (work->flushing)
> wake_up_all(&work->done);
> }
>
> and work is set here:
>
> if (!list_empty(&dev->work_list)) {
> work = list_first_entry(&dev->work_list,
> struct vhost_work, node);
> list_del_init(&work->node);
> seq = work->queue_seq;
> }
>
> this work is processed on the next line:
>
> if (work) {
> __set_current_state(TASK_RUNNING);
> work->fn(work);
> if (need_resched())
> schedule();
> }
>
> so how do we end up with a sequence of a work item
> that isn't processed?

I was wondering what would happen if a work item got requeued before
done_seq is set. I think you are right and this should work fine.

Bart.