Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp63488lqe; Wed, 3 Apr 2024 22:36:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVw6Fv8Vz8kBzwPxoXd17DHsvaEN75YJK2s4L6jalAWqcOz8w9rZ2PdjEzcNOJEFVcdoIObGuXgbeaZpLknucQxkcRbF4fJr7kfuauHmQ== X-Google-Smtp-Source: AGHT+IFkRhPbhtIZRDrx0bVCEnjGUUQ4Sg1KuQwI4tAlL2aj87xpH7UdXHfwnz6x+yw6QUZ8KbhE X-Received: by 2002:a05:620a:4951:b0:789:e8cd:3a49 with SMTP id vz17-20020a05620a495100b00789e8cd3a49mr1298059qkn.75.1712208963894; Wed, 03 Apr 2024 22:36:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712208963; cv=pass; d=google.com; s=arc-20160816; b=bJi/7BnrbviVZRUo8EBvdeohqju3+Y0w3iC0o1gvZsQ5k3boKY4C7Kc/5DFP0kpaVT LfAn6UGlG+UiudCwjq7OgmyBESwwbwupUWWdBVSv3PN0q6nsg7En1r3wUDo8VAu0HIvp PRSzlJaWC1DCO23WhTEsmbKhzeK2msxgcz56fAUiAeCg7MxQTQuJg1U6vs/4PVfHozZg Te/cQfHfB7uuhYY9a7sUkNhJYSkntJgUcUXc3O4g77AT5LJDaV1tJC75kbzQUuW+i49Q sDFtZ9YJzsMzKzin3ahWFc/sLbtyKSf+xTSr1/mfzSRyTdTFvbgUYs+zXlT/wzJ0S3qf wuyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=gaCNfh5JQ71P8XHmMhbBbFyQnfQUNQ6Qvksh5dYu/Jg=; fh=cmwtl8b1m6HgnCxHPpgDy85/uiWXWGt9eaesQjoWjNg=; b=yWoqkrukYUSabg7MlpLmmddU9u/9Pa2mymn38+8Nhuwo5zspEc7V9ZurBmszE4kuPe hd5SKlFpW0iFPHsdJNCMxMun7mMghPn29QYPUxfxdE9woTu2ONiLJpkoPn1iY0F8uOVM NFDN8smpx7IZDPKbz619dIpixpJnRnisiaXwo7fyc0md8hSjbqhCQNIXLL0s1LOnDe+5 FGFA+uNfZKBqqRyD+Z8uPkzwwn1e0AnxiHQwlQ3RCskIJI33IZisgw9IVP17ulKdJc9X LlNo+7RJ6fKFQ7+XftpKeUq31eMEJmfsBQDDF0IY0kDY1vSTtUtu2UT4l9G7P3PkcPSt gPow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PCUEluys; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-130952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z4-20020ae9e604000000b0078beb640896si6233481qkf.256.2024.04.03.22.36.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 22:36:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PCUEluys; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-130952-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9B5041C2361E for ; Thu, 4 Apr 2024 05:36:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5FF145C18; Thu, 4 Apr 2024 05:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PCUEluys" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5AE01B810 for ; Thu, 4 Apr 2024 05:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712208948; cv=none; b=rgZQuesVTAVqPL7F3QwpyQXCk+H+wArA3cFXsYP4PsYWFjQEsxDd3YrEkHERSsvSpXPXH+kSoYBUuztcpkVHzsohx0DgRWZ17W4R+Hr399f59iLutSF5+01f8FfLOzIN1HFAd5Dysb1f6VdIIXxwcWpbuochMdkuOxXvLaNK6kU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712208948; c=relaxed/simple; bh=Ym38qLEOUNfy/4hL6ENnTMzg8xPqYlCnX/Fr3RLE/U8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BwEetIPl+IHOfX8IVPisfJ/Nh5YKReGrdCI54+wpKyPkmX3A4eSw7p4EyZ5XyPDh4BdsN/3qladi4EpetoVKC6ZFL8NaPkDFZP+gNpuhByCPOrYOBRCr2+4v/Yc6rZ9FO/pm51vCOup/vFK40Z22OZvcAgqD/aMtXkyBWFtgpKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PCUEluys; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712208945; 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=gaCNfh5JQ71P8XHmMhbBbFyQnfQUNQ6Qvksh5dYu/Jg=; b=PCUEluys+PKa7j0+pXlF6DoGW6oPFqo3PAOuikK8RdV1cNCE2gKbhPUsRANUaJGJfPKExS DtRJ2aa9gBwSLEXGtf37fsQMipCqi3FSjzXS9jXaCEu6s6ZudDRE+DOoidlbyrufrPK6vr RHURDSH/VnHJ8SOKABgr8JmvIKGFPrs= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-m5BdewYtMHmBz89sfdCo_g-1; Thu, 04 Apr 2024 01:35:44 -0400 X-MC-Unique: m5BdewYtMHmBz89sfdCo_g-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a450265c7b6so27421266b.0 for ; Wed, 03 Apr 2024 22:35:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712208943; x=1712813743; 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=gaCNfh5JQ71P8XHmMhbBbFyQnfQUNQ6Qvksh5dYu/Jg=; b=MqQjAPJB7baOSNOdGmefxKNJk1Hfg4SMBxJ6ONttdGS/LwST30iBBhhf5bJwtsI1fq xWJ7/EaiZmfl3el1gV6xkngarC+4H4LPud7gvLjcW1ltxzTlpXGtoPAaM8ptx6XpP7u4 P5Elg4cUdVxdz4LmjOBbvXUeIKi4nzftJ9S+cM0zftaSGY2EJ9G6roW9AeFEEpqYiyut yCrLa1GkF9j3WJVFzg2vCu+n0iJvkt0DKvDsVHah+6JaC+Sy1v/Qwlmv+cBL2004wqnr alc3cPQusmcl86gHlGSicg7o9UszgLa3XvvN5DS/+w5ifaJwNWX6OoPh2mXEK0J8hoiS RrXg== X-Forwarded-Encrypted: i=1; AJvYcCV7Iuly9PTuTKU0v989evbUSbMDFQg9TZJwH49BDysUaN0lCZX31ZKUDAqEdKi8VsXjcfWqZNrwn6tYTprEcu977w1AW0D/yvN42RfB X-Gm-Message-State: AOJu0YwMazmLupuKlR99Ec47y/OTrjSvK3Q8z/GTNIeCyDAU4tqq5Csz SPtYVt/v5ucyxtt871ojS6/qO/o9qDlB0BDktUz2/VA4yy2dYvwjUikYr7HKhtDmoagHpEScdvX S1CbskClKif7MB6t6hc7KIl6+oNLnfK0ehaAYdVftApNcIWhi5annWtF4cafy8nBS1iKueeZ4iz AAkfvciGUQHk24VccnvASABYoa34qtMQlRMS3r X-Received: by 2002:a17:906:3e50:b0:a4e:9591:c2dd with SMTP id t16-20020a1709063e5000b00a4e9591c2ddmr725278eji.39.1712208942843; Wed, 03 Apr 2024 22:35:42 -0700 (PDT) X-Received: by 2002:a17:906:3e50:b0:a4e:9591:c2dd with SMTP id t16-20020a1709063e5000b00a4e9591c2ddmr725266eji.39.1712208942439; Wed, 03 Apr 2024 22:35:42 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240329093832.140690-1-lulu@redhat.com> <20240329054845-mutt-send-email-mst@kernel.org> In-Reply-To: <20240329054845-mutt-send-email-mst@kernel.org> From: Cindy Lu Date: Thu, 4 Apr 2024 13:35:02 +0800 Message-ID: Subject: Re: [PATCH v2] Documentation: Add reconnect process for VDUSE To: "Michael S. Tsirkin" Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 29, 2024 at 5:52=E2=80=AFPM Michael S. Tsirkin = wrote: > > On Fri, Mar 29, 2024 at 05:38:25PM +0800, Cindy Lu wrote: > > Add a document explaining the reconnect process, including what the > > Userspace App needs to do and how it works with the kernel. > > > > Signed-off-by: Cindy Lu > > --- > > Documentation/userspace-api/vduse.rst | 41 +++++++++++++++++++++++++++ > > 1 file changed, 41 insertions(+) > > > > diff --git a/Documentation/userspace-api/vduse.rst b/Documentation/user= space-api/vduse.rst > > index bdb880e01132..f903aed714d1 100644 > > --- a/Documentation/userspace-api/vduse.rst > > +++ b/Documentation/userspace-api/vduse.rst > > @@ -231,3 +231,44 @@ able to start the dataplane processing as follows: > > after the used ring is filled. > > > > For more details on the uAPI, please see include/uapi/linux/vduse.h. > > + > > +HOW VDUSE devices reconnectoin works > > typo > Really sorry for this, I will send a new version Thanks Cindy > > +------------------------------------ > > +1. What is reconnection? > > + > > + When the userspace application loads, it should establish a connect= ion > > + to the vduse kernel device. Sometimes,the userspace application exi= sts, > > + and we want to support its restart and connect to the kernel device= again > > + > > +2. How can I support reconnection in a userspace application? > > + > > +2.1 During initialization, the userspace application should first veri= fy the > > + existence of the device "/dev/vduse/vduse_name". > > + If it doesn't exist, it means this is the first-time for connectio= n. goto step 2.2 > > + If it exists, it means this is a reconnection, and we should goto = step 2.3 > > + > > +2.2 Create a new VDUSE instance with ioctl(VDUSE_CREATE_DEV) on > > + /dev/vduse/control. > > + When ioctl(VDUSE_CREATE_DEV) is called, kernel allocates memory fo= r > > + the reconnect information. The total memory size is PAGE_SIZE*vq_m= umber. > > + > > +2.3 Check if the information is suitable for reconnect > > + If this is reconnection : > > + Before attempting to reconnect, The userspace application needs to= use the > > + ioctl(VDUSE_DEV_GET_CONFIG, VDUSE_DEV_GET_STATUS, VDUSE_DEV_GET_FE= ATURES...) > > + to get the information from kernel. > > + Please review the information and confirm if it is suitable to rec= onnect. > > + > > +2.4 Userspace application needs to mmap the memory to userspace > > + The userspace application requires mapping one page for every vq. = These pages > > + should be used to save vq-related information during system runnin= g. Additionally, > > + the application must define its own structure to store information= for reconnection. > > + > > +2.5 Completed the initialization and running the application. > > + While the application is running, it is important to store relevan= t information > > + about reconnections in mapped pages. When calling the ioctl VDUSE_= VQ_GET_INFO to > > + get vq information, it's necessary to check whether it's a reconne= ction. If it is > > + a reconnection, the vq-related information must be get from the ma= pped pages. > > + > > > I don't get it. So this is just a way for the application to allocate > memory? Why do we need this new way to do it? > Why not just mmap a file anywhere at all? > We used to use tmpfs to save this reconnect information, but this will make the API not self contained, so we changed to using the kernel memory Thanks cindy > > > +2.6 When the Userspace application exits, it is necessary to unmap all= the > > + pages for reconnection > > -- > > 2.43.0 >