From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C4F8C433E0 for ; Tue, 12 Jan 2021 18:45:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BC2B22B4B for ; Tue, 12 Jan 2021 18:45:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BC2B22B4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzOfO-0001lu-07 for qemu-devel@archiver.kernel.org; Tue, 12 Jan 2021 13:45:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzOJ3-0001Ti-Jt for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:22:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kzOIz-0002MW-T3 for qemu-devel@nongnu.org; Tue, 12 Jan 2021 13:22:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610475726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ltzSMsOBmoKeRI1L4IOCgQ7n1ZwKFysvzmkyq562kMs=; b=jVj6xSJOSm65BeYrnYAI1HHEXzlLL2tgyIET/5o2de49gl9qc6Mt03Ss7Gio+H0CYwcBv5 rf2HFXSfoBAGbD6KsdXxJ4Y+5gxCx/Ia7lFq2df2HXdzE59a7dx3fo30VWfGk8tJMTX88h 1pyQk5VLPEaXznHbHdmcIQn26T68F/8= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-558-r5UJI4sTMxCjK7DYVivpDQ-1; Tue, 12 Jan 2021 13:22:05 -0500 X-MC-Unique: r5UJI4sTMxCjK7DYVivpDQ-1 Received: by mail-qv1-f72.google.com with SMTP id j24so2086797qvg.8 for ; Tue, 12 Jan 2021 10:22:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ltzSMsOBmoKeRI1L4IOCgQ7n1ZwKFysvzmkyq562kMs=; b=TE8LjAADqaoTGbyBtxYOsCXZAYmSOqDqn5GcjgqsruV5ksTTRi82DuiJ0HCvJKeP9+ Cu/XYgn09Ne/9e4BGwQX8Q1a15/GXo6f9B5yXNep4mlPCJRkPLImXDyHPFvB26ydff02 /a4BCJRnHAAfmMkY5sHVZ9cKCZ42GED+IA6giy2sVpQg/tEmxcnFd5fry+dseEPDalwu Yfo4CCFT5qYzmYGwUhRlZkP9MuWYOkX3xvY0h0zeC+VcMAr9H/3K6s2BU1xZJ8ymt5G7 sVqe1u2AnRjFRTiFml7bDAYnK9GGFLbEqscUjxYdAFkH1TuMnpmdcWwRwgglJ2ZpJVYC VkgA== X-Gm-Message-State: AOAM533h0d/qAyhy3XxnMYP95kXahK6b3vU92xfgtByoHXuy6BlZFTYg +k4HKPJ4Ui/TwNdOByrkzBpayHhyc0i1Mz0h9EMZxWpCXQHWG/GdCC1lTp7f1SmqMS1AE6nME+H 5RzPXkvytPbTtZWnldaO/JFdSU4EWvTY= X-Received: by 2002:ac8:5441:: with SMTP id d1mr270432qtq.384.1610475724533; Tue, 12 Jan 2021 10:22:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxrsSzZftWuMuBvJWz3zjdZXTF9Rj/KikTBG5Gvotrb499zSfZZnuj1AhLDoewu2jIs4sw+lQd5WdkoGYx0ic= X-Received: by 2002:ac8:5441:: with SMTP id d1mr270398qtq.384.1610475724263; Tue, 12 Jan 2021 10:22:04 -0800 (PST) MIME-Version: 1.0 References: <20201120185105.279030-1-eperezma@redhat.com> <20201120185105.279030-7-eperezma@redhat.com> <20201207165848.GM203660@stefanha-x1.localdomain> In-Reply-To: <20201207165848.GM203660@stefanha-x1.localdomain> From: Eugenio Perez Martin Date: Tue, 12 Jan 2021 19:21:27 +0100 Message-ID: Subject: Re: [RFC PATCH 06/27] virtio: Add virtio_queue_get_used_notify_split To: Stefan Hajnoczi Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.251, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm list , "Michael S. Tsirkin" , Jason Wang , qemu-level , Daniel Daly , virtualization@lists.linux-foundation.org, Liran Alon , Eli Cohen , Nitin Shrivastav , Alex Barba , Christophe Fontaine , Juan Quintela , Lee Ballard , Lars Ganrot , Rob Miller , Stefano Garzarella , Howard Cai , Parav Pandit , vm , Salil Mehta , Stephen Finucane , Xiao W Wang , Sean Mooney , Stefan Hajnoczi , Jim Harford , Dmytro Kazantsev , Siwei Liu , Harpreet Singh Anand , Michael Lilja , Max Gurtovoy Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Mon, Dec 7, 2020 at 5:58 PM Stefan Hajnoczi wrote: > > On Fri, Nov 20, 2020 at 07:50:44PM +0100, Eugenio P=C3=A9rez wrote: > > This function is just used for a few commits, so SW LM is developed > > incrementally, and it is deleted after it is useful. > > > > For a few commits, only the events (irqfd, eventfd) are forwarded. > > s/eventfd/ioeventfd/ (irqfd is also an eventfd) > Oops, will fix, thanks! > > +bool virtio_queue_get_used_notify_split(VirtQueue *vq) > > +{ > > + VRingMemoryRegionCaches *caches; > > + hwaddr pa =3D offsetof(VRingUsed, flags); > > + uint16_t flags; > > + > > + RCU_READ_LOCK_GUARD(); > > + > > + caches =3D vring_get_region_caches(vq); > > + assert(caches); > > + flags =3D virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); > > + return !(VRING_USED_F_NO_NOTIFY & flags); > > +} > > QEMU stores the notification status: > > void virtio_queue_set_notification(VirtQueue *vq, int enable) > { > vq->notification =3D enable; <---- here > > if (!vq->vring.desc) { > return; > } > > if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { > virtio_queue_packed_set_notification(vq, enable); > } else { > virtio_queue_split_set_notification(vq, enable); > > I'm wondering why it's necessary to fetch from guest RAM instead of > using vq->notification? It also works for both split and packed > queues so the code would be simpler. To use vq->notification makes sense at the end of the series. However, at this stage (just routing notifications, not descriptors), vhost device is the one updating that flag, not qemu. Since we cannot just migrate used ring memory to qemu without migrating descriptors ring too, qemu needs to check guest's memory looking for vhost device updates on that flag. I can see how that deserves better documentation or even a better name. Also, this function should be in the shadow vq file, not virtio.c. Thanks!