Received: by 10.223.185.116 with SMTP id b49csp7711117wrg; Thu, 1 Mar 2018 09:47:19 -0800 (PST) X-Google-Smtp-Source: AG47ELtqXvAn07/MzIMHKw0lLFQqEcht86icVrzZOP8xQt1DHvCajGxRFfJ/8aOczIjL7mTowxgm X-Received: by 2002:a17:902:724a:: with SMTP id c10-v6mr2632111pll.98.1519926439817; Thu, 01 Mar 2018 09:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519926439; cv=none; d=google.com; s=arc-20160816; b=uBCGfqi6UzVvPCzC7EUQn+CrER3njlKfTXiFirreUxXfPw3b6hkUyv/odWEOytEJCf eSZ6i4PdFX04dOIGiNCn+PMxqHKhH0pe40dbJ5Uw8Jy3iZzxrZoeVzGkhCYNSGfLsnVL FaTiE74G8KpXj8qETTIYvR3sA+ZYj2220kZgMhmeWmdvXgPhPArS++Gj2pEWj38o2dkT wK36VNpljnrf9jk5jf+gAqijG+Wuc4+qT2hNavBSIGDa+Mh+EqSa8adh3QiGBd00nanZ 6cnmxeoVVFglAZEQRDtf8+WByAzAYkSqRpquqZcriFgYXzj2lJpWFGyYMhF5HkKG3GHz hF1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=6QGHS55rhh6EzXX8AeA0I3pg4zSm3MyZuPdonrDPYac=; b=g5Nv9X7Pk1k6g/K1Fa8qUrPEcTzYZkTKZLy0YytRAs6ysv9YGaK4r+Ix08bgUygtyW vfbL2yO6FuEHIZgwjeCzU5fnI8opTqVht7eUUNSJaRXqgavgzHkC1Lq/lJ0LBYdFfDXW AR0w4jQx2nvoVslry8omLTxelOOCIX/3qoihtv7HWC8+us4CLCbvxC/MwRdizeEfHnqP WAUCu9AjnMUQa3PD4X1ftrfkfGhxA40n7W6T33NwINylQrShvsj6AyC0+iJ6VJ7eO7Z8 7TfKXG/fGaiyvH28vuzP2AGu/HV5dCpI7e54/ra+zM2CCSCAWgjS/PWC/RvHOB4LwYBS DSrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si2711657pgp.141.2018.03.01.09.47.05; Thu, 01 Mar 2018 09:47:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033619AbeCARoz (ORCPT + 99 others); Thu, 1 Mar 2018 12:44:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:47482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033374AbeCARox (ORCPT ); Thu, 1 Mar 2018 12:44:53 -0500 Received: from localhost (50-81-63-165.client.mchsi.com [50.81.63.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D9F0C20856; Thu, 1 Mar 2018 17:44:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9F0C20856 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Thu, 1 Mar 2018 11:44:50 -0600 From: Bjorn Helgaas To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, linux-nvdimm@lists.01.org, linux-block@vger.kernel.org, Stephen Bates , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?iso-8859-1?B?Suly9G1l?= Glisse , Benjamin Herrenschmidt , Alex Williamson Subject: Re: [PATCH v2 02/10] PCI/P2PDMA: Add sysfs group to display p2pmem stats Message-ID: <20180301174450.GF13722@bhelgaas-glaptop.roam.corp.google.com> References: <20180228234006.21093-1-logang@deltatee.com> <20180228234006.21093-3-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180228234006.21093-3-logang@deltatee.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 28, 2018 at 04:39:58PM -0700, Logan Gunthorpe wrote: > Attributes display the total amount of P2P memory, the amount available > and whether it is published or not. Can you add enough text here to make the body of the changelog complete in itself? That might mean just repeating the subject, which is fine. > Signed-off-by: Logan Gunthorpe > --- > Documentation/ABI/testing/sysfs-bus-pci | 25 +++++++++++++++++ > drivers/pci/p2pdma.c | 50 +++++++++++++++++++++++++++++++++ > 2 files changed, 75 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci > index 44d4b2be92fd..f5656dae21be 100644 > --- a/Documentation/ABI/testing/sysfs-bus-pci > +++ b/Documentation/ABI/testing/sysfs-bus-pci > @@ -323,3 +323,28 @@ Description: > > This is similar to /sys/bus/pci/drivers_autoprobe, but > affects only the VFs associated with a specific PF. > + > +What: /sys/bus/pci/devices/.../p2pmem/available > +Date: November 2017 > +Contact: Logan Gunthorpe > +Description: > + If the device has any Peer-to-Peer memory registered, this > + file contains the amount of memory that has not been > + allocated (in decimal). > + > +What: /sys/bus/pci/devices/.../p2pmem/size > +Date: November 2017 > +Contact: Logan Gunthorpe > +Description: > + If the device has any Peer-to-Peer memory registered, this > + file contains the total ammount of memory that the device s/ammount/amount/ > + provides (in decimal). > + > +What: /sys/bus/pci/devices/.../p2pmem/published > +Date: November 2017 > +Contact: Logan Gunthorpe > +Description: > + If the device has any Peer-to-Peer memory registered, this > + file contains a '1' if the memory has been published for > + use inside the kernel or a '0' if it is only intended > + for use within the driver that published it. > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > index ec0a6cb9e500..a57df78f6a32 100644 > --- a/drivers/pci/p2pdma.c > +++ b/drivers/pci/p2pdma.c > @@ -29,6 +29,53 @@ struct pci_p2pdma { > bool published; > }; > > +static ssize_t size_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + size_t size = 0; > + > + if (pdev->p2pdma->pool) > + size = gen_pool_size(pdev->p2pdma->pool); > + > + return snprintf(buf, PAGE_SIZE, "%zd\n", size); > +} > +static DEVICE_ATTR_RO(size); > + > +static ssize_t available_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + size_t avail = 0; > + > + if (pdev->p2pdma->pool) > + avail = gen_pool_avail(pdev->p2pdma->pool); > + > + return snprintf(buf, PAGE_SIZE, "%zd\n", avail); > +} > +static DEVICE_ATTR_RO(available); > + > +static ssize_t published_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct pci_dev *pdev = to_pci_dev(dev); > + > + return snprintf(buf, PAGE_SIZE, "%d\n", pdev->p2pdma->published); > +} > +static DEVICE_ATTR_RO(published); > + > +static struct attribute *p2pmem_attrs[] = { > + &dev_attr_size.attr, > + &dev_attr_available.attr, > + &dev_attr_published.attr, > + NULL, > +}; > + > +static const struct attribute_group p2pmem_group = { > + .attrs = p2pmem_attrs, > + .name = "p2pmem", > +}; > + > static void pci_p2pdma_percpu_release(struct percpu_ref *ref) > { > struct pci_p2pdma *p2p = > @@ -55,6 +102,7 @@ static void pci_p2pdma_release(void *data) > percpu_ref_exit(&pdev->p2pdma->devmap_ref); > > gen_pool_destroy(pdev->p2pdma->pool); > + sysfs_remove_group(&pdev->dev.kobj, &p2pmem_group); > pdev->p2pdma = NULL; > } > > @@ -83,6 +131,8 @@ static int pci_p2pdma_setup(struct pci_dev *pdev) > if (error) > goto out_pool_destroy; > > + error = sysfs_create_group(&pdev->dev.kobj, &p2pmem_group); > + > pdev->p2pdma = p2p; I think these two statements are out of order, since the attributes dereference pdev->p2pdma. And it looks like you set "error" unnecessarily, since you return immediately looking at it. > return 0; > -- > 2.11.0 >