From patchwork Wed Aug 14 07:03:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 2844200 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C24349F2F4 for ; Wed, 14 Aug 2013 07:03:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D1632032D for ; Wed, 14 Aug 2013 07:03:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 50CAC20326 for ; Wed, 14 Aug 2013 07:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755506Ab3HNHD3 (ORCPT ); Wed, 14 Aug 2013 03:03:29 -0400 Received: from juliette.telenet-ops.be ([195.130.137.74]:43818 "EHLO juliette.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752942Ab3HNHD2 (ORCPT ); Wed, 14 Aug 2013 03:03:28 -0400 Received: from [192.168.1.100] ([178.119.235.68]) by juliette.telenet-ops.be with bizsmtp id CX3U1m0071VD9XW06X3Ugu; Wed, 14 Aug 2013 09:03:28 +0200 Message-ID: <520B2BC0.3050807@acm.org> Date: Wed, 14 Aug 2013 09:03:28 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: Asias He , kvm-devel Subject: [PATCH 2/2] vhost: Avoid that vhost_work_flush() returns early References: <520B2B47.9040002@acm.org> In-Reply-To: <520B2B47.9040002@acm.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If two or more items are queued on dev->work_list before vhost_worker() starts processing these then the value of work->done_seq will be set to the sequence number of a work item that has not yet been processed. Avoid this by letting vhost_worker() count the number of items that have already been processed. Signed-off-by: Bart Van Assche Cc: Michael S. Tsirkin Cc: Asias He --- drivers/vhost/vhost.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index e7ffc10..11d668a 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -202,7 +202,7 @@ static int vhost_worker(void *data) { struct vhost_dev *dev = data; struct vhost_work *work; - unsigned seq; + unsigned seq = 0; mm_segment_t oldfs = get_fs(); set_fs(USER_DS); @@ -216,14 +216,13 @@ static int vhost_worker(void *data) work = list_first_entry(&dev->work_list, struct vhost_work, node); list_del_init(&work->node); - seq = work->queue_seq; spin_unlock_irq(&dev->work_lock); __set_current_state(TASK_RUNNING); work->fn(work); spin_lock_irq(&dev->work_lock); - work->done_seq = seq; + work->done_seq = ++seq; if (work->flushing) wake_up_all(&work->done); }