Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2330317rwr; Fri, 21 Apr 2023 07:31:27 -0700 (PDT) X-Google-Smtp-Source: AKy350bpSpYMrZ64oIWVOa9FBcp3tcIZUJORISYCQL6YdRk7YBv8OGqFqcn7pRCYWAuFaHPe2p9K X-Received: by 2002:a05:6602:398a:b0:763:55ab:de with SMTP id bw10-20020a056602398a00b0076355ab00demr3223420iob.1.1682087487621; Fri, 21 Apr 2023 07:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682087487; cv=none; d=google.com; s=arc-20160816; b=kFCQ+/X/s2Tdk3KlbeHJHmuWOeguaZZO3fhWFTWduKQVw2Ef8O8bRNv4dq8d0kc1qZ s3RvO+WKr/er4AqcFuyoWYRmhKi0EArkNuwgzfG5s/JLqF/dQE9tXlLU+eIIuRSGosgz NgzT8sBerlhNhtDc68HJNOvdb7VersT0APUjN3huZzlEzsBn5RvuAk0rAMoaHzFIO3E8 TszpOzNYebhMxnewDQGNg/TssHrXj511+4Ls7Cftp2V3XLM5iAYogBqLuGeL71L3EMG5 VjMfnQf8UTRuHpu/c4nj3Uc8B29nujvbk/v2JU0sCwzo9jseHiO/VVpA9REaxFpjROPD y96w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=gh2FKDIw04E1Y2danPvwRc3umx0NY4oLoGalTyKkosA=; b=ACJG3zRB5VKMx0Pi2Xx1Q0dV5kY00X/NJmhStJ0wXca2iXb9ezzhvoxbF25HqL575H wQNdD3ng5p2T2/WQcJ8urZKYIiwmwm1a28DRIOjbkzol823SKn+dn1nn5hyYNjBdaAwE b1ScFH1YxUGYhob+2EOvoSWuGuE5XYPCb5OCr76KZvzYI+vmHI2iL06XSkz9uF4GWFsA BMsHPMm9sXEUCMM7bShti6xiGXUCzw2HL4zVDU/ZgiSq4bZdei+XMZ39rJ0HJAILZKYn hPEppQKIs7dcqjZqD2LtREkdNO4lA3vU6ESUz+VKdU1V2Ine8oEzs2qVwFPsA73zQ5JO MTuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bDyTg0cm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a056602234400b006f6623df639si4069635iot.7.2023.04.21.07.31.11; Fri, 21 Apr 2023 07:31:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bDyTg0cm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232634AbjDUO3Y (ORCPT + 99 others); Fri, 21 Apr 2023 10:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbjDUO3S (ORCPT ); Fri, 21 Apr 2023 10:29:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8927C2D68 for ; Fri, 21 Apr 2023 07:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682087309; 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=gh2FKDIw04E1Y2danPvwRc3umx0NY4oLoGalTyKkosA=; b=bDyTg0cm2eUs/tUKqL+haN1CEqvXh5XnPqYJRAZ9kFSpOp7TTRyMS8X2VwItDHoQOBhcEN zBddQzP+qHjwo/aee2hqJwfNm5/YhGkLIZQE/zwTJaJahZwLkrthRHObBJG1UJc4Wvgomp f8WQ/3QJl27ZxmV5jywqfKAoArgBu9s= Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-53-gToPFlIiNMmobDwMQ3Dsdw-1; Fri, 21 Apr 2023 10:28:26 -0400 X-MC-Unique: gToPFlIiNMmobDwMQ3Dsdw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF57838123CC; Fri, 21 Apr 2023 14:28:25 +0000 (UTC) Received: from [10.39.208.29] (unknown [10.39.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C80E2C08492; Fri, 21 Apr 2023 14:28:23 +0000 (UTC) Message-ID: <88a24206-b576-efc6-1bce-7f5075024c63@redhat.com> Date: Fri, 21 Apr 2023 16:28:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: Jason Wang , xieyongji@bytedance.com Cc: mst@redhat.com, david.marchand@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, Peter Xu References: <20230419134329.346825-1-maxime.coquelin@redhat.com> From: Maxime Coquelin Subject: Re: [RFC 0/2] vduse: add support for networking devices In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/21/23 07:51, Jason Wang wrote: > On Thu, Apr 20, 2023 at 10:16 PM Maxime Coquelin > wrote: >> >> >> >> On 4/20/23 06:34, Jason Wang wrote: >>> On Wed, Apr 19, 2023 at 9:43 PM Maxime Coquelin >>> wrote: >>>> >>>> This small series enables virtio-net device type in VDUSE. >>>> With it, basic operation have been tested, both with >>>> virtio-vdpa and vhost-vdpa using DPDK Vhost library series >>>> adding VDUSE support [0] using split rings layout. >>>> >>>> Control queue support (and so multiqueue) has also been >>>> tested, but require a Kernel series from Jason Wang >>>> relaxing control queue polling [1] to function reliably. >>>> >>>> Other than that, we have identified a few gaps: >>>> >>>> 1. Reconnection: >>>> a. VDUSE_VQ_GET_INFO ioctl() returns always 0 for avail >>>> index, even after the virtqueue has already been >>>> processed. Is that expected? I have tried instead to >>>> get the driver's avail index directly from the avail >>>> ring, but it does not seem reliable as I sometimes get >>>> "id %u is not a head!\n" warnings. Also such solution >>>> would not be possible with packed ring, as we need to >>>> know the wrap counters values. >>> >>> Looking at the codes, it only returns the value that is set via >>> set_vq_state(). I think it is expected to be called before the >>> datapath runs. >>> >>> So when bound to virtio-vdpa, it is expected to return 0. But we need >>> to fix the packed virtqueue case, I wonder if we need to call >>> set_vq_state() explicitly in virtio-vdpa before starting the device. >>> >>> When bound to vhost-vdpa, Qemu will call VHOST_SET_VRING_BASE which >>> will end up a call to set_vq_state(). Unfortunately, it doesn't >>> support packed ring which needs some extension. >>> >>>> >>>> b. Missing IOCTLs: it would be handy to have new IOCTLs to >>>> query Virtio device status, >>> >>> What's the use case of this ioctl? It looks to me userspace is >>> notified on each status change now: >>> >>> static int vduse_dev_set_status(struct vduse_dev *dev, u8 status) >>> { >>> struct vduse_dev_msg msg = { 0 }; >>> >>> msg.req.type = VDUSE_SET_STATUS; >>> msg.req.s.status = status; >>> >>> return vduse_dev_msg_sync(dev, &msg); >>> } >> >> The idea was to be able to query the status at reconnect time, and >> neither having to assume its value nor having to store its value in a >> file (the status could change while the VDUSE application is stopped, >> but maybe it would receive the notification at reconnect). > > I see. > >> >> I will prototype using a tmpfs file to save needed information, and see >> if it works. > > It might work but then the API is not self contained. Maybe it's > better to have a dedicated ioctl. > >> >>>> and retrieve the config >>>> space set at VDUSE_CREATE_DEV time. >>> >>> In order to be safe, VDUSE avoids writable config space. Otherwise >>> drivers could block on config writing forever. That's why we don't do >>> it now. >> >> The idea was not to make the config space writable, but just to be able >> to fetch what was filled at VDUSE_CREATE_DEV time. >> >> With the tmpfs file, we can avoid doing that and just save the config >> space there. > > Same as the case for status. I have cooked a DPDK patch to support reconnect with a tmpfs file as suggested by Yongji: https://gitlab.com/mcoquelin/dpdk-next-virtio/-/commit/53913f2b1155b02c44d5d3d298aafd357e7a8c48 That's still rough around the edges, but it seems to work reliably for the testing I have done so far. We'll certainly want to use the tmpfs memory to directly store available indexes and wrap counters to avoid introducing overhead in the datapath. The tricky part will be to manage NUMA affinity. Regards, Maxime > > Thanks > >> >>> We need to harden the config write before we can proceed to this I think. >>> >>>> >>>> 2. VDUSE application as non-root: >>>> We need to run the VDUSE application as non-root. There >>>> is some race between the time the UDEV rule is applied >>>> and the time the device starts being used. Discussing >>>> with Jason, he suggested we may have a VDUSE daemon run >>>> as root that would create the VDUSE device, manages its >>>> rights and then pass its file descriptor to the VDUSE >>>> app. However, with current IOCTLs, it means the VDUSE >>>> daemon would need to know several information that >>>> belongs to the VDUSE app implementing the device such >>>> as supported Virtio features, config space, etc... >>>> If we go that route, maybe we should have a control >>>> IOCTL to create the device which would just pass the >>>> device type. Then another device IOCTL to perform the >>>> initialization. Would that make sense? >>> >>> I think so. We can hear from others. >>> >>>> >>>> 3. Coredump: >>>> In order to be able to perform post-mortem analysis, DPDK >>>> Vhost library marks pages used for vrings and descriptors >>>> buffers as MADV_DODUMP using madvise(). However with >>>> VDUSE it fails with -EINVAL. My understanding is that we >>>> set VM_DONTEXPAND flag to the VMAs and madvise's >>>> MADV_DODUMP fails if it is present. I'm not sure to >>>> understand why madvise would prevent MADV_DODUMP if >>>> VM_DONTEXPAND is set. Any thoughts? >>> >>> Adding Peter who may know the answer. >> >> Thanks! >> Maxime >> >>> Thanks >>> >>>> >>>> [0]: https://patchwork.dpdk.org/project/dpdk/list/?series=27594&state=%2A&archive=both >>>> [1]: https://lore.kernel.org/lkml/CACGkMEtgrxN3PPwsDo4oOsnsSLJfEmBEZ0WvjGRr3whU+QasUg@mail.gmail.com/T/ >>>> >>>> Maxime Coquelin (2): >>>> vduse: validate block features only with block devices >>>> vduse: enable Virtio-net device type >>>> >>>> drivers/vdpa/vdpa_user/vduse_dev.c | 11 +++++++---- >>>> 1 file changed, 7 insertions(+), 4 deletions(-) >>>> >>>> -- >>>> 2.39.2 >>>> >>> >> >