Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2357701rdb; Thu, 21 Sep 2023 16:55:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOUQpsuMkUWbXFQVIurdSOFRlUfvcAaSYT4RRH2PGCYJiOCLR0uUzhaGIYAu+eobIEgPz1 X-Received: by 2002:a05:6a00:2d9d:b0:68f:dcc1:4bef with SMTP id fb29-20020a056a002d9d00b0068fdcc14befmr8486620pfb.7.1695340558801; Thu, 21 Sep 2023 16:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695340558; cv=none; d=google.com; s=arc-20160816; b=pzyr8AWDPamf5EjvFXz10VqAdnRfPd4+BSEEbOkiBs/ppa2AxsK/+PIioSvkvrkwty 4RUcXsla4ZiNDs/SsuUyGZ3r3SfU2/ytd9fOy3YS/uCNH9HBHSWFxsr9sQXmwi0cTAiB A8o75eNSTMYb5h/UbJcAZSLIKa9IfNalNvFnhD81Mah96YmlMllHvYXDubC/nReMIRuS +zJ1SvYsyU9WEy0tOwmRJopjpeXqPd/8DmSziOxLPWkrPSiYlgolgcj3MWpFmFW0B2wF t0cBOTm8U0OuzaZdul/DVJ8DNiNdLlWSPbPyCJF7Pf+s2DghMF7EmTzZ0evv99o86oZL 0H9g== 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=SqoOPgme4Uuv5hKrBPiJj6+uKIVnMHAtPkgpqGU6vG4=; fh=9z4dZr983w21Pd0RQN3Hf7v6e+s/vu+D8meFPGx2CyU=; b=bicsN+/eB1NpW5vmKntORAgu20qh3m+aaDyGyctQ0Af9ee+o0bijrdvoRK4G8qQ8u0 AaRH5i+N45/LFjEH28mkS0ZAUZZhzZ+eAyR8j2RonqE/7wT6GBiQ7i+UntDJkqhevNm8 Te0vKvRz7x0EAhb1FG1HcM5lS/Dssjv//zUmc5aUgowSrVxLm7anMYefSb9RcPS1C7e/ sLlAHgGg4tt9uNuu9D59xnDPY4lxmrHxqxCLdJrZ85+gjT2VHja/yjIBxjVyZvuwVjNH qDcCpsfdaT28YsQa2KrKEaplTwJpW8xiiZea8iPJDHUYyVPg/eeszpB49E+kv0nOLjWT nU2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TWSl9O1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bw8-20020a056a00408800b0068fb95e5401si2430798pfb.65.2023.09.21.16.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 16:55:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TWSl9O1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 11252836B5EB; Thu, 21 Sep 2023 13:18:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbjIUUSr (ORCPT + 99 others); Thu, 21 Sep 2023 16:18:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbjIUUST (ORCPT ); Thu, 21 Sep 2023 16:18:19 -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 85FCD448C for ; Thu, 21 Sep 2023 10:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695316944; 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=SqoOPgme4Uuv5hKrBPiJj6+uKIVnMHAtPkgpqGU6vG4=; b=TWSl9O1w12Vb7S1rK8jOQ2jInvDieEPYn6pKYNPhtnAjjJWk+qv/l0/C8DuFONBAD6C3G+ ESWMVUXoHaikX0GET0GHeoz9I8lMWIliQMXsomQ3ar0Xg5VHn/yFFqdYw3vfM8wx0phtkf qrmINJbr79d1gq02jPCDqVlFyBexVWg= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-7zhZSFnVOCC5QKAshlgMWQ-1; Thu, 21 Sep 2023 10:07:01 -0400 X-MC-Unique: 7zhZSFnVOCC5QKAshlgMWQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-31fd48da316so676890f8f.3 for ; Thu, 21 Sep 2023 07:07:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695305219; x=1695910019; 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=SqoOPgme4Uuv5hKrBPiJj6+uKIVnMHAtPkgpqGU6vG4=; b=GJyUHc1dmUvZ92jL7JT0/GeDh5XU3SMgW5W4CZS7/9EY6YHSiY9D5jrFPMiPM4bn3n u9uICpmT3ZdLM1rGDnSopCqc76KbCuiToDOIt32/+fgEcDKsJnQqQ2JmZNwJUBioLg7g Vpgyo12qW2lmXJPHkzsgJ066nDmlWgtzAPz1t9Z0A+6VBLToZPRvPdukf7Do5N/SrtxC 7w9IszXzPTXDCAkuStv1GQxYQyskZ1uni63Vc+YrKSBrmC5ATxIMkEpbLsQ06WQCNbMQ e7sfh1InXVcVCkTm1d54Ejyn+tF7DbbTIASVcNCtpNnxPB1biL/Ja4mMQCSTLEEydomZ DqMg== X-Gm-Message-State: AOJu0Yz650Vg/k2UxpMQgQoAyH07ISezeJhsem1VA6E2gsTnp8eTheOU v8VNh6hvXkFvaXIux9gupqotFtSY+vEy/RGWYru6novsEmErkFjxmHcmOu2W+bfTie4OAavvf9T eae1XRCh+cbMWscB2oj7wgdNuMGxRVLXG4VZtGpS7 X-Received: by 2002:adf:e604:0:b0:319:7c7d:8d1 with SMTP id p4-20020adfe604000000b003197c7d08d1mr4559820wrm.44.1695305219572; Thu, 21 Sep 2023 07:06:59 -0700 (PDT) X-Received: by 2002:adf:e604:0:b0:319:7c7d:8d1 with SMTP id p4-20020adfe604000000b003197c7d08d1mr4559793wrm.44.1695305219207; Thu, 21 Sep 2023 07:06:59 -0700 (PDT) MIME-Version: 1.0 References: <20230912030008.3599514-1-lulu@redhat.com> <20230912030008.3599514-2-lulu@redhat.com> In-Reply-To: From: Cindy Lu Date: Thu, 21 Sep 2023 22:06:16 +0800 Message-ID: Subject: Re: [RFC v2 1/4] vduse: Add function to get/free the pages for reconnection To: Jason Wang 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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:18:50 -0700 (PDT) On Mon, Sep 18, 2023 at 4:41=E2=80=AFPM Jason Wang wr= ote: > > On Tue, Sep 12, 2023 at 11:00=E2=80=AFAM Cindy Lu wrote= : > > > > Add the function vduse_alloc_reconnnect_info_mem > > and vduse_alloc_reconnnect_info_mem > > In this 2 function, vduse will get/free (vq_num + 1)*page > > Page 0 will be used to save the reconnection information, The > > Userspace App will maintain this. Page 1 ~ vq_num + 1 will save > > the reconnection information for vqs. > > Please explain why this is needed instead of only describing how it is > implemented. (Code can explain itself). > > > > > Signed-off-by: Cindy Lu > > --- > > drivers/vdpa/vdpa_user/vduse_dev.c | 86 ++++++++++++++++++++++++++++++ > > 1 file changed, 86 insertions(+) > > > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_use= r/vduse_dev.c > > index 26b7e29cb900..4c256fa31fc4 100644 > > --- a/drivers/vdpa/vdpa_user/vduse_dev.c > > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > > @@ -30,6 +30,10 @@ > > #include > > #include > > > > +#ifdef CONFIG_X86 > > +#include > > +#endif > > + > > #include "iova_domain.h" > > > > #define DRV_AUTHOR "Yongji Xie " > > @@ -41,6 +45,23 @@ > > #define VDUSE_IOVA_SIZE (128 * 1024 * 1024) > > #define VDUSE_MSG_DEFAULT_TIMEOUT 30 > > > > +/* struct vdpa_reconnect_info save the page information for reconnecti= on > > + * kernel will init these information while alloc the pages > > + * and use these information to free the pages > > + */ > > +struct vdpa_reconnect_info { > > + /* Offset (within vm_file) in PAGE_SIZE, > > + * this just for check, not using > > + */ > > + u32 index; > > + /* physical address for this page*/ > > + phys_addr_t addr; > > + /* virtual address for this page*/ > > + unsigned long vaddr; > > If it could be switched by virt_to_phys() why duplicate those fields? > yes will remove this part Thanks Cindy > > + /* memory size, here always page_size*/ > > + phys_addr_t size; > > If it's always PAGE_SIZE why would we have this? will remove this Thanks Cindy > > > +}; > > + > > struct vduse_virtqueue { > > u16 index; > > u16 num_max; > > @@ -57,6 +78,7 @@ struct vduse_virtqueue { > > struct vdpa_callback cb; > > struct work_struct inject; > > struct work_struct kick; > > + struct vdpa_reconnect_info reconnect_info; > > }; > > > > struct vduse_dev; > > @@ -106,6 +128,7 @@ struct vduse_dev { > > u32 vq_align; > > struct vduse_umem *umem; > > struct mutex mem_lock; > > + struct vdpa_reconnect_info reconnect_status; > > }; > > > > struct vduse_dev_msg { > > @@ -1030,6 +1053,65 @@ static int vduse_dev_reg_umem(struct vduse_dev *= dev, > > return ret; > > } > > > > +int vduse_alloc_reconnnect_info_mem(struct vduse_dev *dev) > > +{ > > + struct vdpa_reconnect_info *info; > > + struct vduse_virtqueue *vq; > > + void *addr; > > + > > + /*page 0 is use to save status,dpdk will use this to save the i= nformation > > + *needed in reconnection,kernel don't need to maintain this > > + */ > > + info =3D &dev->reconnect_status; > > + addr =3D (void *)get_zeroed_page(GFP_KERNEL); > > + if (!addr) > > + return -1; > > -ENOMEM? > sure will change this Thanks Cidny > Thanks >