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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4E272E7AD58 for ; Tue, 3 Oct 2023 14:29:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qngOA-0003O6-0B; Tue, 03 Oct 2023 10:28:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qngO7-0003Ng-HQ for qemu-devel@nongnu.org; Tue, 03 Oct 2023 10:28:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qngO3-0006o5-Rr for qemu-devel@nongnu.org; Tue, 03 Oct 2023 10:28:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696343314; 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=UBkeA1Gc0PshSGDHZUbB+zKV/8R319B8OtGmXPAzHQo=; b=C3zsK7cAGvo68mBDoQ/zszULZGvbefg7kJYgV5ip02A7WqfLhY8B7TS6JLlD764fwe/q6R 9pfCk7aSGbB2tcS0smT4pZa183ENLDrR59B2FkioEfGAlGlnPKPzFfwbWcvZM24/dKFOtH wK3y3+1GbkXhX1/bhSrmOPQi15R1IMY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-321-cvhe4Aj_O6y1VHdUbqO2_Q-1; Tue, 03 Oct 2023 10:28:23 -0400 X-MC-Unique: cvhe4Aj_O6y1VHdUbqO2_Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF02738143AB; Tue, 3 Oct 2023 14:28:22 +0000 (UTC) Received: from [10.39.192.186] (unknown [10.39.192.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B1B440C2013; Tue, 3 Oct 2023 14:28:21 +0000 (UTC) Message-ID: <41256188-cedc-a902-f2d9-8da1593f34e2@redhat.com> Date: Tue, 3 Oct 2023 16:28:20 +0200 MIME-Version: 1.0 Subject: Re: [PATCH 7/7] vhost-user: call VHOST_USER_SET_VRING_ENABLE synchronously Content-Language: en-US To: "Michael S. Tsirkin" Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, Eugenio Perez Martin , German Maglione , Liu Jiang , Sergio Lopez Pascual , Stefano Garzarella , Jason Wang References: <20230827182937.146450-8-lersek@redhat.com> <6d766ab4-b6b8-b64b-1f9d-60c558b56509@redhat.com> <20231002015259-mutt-send-email-mst@kernel.org> <20231002183627-mutt-send-email-mst@kernel.org> <037ac5f2-8c19-e1ff-fc96-3cda8755924f@redhat.com> <20231003102338-mutt-send-email-mst@kernel.org> From: Laszlo Ersek In-Reply-To: <20231003102338-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.129.124; envelope-from=lersek@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 10/3/23 16:25, Michael S. Tsirkin wrote: > On Tue, Oct 03, 2023 at 03:23:24PM +0200, Laszlo Ersek wrote: >> On 10/3/23 15:08, Stefan Hajnoczi wrote: >>> On Tue, 3 Oct 2023 at 08:27, Michael S. Tsirkin wrote: >>>> >>>> On Mon, Oct 02, 2023 at 05:13:26PM -0400, Stefan Hajnoczi wrote: >>>>> One more question: >>>>> >>>>> Why is the disabled state not needed by regular (non-vhost) virtio-net devices? >>>> >>>> Tap does the same - it purges queued packets: >>>> >>>> int tap_disable(NetClientState *nc) >>>> { >>>> TAPState *s = DO_UPCAST(TAPState, nc, nc); >>>> int ret; >>>> >>>> if (s->enabled == 0) { >>>> return 0; >>>> } else { >>>> ret = tap_fd_disable(s->fd); >>>> if (ret == 0) { >>>> qemu_purge_queued_packets(nc); >>>> s->enabled = false; >>>> tap_update_fd_handler(s); >>>> } >>>> return ret; >>>> } >>>> } >>> >>> tap_disable() is not equivalent to the vhost-user "started but >>> disabled" ring state. tap_disable() is a synchronous one-time action, >>> while "started but disabled" is a continuous state. >>> >>> The "started but disabled" ring state isn't needed to achieve this. >>> The back-end can just drop tx buffers upon receiving >>> VHOST_USER_SET_VRING_ENABLE .num=0. >>> >>> The history of the spec is curious. VHOST_USER_SET_VRING_ENABLE was >>> introduced before the the "started but disabled" state was defined, >>> and it explicitly mentions tap attach/detach: >>> >>> commit 7263a0ad7899994b719ebed736a1119cc2e08110 >>> Author: Changchun Ouyang >>> Date: Wed Sep 23 12:20:01 2015 +0800 >>> >>> vhost-user: add a new message to disable/enable a specific virt queue. >>> >>> Add a new message, VHOST_USER_SET_VRING_ENABLE, to enable or disable >>> a specific virt queue, which is similar to attach/detach queue for >>> tap device. >>> >>> and then later: >>> >>> commit c61f09ed855b5009f816242ce281fd01586d4646 >>> Author: Michael S. Tsirkin >>> Date: Mon Nov 23 12:48:52 2015 +0200 >>> >>> vhost-user: clarify start and enable >>> >>>> >>>> what about non tap backends? I suspect they just aren't >>>> used widely with multiqueue so no one noticed. >>> >>> I still don't understand why "started but disabled" is needed instead >>> of just two ring states: enabled and disabled. >>> >>> It seems like the cleanest path going forward is to keep the "ignore >>> rx, discard tx" semantics for virtio-net devices but to clarify in the >>> spec that other device types do not process the ring: >>> >>> " >>> * started but disabled: the back-end must not process the ring. For legacy >>> reasons there is an exception for the networking device, where the >>> back-end must process and discard any TX packets and not process >>> other rings. >>> " >>> >>> What do you think? >> >> ... from a vhost-user backend perspective, won't this create a need for >> all "ring processor" (~ virtio event loop) implementations to support >> both methods? IIUC, the "virtio pop" is usually independent of the >> particular device to which the requests are ultimately delivered. So the >> event loop would have to grow a new parameter regarding "what to do in >> the started-but-disabled state", the network device would have to pass >> in one value (-> pop & drop), and all other devices would have to pass >> in the other value (stop popping). >> >> ... I figure in rust-vmm/vhost it would affect the "handle_event" >> function in "crates/vhost-user-backend/src/event_loop.rs". >> >> Do I understand right? (Not disagreeing, just pondering the impact on >> backends.) >> >> Laszlo > > Already the case I guess - RX ring is not processed, TX is. Right? > Ah I see your point, this distinction must already exist in event loops. But... as far as I can tell, it's not there in rust-vmm/vhost. Laszlo