From patchwork Fri Apr 1 13:19:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8724491 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A45E5C0553 for ; Fri, 1 Apr 2016 13:20:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC105203DB for ; Fri, 1 Apr 2016 13:20:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45754203DA for ; Fri, 1 Apr 2016 13:20:16 +0000 (UTC) Received: from localhost ([::1]:44316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alyzm-0008I1-F1 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Apr 2016 09:20:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alyzZ-0008GQ-C9 for qemu-devel@nongnu.org; Fri, 01 Apr 2016 09:20:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alyzX-0001q8-Jv for qemu-devel@nongnu.org; Fri, 01 Apr 2016 09:20:01 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:33453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alyzX-0001pz-BS for qemu-devel@nongnu.org; Fri, 01 Apr 2016 09:19:59 -0400 Received: by mail-wm0-x242.google.com with SMTP id i204so4580251wmd.0 for ; Fri, 01 Apr 2016 06:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DytoWtRE6aj6Ac7Xus4ISG05iPo/YPZSN49NIKsJsWk=; b=0oev4yQbdjBzGwOabGdvpzOiGqxan3j16v3aE+w9NQ2mxV9lsKwx0tt9M3z+dS8Lf1 YM+hbcj9H9iGOBASt2TW60S9bGyYObcCUpBjrftWEy8cgldPkwKGe+dMPaEhsBBw6CUb XPjkaUGCCiqXSZdOj6kfRY+1ypihTXkcrXSZk22NE6NbuFPVuH/OVyCgvXBojfAgVg/V QVv83rWUne0bhMyr/Kq4PXLA/s3YCRS18hQz6load83Hmwir8A01AUUqv/kJF8HXxX9x m99G1nqFpSKabKPIg/wmWTB3wrpn/B3WtmhT0EcAxxj5EPEyoVpYaP0KX7dMExidkJIc RpZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=DytoWtRE6aj6Ac7Xus4ISG05iPo/YPZSN49NIKsJsWk=; b=asD0hORcYQX2v0xg61RIU9hT5lvAMgPFKWSHPR+rrLVfemsBVrrGL3ysP+AROxOm5G 0zBZxprF9LAv4Lq6CrvJhlova3JRPLyJ7LR6bWLC/gCmrP91NRiMfM3H2BpnyOgMvucl Y9vfI5eWQqfL89oXRXN8HA2XKLY5IvCXdoL7ySgwmZy2p7W6vefDNna8iClgh0FFjhJV dNd69d8bc9fyMqsvk031Kw7VYpBfV37VUZdyqja9Pfn/ooG+m+zG25zzhrMzu7Ag2s4I CZMBLwSSnvVG+5d7beaIsbJIqZelCcqxe6CmjRGB6OjKmE5bjqo8upvyxfWMVvCVuqZA GSLA== X-Gm-Message-State: AD7BkJJePY0pb+CmWVgTYxfcQNvUbITMSWdB69HAg8qoxke+vwYgfDoqJqOHWpn/tskJ5Q== X-Received: by 10.28.47.143 with SMTP id v137mr4023403wmv.49.1459516798754; Fri, 01 Apr 2016 06:19:58 -0700 (PDT) Received: from 640k.lan (94-39-141-76.adsl-ull.clienti.tiscali.it. [94.39.141.76]) by smtp.gmail.com with ESMTPSA id a1sm14032334wje.43.2016.04.01.06.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Apr 2016 06:19:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 1 Apr 2016 15:19:46 +0200 Message-Id: <1459516794-23629-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1459516794-23629-1-git-send-email-pbonzini@redhat.com> References: <1459516794-23629-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Cc: famz@redhat.com, tubo@linux.vnet.ibm.com, mst@redhat.com, borntraeger@de.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com Subject: [Qemu-devel] [PATCH 1/9] virtio-dataplane: pass assign=true to virtio_queue_aio_set_host_notifier_handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 There is no need to run the handler one last time; the device is being reset and it is okay to drop requests that are pending in the virtqueue. Even in the case of migration, the requests would be processed when ioeventfd is re-enabled on the destination side: virtio_queue_set_host_notifier_fd_handler will call virtio_queue_host_notifier_read, which will start dataplane; the host notifier is then connected to the I/O thread and event_notifier_set is called to start processing it. By omitting this call, we dodge a possible cause of races between the dataplane thread on one side and the main/vCPU threads on the other. The virtio_queue_aio_set_host_notifier_handler function is now only ever called with assign=true, but for now this is left as is because the function parameters will change soon anyway. Signed-off-by: Paolo Bonzini Reviewed-by: Cornelia Huck --- hw/block/dataplane/virtio-blk.c | 2 +- hw/scsi/virtio-scsi-dataplane.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index e666dd4..fddd3ab 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -262,7 +262,7 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s) aio_context_acquire(s->ctx); /* Stop notifications for new requests from guest */ - virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, false, false); + virtio_queue_aio_set_host_notifier_handler(s->vq, s->ctx, true, false); /* Drain and switch bs back to the QEMU main loop */ blk_set_aio_context(s->conf->conf.blk, qemu_get_aio_context()); diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c index b44ac5d..21d5bfd 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -70,10 +70,10 @@ static void virtio_scsi_clear_aio(VirtIOSCSI *s) VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); int i; - virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, false, false); - virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, false, false); + virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, true, false); + virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, true, false); for (i = 0; i < vs->conf.num_queues; i++) { - virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, false, false); + virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, true, false); } }