Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp999615rdh; Sun, 24 Sep 2023 23:11:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE94m27M3983ZAtbxbxkMM7NA+sGTOCBrHWkekTM+unElk9U3U1QICIyaHFYyOADyiBSEKW X-Received: by 2002:a17:903:120a:b0:1c1:f27e:a55a with SMTP id l10-20020a170903120a00b001c1f27ea55amr4521878plh.46.1695622285336; Sun, 24 Sep 2023 23:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695622285; cv=none; d=google.com; s=arc-20160816; b=v+5bMufKrfdEg6SjSeRrX5dejLka5ozU7WvJla7hl7o6vA+J6ufmMbI4ApeLFO+7Qk aDG+8eiKg5IuVgpjCxPjVu0LTuaDmD+QrutSERgyW8elfd+df6RtXQS3e7TOBZEii6KA Y9ONeve7UeXpQU5wz5BHHeFj26yCZQGq0CHA0JDlAEx0a729h93u405obUQWGp3P6jZm 9475q+rqG77BLzd7+zh6wGDKuDdKRNBTe24uQw9fE4LZw17G+cyfecQUmr/iR4sF4em2 dup9iZKRlU3BYi3LjMY/UJS/t4zIuEx77xe+4QNbO8HXNKxDIVkjwJRiGbZN7PWyZlZl L5RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=03qSg2yEAIVwRPqjjQs4G4M60zsU0m+0zE8R/M2ccL4=; fh=KYIgaKzY60pU9WqmLGkDlcDWEU+gMoww+4hF4y9j8Zo=; b=v4+lLkdYO2zWD1NvW9Il7ZOm+MUQQiRzgAjTLV22Wtp6j2i7NhGuCVcTHz1sCd07BD rqjydXWscKaWJTwdUHXhr7tyeIRWtfhX8ISD077jJ+woC3hxJJdEYDkTQYdYcaaTEcOf W0IHi9rr7XvGizBRZ73l0cI3vJCf15cSG6HuLsxvhURU/c1bZdfbRyIhuaHxldG+XVzR SybIbDN6Rj9j8EZTtbch9A/+RNwNNj7E7H6VZ2bHhCLkKGmGKk65iXD0MTte47qGCZwo 1+GmcLJDg73CmgxP5ikolTRUFeLsQhqFpx0D6IiiJAG9tv86OyM0O+a8fi6akrlZN2/v Ak+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gx7p+WNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t11-20020a170902d28b00b001c60502ccd4si3808383plc.642.2023.09.24.23.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 23:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gx7p+WNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 6D92C80755C6; Sun, 24 Sep 2023 19:58:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbjIYC6z (ORCPT + 99 others); Sun, 24 Sep 2023 22:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbjIYC6y (ORCPT ); Sun, 24 Sep 2023 22:58:54 -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 775E6A4 for ; Sun, 24 Sep 2023 19:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695610681; 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=03qSg2yEAIVwRPqjjQs4G4M60zsU0m+0zE8R/M2ccL4=; b=Gx7p+WNaMcz41qn7JSOpljDkAZ+m4EuctKM8tD7FgNW2+zGr5N6AZQhGGJ0Qd9i7wLf/Ja EDdTrRU19+BIvyt/bQ+iseTcH0qGhY9lDo31XnNdM95O75qLAWC+RYPkJEnecBhHmmkWOK JYfR8ElawbhwEAXoXoniewbgcVYuVx4= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-499-K_mMcmUEPZ-EcolO575I2A-1; Sun, 24 Sep 2023 22:57:59 -0400 X-MC-Unique: K_mMcmUEPZ-EcolO575I2A-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-5030ed95acdso7544181e87.2 for ; Sun, 24 Sep 2023 19:57:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695610678; x=1696215478; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=03qSg2yEAIVwRPqjjQs4G4M60zsU0m+0zE8R/M2ccL4=; b=F9PPZglkqe4VQu403QJ6Ey9TTn4/D572ATerzfW6P00l/v8hmGSG3HLnJRAZgiDE+B QT3rVJ4/Hv68qiwtM/u2115nCt7zJh005rmSDrr7B7OwSeTvbUgskFmE8RBY5PoKVar3 baQMR+7UghBELsIWMMNZQgMalt/3S17OOV3bTRdxhhuyTgNzs/jz0/gl6RqTxl/KevJa hndStC3gwc7zRInC8OUeibEfzlTOk+UHRcP073xbh2XU8hTeh7ZVrgTptp5aCF6nO5Eo JL6aEU1EJuD7+aipwj5J5zEMNTkKBNAq4XMHw4V3Mb9PjBXAFRMY6PrvF2n7Hr+XmT2u eebg== X-Gm-Message-State: AOJu0Yx4nEO1PQXlxy00SWe97SqNguFg2hIcMiz5X0MV7jszALgqIGoK 6WXBrFVN0S1PiQ9RuFfpyGntP96W8lk79D0s/fyVRnyWynd9XqEQ9EU1DZekIpIqjSzL7ycrQXq yuHw5RWAo061XwBeEFq2Z8wfqsae8lR1Ny1Z0FQXk X-Received: by 2002:a05:6512:12c5:b0:4fb:8948:2b28 with SMTP id p5-20020a05651212c500b004fb89482b28mr5070670lfg.63.1695610678409; Sun, 24 Sep 2023 19:57:58 -0700 (PDT) X-Received: by 2002:a05:6512:12c5:b0:4fb:8948:2b28 with SMTP id p5-20020a05651212c500b004fb89482b28mr5070657lfg.63.1695610678004; Sun, 24 Sep 2023 19:57:58 -0700 (PDT) MIME-Version: 1.0 References: <20230912030008.3599514-1-lulu@redhat.com> <20230912030008.3599514-5-lulu@redhat.com> In-Reply-To: From: Jason Wang Date: Mon, 25 Sep 2023 10:57:47 +0800 Message-ID: Subject: Re: [RFC v2 4/4] vduse: Add new ioctl VDUSE_GET_RECONNECT_INFO To: Cindy Lu Cc: mst@redhat.com, maxime.coquelin@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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 (snail.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:58:54 -0700 (PDT) On Thu, Sep 21, 2023 at 10:07=E2=80=AFPM Cindy Lu wrote: > > On Mon, Sep 18, 2023 at 4:49=E2=80=AFPM Jason Wang = wrote: > > > > On Tue, Sep 12, 2023 at 11:01=E2=80=AFAM Cindy Lu wro= te: > > > > > > In VDUSE_GET_RECONNECT_INFO, the Userspace App can get the map size > > > and The number of mapping memory pages from the kernel. The userspace > > > App can use this information to map the pages. > > > > > > Signed-off-by: Cindy Lu > > > --- > > > drivers/vdpa/vdpa_user/vduse_dev.c | 15 +++++++++++++++ > > > include/uapi/linux/vduse.h | 15 +++++++++++++++ > > > 2 files changed, 30 insertions(+) > > > > > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_u= ser/vduse_dev.c > > > index 680b23dbdde2..c99f99892b5c 100644 > > > --- a/drivers/vdpa/vdpa_user/vduse_dev.c > > > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > > > @@ -1368,6 +1368,21 @@ static long vduse_dev_ioctl(struct file *file,= unsigned int cmd, > > > ret =3D 0; > > > break; > > > } > > > + case VDUSE_GET_RECONNECT_INFO: { > > > + struct vduse_reconnect_mmap_info info; > > > + > > > + ret =3D -EFAULT; > > > + if (copy_from_user(&info, argp, sizeof(info))) > > > + break; > > > + > > > + info.size =3D PAGE_SIZE; > > > + info.max_index =3D dev->vq_num + 1; > > > + > > > + if (copy_to_user(argp, &info, sizeof(info))) > > > + break; > > > + ret =3D 0; > > > + break; > > > + } > > > default: > > > ret =3D -ENOIOCTLCMD; > > > break; > > > diff --git a/include/uapi/linux/vduse.h b/include/uapi/linux/vduse.h > > > index d585425803fd..ce55e34f63d7 100644 > > > --- a/include/uapi/linux/vduse.h > > > +++ b/include/uapi/linux/vduse.h > > > @@ -356,4 +356,19 @@ struct vhost_reconnect_vring { > > > _Bool avail_wrap_counter; > > > }; > > > > > > +/** > > > + * struct vduse_reconnect_mmap_info > > > + * @size: mapping memory size, always page_size here > > > + * @max_index: the number of pages allocated in kernel,just > > > + * use for check > > > + */ > > > + > > > +struct vduse_reconnect_mmap_info { > > > + __u32 size; > > > + __u32 max_index; > > > +}; > > > > One thing I didn't understand is that, aren't the things we used to > > store connection info belong to uAPI? If not, how can we make sure the > > connections work across different vendors/implementations. If yes, > > where? > > > > Thanks > > > The process for this reconnecttion is > A.The first-time connection > 1> The userland app checks if the device exists > 2> use the ioctl to create the vduse device > 3> Mapping the kernel page to userland and save the > App-version/features/other information to this page > 4> if the Userland app needs to exit, then the Userland app will only > unmap the page and then exit > > B, the re-connection > 1> the userland app finds the device is existing > 2> Mapping the kernel page to userland > 3> check if the information in shared memory is satisfied to > reconnect,if ok then continue to reconnect > 4> continue working > > For now these information are all from userland,So here the page will > be maintained by the userland App > in the previous code we only saved the api-version by uAPI . if we > need to support reconnection maybe we need to add 2 new uAPI for this, > one of the uAPI is to save the reconnect information and another is > to get the information > > maybe something like > > struct vhost_reconnect_data { > uint32_t version; > uint64_t features; > uint8_t status; > struct virtio_net_config config; > uint32_t nr_vrings; > }; Probably, then we can make sure the re-connection works across different vduse-daemon implementations. > > #define VDUSE_GET_RECONNECT_INFO _IOR (VDUSE_BASE, 0x1c, struct > vhost_reconnect_data) > > #define VDUSE_SET_RECONNECT_INFO _IOWR(VDUSE_BASE, 0x1d, struct > vhost_reconnect_data) Not sure I get this, but the idea is to map those pages to user space, any reason we need this uAPI? Thanks > > Thanks > Cindy > > > > > > > + > > > +#define VDUSE_GET_RECONNECT_INFO \ > > > + _IOWR(VDUSE_BASE, 0x1b, struct vduse_reconnect_mmap_info) > > > + > > > #endif /* _UAPI_VDUSE_H_ */ > > > -- > > > 2.34.3 > > > > > >