From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5053C31ED7C for ; Fri, 12 Jun 2026 14:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781273185; cv=none; b=XimiPCLG3G3MVuJuXkTyVfzt5TK0+3qEKx4aiEBSX6yseep0CTiYEsSSOUwpw6C4jMRFw/vtbpme4KCNxIrRe9LxuaBNSYuMN8xtHBBteWVeWXe4sQEycN9B1uHrjfwec/4FgRp+7jOSHDXMHCr92FX1hh0WpKKf5fgOHley8AI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781273185; c=relaxed/simple; bh=8nGRcelhCMsBP5e+Ti6pgha8vZKPOQWb1Xzagxo6dR4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OlHbsFt1BebYKUQuC0gG0fQUTBDEn+m31udl9vIy6C4gh86lvbvRzVz5MsLCoCogdiTqMBiVPk54OIuV7sLU3QdT6g4nen85sNGKR+tkTRMDa115M6tjxGpwpcvxp2qKMDscI1X4YEcfhWDeyqmQecLaRSDzPe1G6Yqp8mHf7UY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=m7MvQXrP; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="m7MvQXrP" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2bf2911f93cso80395ad.1 for ; Fri, 12 Jun 2026 07:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781273184; x=1781877984; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7gWNes2hHFmdqgzisSBTrBhiO7t0Lprwi8AqbjigE24=; b=m7MvQXrP5FFeGc1nXMIYk+a4X8itmrWVegIOWowNV9rAshzHeltu3Bed8cXCOPVc+q 8qidSDuQhAIJOHwCIx4jRnzrDHORHEhizuJ+UgUNx8XV0FkP5yKsvRAlsSQ5TIO1E8lC KpQsX1DPsDhJvf/sy5nTzM/OMZ83w8OvRyaFXda5P7Ra0RGL2aHqaBU7LFG8k4snI1bQ eiiJZ7yrEHbsXb5yvCHQGz994pSiRo/Pdhh4J2Sse1gcY0D8AXEKesTggOZ3H2jSyXSO PpEH7xWuVwh1HzA3tob7KDuuQvXSZnPDRHa1Ooh3Q7zb5DoXaR9K/gSaBEe+HcEshp8/ cyNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781273184; x=1781877984; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7gWNes2hHFmdqgzisSBTrBhiO7t0Lprwi8AqbjigE24=; b=inI2UyYpoEXerlKMJvsKfJ75EjTqQWmoHuDhcEqy/0V/7dis1CX8CVLCdexXH5X4Qf 8bNBO4Gbkz5l2fr7POMAM/9Y1Vb8SUiC7JO855VaqNls2IYpQDwafUxGUd/wLZdAAWeE qq1tMV8jl3JfLNtYV1D76EzmJaIh5Hjm3NHQVGEgzD+nI+qk8y/Pse++K6CspIXwilHN 1S7jeGOYyIylRcTWaBkc0MkeZRi7gAcLUdCkoeaWcGPQoNraiPYHN9ED4ULd0s1PgK6i NTSPZs16ZvMcQnksKYE98XXzqBNlgUthjV/tRAgV3F1EBqB5mFA2GwoAxLjME2Bwu8gQ DJcA== X-Forwarded-Encrypted: i=1; AFNElJ9TcKJ6hxCfUwxL/XTgiTXgtuYzuBi+Dfh4MGMfhagUM3GC6eo9gUzE71S2QG8k9+wpXrY=@vger.kernel.org X-Gm-Message-State: AOJu0Yylgq5L1mrQooG5l4RYjRjvWK9cHsFAHMVPUiHV1+C29CaLh74L Z2c+c5w0c9Zn2Pitb8rZnttbVIm2iARg8Tfz3wj0TWEpL2YuDLaVug3oafQ2o7TYCw== X-Gm-Gg: Acq92OFEUoge2+m+lQCb/bpDHwIVS0tJE/5ooA1LAPh+FMAulYe3/qOctOnut2EkAU4 nCnqGAFh+ZZUegG7yvPQ4zy7z9dFnwSSb+OIsZNUY153R8TAfMnXXK5CdcHdK2W7cu0pyH+93v7 tQA3P68wX1DKswy87hvFZbnckuugqXVMmiAZAL7/2Ze5UUSa8IMZQtCNm4hGxy2pk6A/bw5nFxc yRr8SnaDYZgSfthIAtWLyc+ABfEIr41FaDKnu+X6edHis3J5448FrP7kqq4pfjEWa01c6x9vz33 4Tv/10TbdyZ0MrLl2UAjbhtezy0kyRqYwj/ttl1uafYnJKcnmqeAi4kn74BLzl5zGzLKCyZ+hqI lGguxG1DZBxNYFa5Ec7V+Db8LD4pWJGg5JBrA3WgoDpaZhY+2BBbfYfVO8yDIDH2/MoWROwg57r DbnL+kNJtcFlJvtyfGdtBbC0w0YEYmU7CeA/w1mgXdzpl50lPpZY0xuAe9i8JJ5m3OLIO+3p8= X-Received: by 2002:a17:903:46c6:b0:2bd:6dad:3df9 with SMTP id d9443c01a7336-2c405f85829mr1700165ad.23.1781273183096; Fri, 12 Jun 2026 07:06:23 -0700 (PDT) Received: from google.com (199.255.142.34.bc.googleusercontent.com. [34.142.255.199]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-37a25ecd5dcsm2325236a91.9.2026.06.12.07.06.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2026 07:06:22 -0700 (PDT) Date: Fri, 12 Jun 2026 14:06:14 +0000 From: Pranjal Shrivastava To: Matt Evans Cc: Alex Williamson , Leon Romanovsky , Jason Gunthorpe , Alex Mastro , Christian =?iso-8859-1?Q?K=F6nig?= , Bjorn Helgaas , Logan Gunthorpe , Mahmoud Adam , David Matlack , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Sumit Semwal , Kevin Tian , Ankit Agrawal , Alistair Popple , Vivek Kasireddy , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kvm@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v3 5/9] vfio/pci: Provide a user-facing name for BAR mappings Message-ID: References: <20260610154327.37758-1-matt@ozlabs.org> <20260610154327.37758-6-matt@ozlabs.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260610154327.37758-6-matt@ozlabs.org> On Wed, Jun 10, 2026 at 04:43:19PM +0100, Matt Evans wrote: > Since converting BAR mmap()s to using DMABUFs, we lose the original > device path in /proc//maps, lsof, etc. Generate a debug-oriented > synthetic 'filename' based on the cdev, plus BDF, plus resource index. > > This applies only to BAR mappings via the VFIO device fd, as > explicitly-exported DMABUFs are named by userspace via the > DMA_BUF_SET_NAME ioctl. > > Signed-off-by: Matt Evans > --- > drivers/vfio/pci/vfio_pci_dmabuf.c | 27 +++++++++++++++++++++++++-- > 1 file changed, 25 insertions(+), 2 deletions(-) > > diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c > index 2fd3629789bf..8f7f1b909b94 100644 > --- a/drivers/vfio/pci/vfio_pci_dmabuf.c > +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c > @@ -4,6 +4,7 @@ > #include > #include > #include > +#include > > #include "vfio_pci_priv.h" > > @@ -470,6 +471,7 @@ int vfio_pci_core_mmap_prep_dmabuf(struct vfio_pci_core_device *vdev, > { > struct vfio_pci_dma_buf *priv; > unsigned long vma_pgoff = vma->vm_pgoff & (VFIO_PCI_OFFSET_MASK >> PAGE_SHIFT); > + char *bufname; > int ret; > > priv = kzalloc_obj(*priv); > @@ -482,6 +484,20 @@ int vfio_pci_core_mmap_prep_dmabuf(struct vfio_pci_core_device *vdev, > goto err_free_priv; > } > > + bufname = kzalloc(DMA_BUF_NAME_LEN, GFP_KERNEL); > + if (!bufname) { > + ret = -ENOMEM; > + goto err_free_phys; > + } > + > + /* > + * Maximum size of the friendly debug name is > + * vfio1234567890:ffff:ff:3f.7/5 = 30, which fits within > + * DMA_BUF_NAME_LEN. > + */ > + snprintf(bufname, DMA_BUF_NAME_LEN, "%s:%s/%x", > + dev_name(&vdev->vdev.device), pci_name(vdev->pdev), res_index); > + Nit: Could we instead use: bufname = kasprintf(GFP_KERNEL, "%s:%s/%x", dev_name(&vdev->vdev.device), pci_name(vdev->pdev), res_index); if (!bufname) ret = -ENOMEM; [...] > /* > * The DMABUF begins from the mmap()'s BAR offset, i.e. the > * start of the VMA corresponds to byte 0 of the DMABUF and > @@ -500,7 +516,7 @@ int vfio_pci_core_mmap_prep_dmabuf(struct vfio_pci_core_device *vdev, > priv->provider = pcim_p2pdma_provider(vdev->pdev, res_index); > if (!priv->provider) { > ret = -EINVAL; > - goto err_free_phys; > + goto err_free_name; > } > > priv->phys_vec[0].paddr = phys_start + ((u64)vma_pgoff << PAGE_SHIFT); > @@ -508,7 +524,7 @@ int vfio_pci_core_mmap_prep_dmabuf(struct vfio_pci_core_device *vdev, > > ret = vfio_pci_dmabuf_export(vdev, priv, O_CLOEXEC | O_RDWR); > if (ret) > - goto err_free_phys; > + goto err_free_name; > > /* > * Ownership of the DMABUF file transfers to the VMA so that > @@ -523,8 +539,15 @@ int vfio_pci_core_mmap_prep_dmabuf(struct vfio_pci_core_device *vdev, > vma->vm_file = priv->dmabuf->file; > vma->vm_private_data = priv; > > + spin_lock(&priv->dmabuf->name_lock); > + kfree(priv->dmabuf->name); > + priv->dmabuf->name = bufname; > + spin_unlock(&priv->dmabuf->name_lock); > + > return 0; > > +err_free_name: > + kfree(bufname); > err_free_phys: > kfree(priv->phys_vec); > err_free_priv: Apart from that, Reviewed-by: Pranjal Shrivastava Thanks, Praan