Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3855225rdh; Fri, 29 Sep 2023 04:38:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZe3e2hmYuWzWHYRhhYu83daQcOFq4IOJfYtCgVIKpqHEIKnFudoii4wYcTBJWHsiweL1H X-Received: by 2002:aca:2b17:0:b0:3a1:e85f:33ee with SMTP id i23-20020aca2b17000000b003a1e85f33eemr3738404oik.56.1695987530602; Fri, 29 Sep 2023 04:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695987530; cv=none; d=google.com; s=arc-20160816; b=WVXPCPzfATG1FNcVRJ7ATWCTjCp2PoEkmp/OXTjTOaAkF+eVqyxdYm3wQOnIAQ+ZWr IYg0vyYZUQgAR/vdKFuOUvoMfGPIJNTYIQpADhpQp5wLWwdSelJvPfC2l8oeyORdpcWF WeX/dp+X6RxmZ1TfozCbgDAstg+hi7yJpTNTNNK0HVK6/OCGOYCY1q73Kf4vPKgJg7xD /ydSQktPdxCIt3o5pKRXoOiQuIJX9MmsPmWhDaT/ZqNR0e9d+Hy3iKSwUi/LHSfTWHrL 8jd5/0IIwKfaB4IO/SLxHPjRItGCe3UinQIdK6gIQO5OdlQoojkPYFpcLiegoHRzoH3x eahg== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=a/1qYpfgB/Cr65fTbE/peTu216y26U+TzDcRaWm5JW8=; fh=Ef6MfHk2YJRGjuOaC5gMTehHYs4XafdvAEpka+S01dc=; b=rzqVbBs4PZYfAXsCCyTllqi0MEKD0XmyCYutDUnvSUqABTEqLUT5V9c2azPjTs0b1g fUcetDnLCKEELlYFFKR3Lal3EWwcDtXhbtZ813c/J49LPEnHl1nvDGScbK14h1p4it1v u0pN0sSt4R5HEBrtJ1h0bHh0E37ykaufoGVlkkaXlw1gophY+tSIcDodvlp7QQHnpKwY 0m9nLpEkJx0G6mwweEnS8AaHJ3oFTj7L7w/1eLAWyw1y21fXnNNyk3KZdTyyKddKgedn h+Fe+xYZ2/VHTJroFyfyr8UL9EpeL5PtvvQyM/ukle0e2tQWmoq8SSsQlf6u2mwzTqh/ FYMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OC8phQA2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id s25-20020a639259000000b005859a8ae4d3si2064706pgn.483.2023.09.29.04.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 04:38:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OC8phQA2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3FB5A8347B4D; Fri, 29 Sep 2023 02:09:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232895AbjI2JI6 (ORCPT + 99 others); Fri, 29 Sep 2023 05:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbjI2JI4 (ORCPT ); Fri, 29 Sep 2023 05:08:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C8C9180 for ; Fri, 29 Sep 2023 02:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695978489; 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=a/1qYpfgB/Cr65fTbE/peTu216y26U+TzDcRaWm5JW8=; b=OC8phQA278gGlJ/++EX1QG2EUYsoIfova8kRfJ4/uM0A9D6XNBLx8Dvo/JxR1o7EKMOC7y UM1FkdMuZw7EU6vyjYlNi7oBOMD4m8AEzZkJ8BXQLwGVw42imIVRsfkklnS0isO/vNpGSU 3V4GY4IHYn8Uv8V+w1JO0V7vE/YMJr4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-f7TvbMDWMxSPff7skgH1QQ-1; Fri, 29 Sep 2023 05:08:06 -0400 X-MC-Unique: f7TvbMDWMxSPff7skgH1QQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 69881101A53B; Fri, 29 Sep 2023 09:08:05 +0000 (UTC) Received: from [10.39.208.41] (unknown [10.39.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B84340C6EBF; Fri, 29 Sep 2023 09:08:03 +0000 (UTC) Message-ID: <0af14066-6cc9-bfc6-2a4c-0503f9dd4a5c@redhat.com> Date: Fri, 29 Sep 2023 11:08:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC v2 3/4] vduse: update the vq_info in ioctl Content-Language: en-US To: Cindy Lu , Jason Wang Cc: mst@redhat.com, xieyongji@bytedance.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, stable@vger.kernel.org References: <20230912030008.3599514-1-lulu@redhat.com> <20230912030008.3599514-4-lulu@redhat.com> From: Maxime Coquelin 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.2 X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 02:09:12 -0700 (PDT) On 9/25/23 06:15, Cindy Lu wrote: > On Tue, Sep 12, 2023 at 3:39 PM Jason Wang wrote: >> >> On Tue, Sep 12, 2023 at 11:00 AM Cindy Lu wrote: >>> >>> In VDUSE_VQ_GET_INFO, the driver will sync the last_avail_idx >>> with reconnect info, After mapping the reconnect pages to userspace >>> The userspace App will update the reconnect_time in >>> struct vhost_reconnect_vring, If this is not 0 then it means this >>> vq is reconnected and will update the last_avail_idx >>> >>> Signed-off-by: Cindy Lu >>> --- >>> drivers/vdpa/vdpa_user/vduse_dev.c | 13 +++++++++++++ >>> include/uapi/linux/vduse.h | 6 ++++++ >>> 2 files changed, 19 insertions(+) >>> >>> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c >>> index 2c69f4004a6e..680b23dbdde2 100644 >>> --- a/drivers/vdpa/vdpa_user/vduse_dev.c >>> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c >>> @@ -1221,6 +1221,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, >>> struct vduse_vq_info vq_info; >>> struct vduse_virtqueue *vq; >>> u32 index; >>> + struct vdpa_reconnect_info *area; >>> + struct vhost_reconnect_vring *vq_reconnect; >>> >>> ret = -EFAULT; >>> if (copy_from_user(&vq_info, argp, sizeof(vq_info))) >>> @@ -1252,6 +1254,17 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd, >>> >>> vq_info.ready = vq->ready; >>> >>> + area = &vq->reconnect_info; >>> + >>> + vq_reconnect = (struct vhost_reconnect_vring *)area->vaddr; >>> + /*check if the vq is reconnect, if yes then update the last_avail_idx*/ >>> + if ((vq_reconnect->last_avail_idx != >>> + vq_info.split.avail_index) && >>> + (vq_reconnect->reconnect_time != 0)) { >>> + vq_info.split.avail_index = >>> + vq_reconnect->last_avail_idx; >>> + } >>> + >>> ret = -EFAULT; >>> if (copy_to_user(argp, &vq_info, sizeof(vq_info))) >>> break; >>> diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h >>> index 11bd48c72c6c..d585425803fd 100644 >>> --- a/include/uapi/linux/vduse.h >>> +++ b/include/uapi/linux/vduse.h >>> @@ -350,4 +350,10 @@ struct vduse_dev_response { >>> }; >>> }; >>> >>> +struct vhost_reconnect_vring { >>> + __u16 reconnect_time; >>> + __u16 last_avail_idx; >>> + _Bool avail_wrap_counter; >> >> Please add a comment for each field. >> > Sure will do > >> And I never saw _Bool is used in uapi before, maybe it's better to >> pack it with last_avail_idx into a __u32. >> > Thanks will fix this >> Btw, do we need to track inflight descriptors as well? >> > I will check this For existing networking implemenation, this is not necessary. But it should be for block devices. Maxime > Thanks > > cindy >> Thanks >> >>> +}; >>> + >>> #endif /* _UAPI_VDUSE_H_ */ >>> -- >>> 2.34.3 >>> >> >