Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3965614rdh; Fri, 29 Sep 2023 07:32:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJFFuzRb7/uvHgJCcNKXNoAUrT8tbu0Nb3OEcz82f/QeCbJYNRYSocELpdp0Jqgq5Qs5kK X-Received: by 2002:aca:1b0b:0:b0:3a7:4987:d44 with SMTP id b11-20020aca1b0b000000b003a749870d44mr3801004oib.20.1695997935410; Fri, 29 Sep 2023 07:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695997935; cv=none; d=google.com; s=arc-20160816; b=HFBTySHp8x6FaN9C3mCz55mHTAn0kFOikafZAi8DTSbDdfdKeeKHwKQpIS01AxfkM9 EIn/RCMk2/zGVqzWUxPKGgy6cLi2u3rQyKAsOX4YKlqlZc/J3ymzurg0vzzFTk6YmMB8 Xg1/AabcuviWJiAld4uFh6py80DQY//2FO0dZWGsoi6ZRL6oAdzDfjEdb1T85Dr3Ncdn Q6RJ3bWsU3V8UqWc9TMRm8zHLnbbt6fJy/eLSW/sqLlb5qPh/tkm/fEMdQzFVk9S2oIK vYXUbQY6fgOEUQ2hqJcAedaGCWAOCZvbY3CXtvfnNEQ/VFlddKFdF11ZIcECO3FjvINy HNbQ== 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=mWGhTxhB3dGkyUJd+ZvB0A+li+V3clasR5rFEOBuS5Q=; fh=2BQLJbZvrdZJavqsBix7cAjWWiT2lDiXZNnB1Hc4RLU=; b=HuPdU2vGztia7q4hDr73E5QxgOOZyUt0teUIFkEzXajaQw7jSeOX9K3I3k3E5I0thm lt1v9Ib44LhGo6D4iSQEVclJpeAay64U+NUt+JX9RS1ZOk4yrZ1dB0vggIGxCd4bjdn9 4gBo3Q3L8Gr73eOzFYagyun+50XhpKJmD3wuv9aL69NP6onH3swynqsg+HcmIuhbFCjs dhJ9v0lXHZEtO8SLL0C7+WbwvhJ9Impkpte8ku/IQlIF+cI87ZZlayNk0WoDu+6nNscc lPFpuUFxmSC+RnYBh3ARFhModFKQMkK1nfvXQD0JDaSgYJzEpYuOet5Y5QmfWVkfPOU1 GjLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rj+am9QH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id v3-20020a655c43000000b00565e386ff44si21674706pgr.702.2023.09.29.07.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rj+am9QH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 42B4F802580F; Fri, 29 Sep 2023 02:13:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232919AbjI2JNX (ORCPT + 99 others); Fri, 29 Sep 2023 05:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232938AbjI2JNT (ORCPT ); Fri, 29 Sep 2023 05:13:19 -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 424E611F for ; Fri, 29 Sep 2023 02:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695978752; 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=mWGhTxhB3dGkyUJd+ZvB0A+li+V3clasR5rFEOBuS5Q=; b=Rj+am9QH0kTDDPsRpN3ibi3/BNWf476Du1ovdHQeSMq5oGPpGhRlMX0/1HE36bgl+793L/ uA8VreBUxn3kksoO7Is28SVvdyVlPgy3DPzlUjx7IyS9lo5RNm7PuYGpk0J+GiHaNs0HcH Y2yZpBjkx0mNliLGhkWtMnOyI1bpqo8= 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-464-zINCMx0OMu-lnzv0G8nixg-1; Fri, 29 Sep 2023 05:12:29 -0400 X-MC-Unique: zINCMx0OMu-lnzv0G8nixg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 BDC473C1ACEE; Fri, 29 Sep 2023 09:12:28 +0000 (UTC) Received: from [10.39.208.41] (unknown [10.39.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E46AD14171B6; Fri, 29 Sep 2023 09:12:26 +0000 (UTC) Message-ID: Date: Fri, 29 Sep 2023 11:12:25 +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: Jason Wang , Cindy Lu 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.7 X-Spam-Status: No, score=-2.1 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_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 02:13:34 -0700 (PDT) On 9/12/23 09:39, 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. > > And I never saw _Bool is used in uapi before, maybe it's better to > pack it with last_avail_idx into a __u32. Better as two distincts __u16 IMHO. Thanks, Maxime > > Btw, do we need to track inflight descriptors as well? > > Thanks > >> +}; >> + >> #endif /* _UAPI_VDUSE_H_ */ >> -- >> 2.34.3 >> >