Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp168942lqd; Tue, 23 Apr 2024 20:15:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXDwbnpaLimtF4456Wo4cUWviHICw5jul/+wd9u005dWBGe2keoWRqKsH1j6F6o3ehhpjT6+JZ/2FvMuHAMOmTu9YGvgrg641t7jF3uA== X-Google-Smtp-Source: AGHT+IHn6bJe71otULft2fB8XSwpIZ/h5dLykTv1w9UT10YNvgmPsFpMLJHMxVA/+sNVkFd+pOUt X-Received: by 2002:a50:8d1d:0:b0:56b:c210:870c with SMTP id s29-20020a508d1d000000b0056bc210870cmr699171eds.15.1713928553345; Tue, 23 Apr 2024 20:15:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713928553; cv=pass; d=google.com; s=arc-20160816; b=gKpF6wKL6TTeIoG8D/nRy5IusSO9vOC5L85JF9rlF9OCyifIrkOA7QF+Y7NrZ7tRww W48F7Oqf30BYcSHppGrp65Y6GFlT9ZIlxd56fZZdOfwiHA2RPUjVERTxQbpH2ZtvlskP Gz1+KvLx5+XXZ/jt22fs10DqG0PiH0cG2n/5xp59yf7WE9/7CL57TGwurxxa1Mmfbx88 xjkpFKycj8ycrp6gegZnqzDPjYKeM7Vv3EOfWLD+nzIEKraOnqksGThKKUuBzqwPcYHO OcRGJ9Dt2wvxmsE7T3XuX0dQ1W2R+yi695qZjRcQMaeCOpFCbBuGjgmLMVyPMi9ZA/fJ Lmww== 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=XJEFMAfNT/VB4mDk82qfL5Q4Ip01msm7cEvY6vFaAL0=; fh=vaABNjO4KykN9m5zh/z6z9IW+OMIOivKVAF9SHrxP8I=; b=vlzKf6qIwbqE+TxQLBrs+AYK2v/rHzOrColRGJcX4gjCaBhoEUd+HI6Mq9Zv49daQx j2jlGfRm9zU1zKHU5K6/S5ByW+zqwQGp9h3y+JGLgPS7uYW9QiJIUkwbj4xD9TmuPI1R +gKj+WS8Oz+JPcwOXwYRf/GvKWz8pj31g/ZQE7cF8CdDHg2q8cyiSkoB3ITS8hd1pk9c 8vbQEV6p2Aq5ei06ucnT0i96KDdxxwLuVoKJZvw3gZ94nLCsy4Pu14lzgRkA6jmMi9my tO1+LS9PCiLMJURMqVorX3PpGL6ItNa5lBzsJVfOx8SCxnemtOrFJnfL/0gzQDPptroE pe2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a86s0p4J; 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-156202-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156202-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m5-20020a056402050500b00572052cd9c3si3707488edv.502.2024.04.23.20.15.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 20:15:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156202-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a86s0p4J; 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-156202-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156202-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D277C1F235B7 for ; Wed, 24 Apr 2024 03:15:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 493BF1339BA; Wed, 24 Apr 2024 03:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a86s0p4J" 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 6487329429 for ; Wed, 24 Apr 2024 03:15:42 +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=1713928544; cv=none; b=a64e6w8T2QHCD7blPkCVtQNc1OhYFpFYsSrz7gjlV3yg7+KHe8G3WvAkKryw7EtDOwJ4qZ53x2sTJwCL3Md4NP4pCQ2tRd4yHJr3qOh5aITL74ybyJ9lT/ox1fYoae1gXbaZyqiyQ1OZMkkrLbpciMhddF9A/ViCMksbXLNmhq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713928544; c=relaxed/simple; bh=NGmbSMkF+xL8LH8gNNiByBDOn1Ho7TAhVQP5ngZJ200=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Td9UERZQ0MHs632yR32ULWXKimjC3N5VV+KlGAN393PPtmle5KOe7TPFW795n4zkDAJuwAnBpoJ+6LZeQsO4aC3MkO9x0H27iXTEM83iEJwApq+OfqnJtDXXa3Yz5RsVvm0Fudo/ysQv2M2NL28yox26ULJLtrMBYndOKsl608M= 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=a86s0p4J; 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=1713928541; 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=XJEFMAfNT/VB4mDk82qfL5Q4Ip01msm7cEvY6vFaAL0=; b=a86s0p4JGexXbdUnXpjc4JHKBhq0BVIVRc8AO60VhU1RjHdTMOXkrLe10F+nMBvsyWRWOk A5ygN2jHcyLLujFDL3nUHioT7akTUG7SPyuVELSHLhnPuhck6ZqgAd9z79Zhre0ggTCxLq pZvA7HVdIhSpuM9xp/qX3HLsuiH+/8A= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-533-ULmHo1WaPX-NGlTuXRLnUQ-1; Tue, 23 Apr 2024 23:15:38 -0400 X-MC-Unique: ULmHo1WaPX-NGlTuXRLnUQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a46852c2239so419584566b.1 for ; Tue, 23 Apr 2024 20:15:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713928537; x=1714533337; 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=XJEFMAfNT/VB4mDk82qfL5Q4Ip01msm7cEvY6vFaAL0=; b=wVOtZYjv0H5HnyMo/J90+6/gXkSgE0nMWt6Fw8BR+ZJ5rDSXWUJlUSc+0pM/kEuOYs lkrNZpyxSPF1jTerN3/EywG7E6TuRvQYP+aj/0OD3i4qC+gfRayOUe3561KoSVuwaCR0 /2b9C+v4l2SAZb5ruFh7MXiyMzru1rQkXxohUMHbtLiL0tjpZqHAvqpcUjrMZba9i3Zv WMP5A0/Ef1oKOHRXunofIut3vtrtDMoyumKrIew+L26JiDQtm+k6mExWWDw6/8UkjbJ/ 5qQTlZeLjvyHviZjhzWLmYrmYVwwDFN+Msjn22epQoMrAYdXK083TUUNFaWw4lin/QZN KmWA== X-Forwarded-Encrypted: i=1; AJvYcCVuW2U885y/5yNMz7THuEoLqOpfn3l+mnnUGRCUg0imzbLA2xYPHqzA6sAGm3jK6wl+WXWOEPaGydqUGqRjK5lFSqXYz4kRrPcrOLEE X-Gm-Message-State: AOJu0YwdTXUJOBJ85yj1GO7LV2Oqo0SyZp7NvmdjlZh5znFpY0fN+hNJ z46PLFr8o3Ew4bnIKb7lOAVvjUvf71bjUQrZsLZ+99sg6YsYk9hrUPZI0f7ONuzg31Ugywtafzx yKF4Z+klvRdnNWVWnH5cMk8edIiv9t5L1f6Op8v9lphlhpLYqdU/voknN+pwyDefrAFGPdANbgy C8ynNuoAooVxcpncgQR2uwQsoFqN9TznbbuMAk X-Received: by 2002:a17:906:7742:b0:a55:be6d:b9f8 with SMTP id o2-20020a170906774200b00a55be6db9f8mr679668ejn.10.1713928536834; Tue, 23 Apr 2024 20:15:36 -0700 (PDT) X-Received: by 2002:a17:906:7742:b0:a55:be6d:b9f8 with SMTP id o2-20020a170906774200b00a55be6db9f8mr679665ejn.10.1713928536512; Tue, 23 Apr 2024 20:15:36 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240412133017.483407-1-lulu@redhat.com> <20240412133017.483407-4-lulu@redhat.com> <20240417052723-mutt-send-email-mst@kernel.org> <20240422160348-mutt-send-email-mst@kernel.org> <20240423043538-mutt-send-email-mst@kernel.org> In-Reply-To: From: Cindy Lu Date: Wed, 24 Apr 2024 11:14:59 +0800 Message-ID: Subject: Re: [PATCH v5 3/5] vduse: Add function to get/free the pages for reconnection To: Jason Wang Cc: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 24, 2024 at 8:44=E2=80=AFAM Jason Wang wr= ote: > > On Tue, Apr 23, 2024 at 4:42=E2=80=AFPM Michael S. Tsirkin wrote: > > > > On Tue, Apr 23, 2024 at 11:09:59AM +0800, Jason Wang wrote: > > > On Tue, Apr 23, 2024 at 4:05=E2=80=AFAM Michael S. Tsirkin wrote: > > > > > > > > On Thu, Apr 18, 2024 at 08:57:51AM +0800, Jason Wang wrote: > > > > > On Wed, Apr 17, 2024 at 5:29=E2=80=AFPM Michael S. Tsirkin wrote: > > > > > > > > > > > > On Fri, Apr 12, 2024 at 09:28:23PM +0800, Cindy Lu wrote: > > > > > > > Add the function vduse_alloc_reconnnect_info_mem > > > > > > > and vduse_alloc_reconnnect_info_mem > > > > > > > These functions allow vduse to allocate and free memory for r= econnection > > > > > > > information. The amount of memory allocated is vq_num pages. > > > > > > > Each VQS will map its own page where the reconnection informa= tion will be saved > > > > > > > > > > > > > > Signed-off-by: Cindy Lu > > > > > > > --- > > > > > > > drivers/vdpa/vdpa_user/vduse_dev.c | 40 ++++++++++++++++++++= ++++++++++ > > > > > > > 1 file changed, 40 insertions(+) > > > > > > > > > > > > > > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdp= a/vdpa_user/vduse_dev.c > > > > > > > index ef3c9681941e..2da659d5f4a8 100644 > > > > > > > --- a/drivers/vdpa/vdpa_user/vduse_dev.c > > > > > > > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c > > > > > > > @@ -65,6 +65,7 @@ struct vduse_virtqueue { > > > > > > > int irq_effective_cpu; > > > > > > > struct cpumask irq_affinity; > > > > > > > struct kobject kobj; > > > > > > > + unsigned long vdpa_reconnect_vaddr; > > > > > > > }; > > > > > > > > > > > > > > struct vduse_dev; > > > > > > > @@ -1105,6 +1106,38 @@ static void vduse_vq_update_effective_= cpu(struct vduse_virtqueue *vq) > > > > > > > > > > > > > > vq->irq_effective_cpu =3D curr_cpu; > > > > > > > } > > > > > > > +static int vduse_alloc_reconnnect_info_mem(struct vduse_dev = *dev) > > > > > > > +{ > > > > > > > + unsigned long vaddr =3D 0; > > > > > > > + struct vduse_virtqueue *vq; > > > > > > > + > > > > > > > + for (int i =3D 0; i < dev->vq_num; i++) { > > > > > > > + /*page 0~ vq_num save the reconnect info for vq= */ > > > > > > > + vq =3D dev->vqs[i]; > > > > > > > + vaddr =3D get_zeroed_page(GFP_KERNEL); > > > > > > > > > > > > > > > > > > I don't get why you insist on stealing kernel memory for someth= ing > > > > > > that is just used by userspace to store data for its own use. > > > > > > Userspace does not lack ways to persist data, for example, > > > > > > create a regular file anywhere in the filesystem. > > > > > > > > > > Good point. So the motivation here is to: > > > > > > > > > > 1) be self contained, no dependency for high speed persist data > > > > > storage like tmpfs > > > > > > > > No idea what this means. > > > > > > I mean a regular file may slow down the datapath performance, so > > > usually the application will try to use tmpfs and other which is a > > > dependency for implementing the reconnection. > > > > Are we worried about systems without tmpfs now? > > Yes. > > > > > > > > > > > > > > 2) standardize the format in uAPI which allows reconnection from > > > > > arbitrary userspace, unfortunately, such effort was removed in ne= w > > > > > versions > > > > > > > > And I don't see why that has to live in the kernel tree either. > > > > > > I can't find a better place, any idea? > > > > > > Thanks > > > > > > Well anywhere on github really. with libvhost-user maybe? > > It's harmless enough in Documentation > > if you like but ties you to the kernel release cycle in a way that > > is completely unnecessary. > > Ok. > > Thanks > Sure, got it. Do we need to withdraw all the series? maybe we can keep the patch for support ioctl to get status and configure? thanks cindy > > > > > > > > > > > If the above doesn't make sense, we don't need to offer those pag= es by VDUSE. > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + if (vaddr =3D=3D 0) > > > > > > > + return -ENOMEM; > > > > > > > + > > > > > > > + vq->vdpa_reconnect_vaddr =3D vaddr; > > > > > > > + } > > > > > > > + > > > > > > > + return 0; > > > > > > > +} > > > > > > > + > > > > > > > +static int vduse_free_reconnnect_info_mem(struct vduse_dev *= dev) > > > > > > > +{ > > > > > > > + struct vduse_virtqueue *vq; > > > > > > > + > > > > > > > + for (int i =3D 0; i < dev->vq_num; i++) { > > > > > > > + vq =3D dev->vqs[i]; > > > > > > > + > > > > > > > + if (vq->vdpa_reconnect_vaddr) > > > > > > > + free_page(vq->vdpa_reconnect_vaddr); > > > > > > > + vq->vdpa_reconnect_vaddr =3D 0; > > > > > > > + } > > > > > > > + > > > > > > > + return 0; > > > > > > > +} > > > > > > > > > > > > > > static long vduse_dev_ioctl(struct file *file, unsigned int = cmd, > > > > > > > unsigned long arg) > > > > > > > @@ -1672,6 +1705,8 @@ static int vduse_destroy_dev(char *name= ) > > > > > > > mutex_unlock(&dev->lock); > > > > > > > return -EBUSY; > > > > > > > } > > > > > > > + vduse_free_reconnnect_info_mem(dev); > > > > > > > + > > > > > > > dev->connected =3D true; > > > > > > > mutex_unlock(&dev->lock); > > > > > > > > > > > > > > @@ -1855,12 +1890,17 @@ static int vduse_create_dev(struct vd= use_dev_config *config, > > > > > > > ret =3D vduse_dev_init_vqs(dev, config->vq_align, confi= g->vq_num); > > > > > > > if (ret) > > > > > > > goto err_vqs; > > > > > > > + ret =3D vduse_alloc_reconnnect_info_mem(dev); > > > > > > > + if (ret < 0) > > > > > > > + goto err_mem; > > > > > > > > > > > > > > __module_get(THIS_MODULE); > > > > > > > > > > > > > > return 0; > > > > > > > err_vqs: > > > > > > > device_destroy(&vduse_class, MKDEV(MAJOR(vduse_major), = dev->minor)); > > > > > > > +err_mem: > > > > > > > + vduse_free_reconnnect_info_mem(dev); > > > > > > > err_dev: > > > > > > > idr_remove(&vduse_idr, dev->minor); > > > > > > > err_idr: > > > > > > > -- > > > > > > > 2.43.0 > > > > > > > > > > > > >