From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 263ED39EF23; Wed, 29 Jul 2026 17:52:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785347565; cv=none; b=b+xF0X01yeocrDaKbSSeQ/aHu7KTymcYCLwSY1bMPGovAHvXUNyQy+bI/M8zizocVGbmvCDBexo5IsJ/61qA7Ie5OTo6AXq2T7/i7Fxj/mfWdpo/YroOxUjUZnHcU7SECiuEIeDV0g5EbGeDTwHnm0xQFXMnPJKKc/JpUPA2S6E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785347565; c=relaxed/simple; bh=UmoCyoW1+B65IpGMS+VGdlWV5NUjzcYcNkcddFzWlnE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lN3YgNxs+X356psHGTBfyS+Y0cRhO6JehYlHOht1NxtTOuq34ZD3eM4K2VKOt5aAqHJMQ7q1VCc7Fboyl9f7FwMRHMYadF6LkR7vyp+x2a0kQgRbGWqQf7v/IDrDzmZJxP8kdhdlVtj1osTWscTFAVkJpZjHlimugUcOE8qZ+zc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org; spf=pass smtp.mailfrom=shazbot.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b=sqREERo8; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OjBg0u0c; arc=none smtp.client-ip=202.12.124.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shazbot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b="sqREERo8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OjBg0u0c" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id CCFFA7A015D; Wed, 29 Jul 2026 13:52:41 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Wed, 29 Jul 2026 13:52:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1785347561; x=1785433961; bh=swpO+bNIco0ihJ3x/W/Pu1/SVkczokwLjjxdBh5qjHw=; b= sqREERo8HzAmvXZHFuCj/SlyWZZB8UeN9C2HchMSbnX2sjmZl8T2z0v1JusVXpSD hdBlqEqFYdFsy2kNz+f8ByGoYqXWKw1BS/MSuqVNSGoYYAMYOv4IOIFdX/U0bVlG 8GEuLLbUo9eu5bewbnyfde3texnd/KwvK3yZQhD9Ry5SKNqDjDeW5SoKV7ydU9l0 yWbtxU9CYTFlSzroDd9MZbJXgD36AYA7SUaFxTjR198DlgJLeU+AXMTIqAdRCMz/ iuh6FbWaVQ2oLvjdgn/7Kx+h5FqPClNiJfrhUNvqKQixZdqIn1OqoVNxhdRvca+5 kztMO5PH3pU4dNmBMNlLhg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2;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xrBrgSLiU+3HZlBGCOuXaPpMS EdOJGXzIUGBYf4QhuB6DNQ5UJ1bhVK2sOVcskyLlKBxFhuIMN34k4k+rP1Nw X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Jul 2026 13:52:39 -0400 (EDT) Date: Wed, 29 Jul 2026 11:52:02 -0600 From: Alex Williamson To: Matt Evans Cc: Leon Romanovsky , Jason Gunthorpe , Alex Mastro , Christian =?UTF-8?B?S8O2bmln?= , Bjorn Helgaas , Logan Gunthorpe , Kevin Tian , Pranjal Shrivastava , Longfang Liu , Mahmoud Adam , David Matlack , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Sumit Semwal , 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, alex@shazbot.org Subject: Re: [PATCH v5 6/9] vfio/pci: Provide a user-facing name for BAR mappings Message-ID: <20260729115202.15ac87c5@shazbot.org> In-Reply-To: <20260715174737.15287-7-matt@ozlabs.org> References: <20260715174737.15287-1-matt@ozlabs.org> <20260715174737.15287-7-matt@ozlabs.org> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 15 Jul 2026 18:47:29 +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 > Reviewed-by: Pranjal Shrivastava > --- > drivers/vfio/pci/vfio_pci_dmabuf.c | 22 ++++++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > > diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci_dmabuf.c > index 46b3cf5dc94b..51606ff3cdc6 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 Is this required? It seems unused. > > #include "vfio_pci_priv.h" > > @@ -486,6 +487,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); > @@ -498,6 +500,15 @@ int vfio_pci_core_mmap_prep_dmabuf(struct vfio_pci_core_device *vdev, > goto err_free_priv; > } > > + bufname = kasprintf(GFP_KERNEL, "%s:%s/%x", > + dev_name(&vdev->vdev.device), pci_name(vdev->pdev), > + res_index); > + > + if (!bufname) { > + ret = -ENOMEM; > + goto err_free_phys; > + } > + > /* > * The DMABUF begins from the mmap()'s BAR offset, i.e. the > * start of the VMA corresponds to byte 0 of the DMABUF and > @@ -516,7 +527,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); > @@ -524,7 +535,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 > @@ -539,8 +550,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); This is simple, but shouldn't it really have a sanctioned, exported dmabuf helper rather than open coding this handling? Thanks, Alex > + > return 0; > > +err_free_name: > + kfree(bufname); > err_free_phys: > kfree(priv->phys_vec); > err_free_priv: