From patchwork Tue Oct 29 20:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 13855452 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 980EB20E318; Tue, 29 Oct 2024 20:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730234171; cv=none; b=eaAqtey+FQgaXS8ZxCniGRNGc5LWwd9H1ExvtaWk4ODGU5RHi6japxvgtqHE1+LXwqWccApqU6j7TWIYm8roweZMgoobrlKqt9MsHv4QseAPH8n9kuF2fP+1FenGoIyhmixIBoSu59ZZgE+RNhQG9t/oVOcBVPefKFPzE9UtAr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730234171; c=relaxed/simple; bh=YE25vA2o07V4KgiruehjjDYgD7QnZc1OO9tmcYsvxVc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J2i/bMO/aI5Djz0KKV6AZ0j9Awnt87KxvyE6JKx1L1YMDZhHz+JRcT1W4vIIV6uiMYNTCwt/iou8H7RwYhWkWPvNVAh7NNJXVJHzUTjFSjWPWXrTm/vxNzYT2HqAbAPj46t99bqJiycxdguBBDcWUK6i7eJux6l3LE964IeUUWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eqb/cX4v; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eqb/cX4v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730234169; x=1761770169; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=YE25vA2o07V4KgiruehjjDYgD7QnZc1OO9tmcYsvxVc=; b=eqb/cX4viUjerrWvkku2ouOngVN1pCvJPO+aRyH9ssPVa6bTkMj4WT1E z731oHfbJaHL7UmPZSP3bn6lPHIlOQxvLmGNGq2R06Ly/BRO72ZqvNM2q yLiQHr7YHjrtKThilj7zWx+S47ncfoqzvkMbXgMPkOt1KtRmqIL362Nw/ +V1GEasjA+Om3szSwXHtDcD4Kn5080hcRBRSXFSpnmXAyegS9JfNWQ2cn FzlW1i3GtPGYuinLTLsnzx7/24y0cMhlwFJ1jEb7ukG8oCuKLP2WlZlr2 I8J6OMlsEgwD4sUHetSD7arRMNv6pFNH2L7VguQwQe7Ytf83M/ry1Ll+j g==; X-CSE-ConnectionGUID: 4Uq9MIAOQTuzWgU6Vai57Q== X-CSE-MsgGUID: YN9pKCiMSduhH/h45peTwQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="52457638" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="52457638" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 13:36:08 -0700 X-CSE-ConnectionGUID: C4d5IZYAT9+1DYTj5shv+w== X-CSE-MsgGUID: +OvKzOEuSSS8qNBLQeMt4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,243,1725346800"; d="scan'208";a="119561323" Received: from ldmartin-desk2.corp.intel.com (HELO localhost) ([10.125.108.77]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 13:36:07 -0700 From: ira.weiny@intel.com Date: Tue, 29 Oct 2024 15:34:56 -0500 Subject: [PATCH v5 21/27] cxl/region/extent: Expose region extent information in sysfs Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241029-dcd-type2-upstream-v5-21-8739cb67c374@intel.com> References: <20241029-dcd-type2-upstream-v5-0-8739cb67c374@intel.com> In-Reply-To: <20241029-dcd-type2-upstream-v5-0-8739cb67c374@intel.com> To: Dave Jiang , Fan Ni , Jonathan Cameron , Navneet Singh , Jonathan Corbet , Andrew Morton Cc: Dan Williams , Davidlohr Bueso , Alison Schofield , Vishal Verma , Ira Weiny , linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730234086; l=5082; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=QGKSINbx2Fx4wEpT6L+Sjrs+51vOTAEIJrxuF6v4KOA=; b=oA0oG8W11YrWewrf7hjIng5A/hgI5HGfW0g/z2qHBQ/fW1q65qnLb7gpqYf5xTRptLXc1mkOp q0nKLYh7VT/CI1zXo9wRTdQr/cXs0rPeOsobuKHlGQhvteRiJj43FSR X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= From: Navneet Singh Extent information can be helpful to the user to coordinate memory usage with the external orchestrator and FM. Expose the details of region extents by creating the following sysfs entries. /sys/bus/cxl/devices/dax_regionX/extentX.Y /sys/bus/cxl/devices/dax_regionX/extentX.Y/offset /sys/bus/cxl/devices/dax_regionX/extentX.Y/length /sys/bus/cxl/devices/dax_regionX/extentX.Y/tag Signed-off-by: Navneet Singh Reviewed-by: Jonathan Cameron Reviewed-by: Fan Ni Tested-by: Fan Ni Co-developed-by: Ira Weiny Signed-off-by: Ira Weiny --- Changes: [Jonathan: mention UUID format for tag] [Jonathan: remove trailing comma] --- Documentation/ABI/testing/sysfs-bus-cxl | 33 +++++++++++++++++++ drivers/cxl/core/extent.c | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-cxl b/Documentation/ABI/testing/sysfs-bus-cxl index aeff248ea368cf49c9977fcaf43ab4def978e896..ee2ef4ea33e17cbc65e1252753f46f6d0dce1aee 100644 --- a/Documentation/ABI/testing/sysfs-bus-cxl +++ b/Documentation/ABI/testing/sysfs-bus-cxl @@ -632,3 +632,36 @@ Description: See Documentation/ABI/stable/sysfs-devices-node. access0 provides the number to the closest initiator and access1 provides the number to the closest CPU. + +What: /sys/bus/cxl/devices/dax_regionX/extentX.Y/offset +Date: December, 2024 +KernelVersion: v6.13 +Contact: linux-cxl@vger.kernel.org +Description: + (RO) [For Dynamic Capacity regions only] Users can use the + extent information to create DAX devices on specific extents. + This is done by creating and destroying DAX devices in specific + sequences and looking at the mappings created. Extent offset + within the region. + +What: /sys/bus/cxl/devices/dax_regionX/extentX.Y/length +Date: December, 2024 +KernelVersion: v6.13 +Contact: linux-cxl@vger.kernel.org +Description: + (RO) [For Dynamic Capacity regions only] Users can use the + extent information to create DAX devices on specific extents. + This is done by creating and destroying DAX devices in specific + sequences and looking at the mappings created. Extent length + within the region. + +What: /sys/bus/cxl/devices/dax_regionX/extentX.Y/tag +Date: December, 2024 +KernelVersion: v6.13 +Contact: linux-cxl@vger.kernel.org +Description: + (RO) [For Dynamic Capacity regions only] Users can use the + extent information to create DAX devices on specific extents. + This is done by creating and destroying DAX devices in specific + sequences and looking at the mappings created. UUID extent + tag. diff --git a/drivers/cxl/core/extent.c b/drivers/cxl/core/extent.c index 315aa46252c15dcefe175da87522505f8ecf537c..97be798873d5043cf811bcf3ead43b9a3830605b 100644 --- a/drivers/cxl/core/extent.c +++ b/drivers/cxl/core/extent.c @@ -6,6 +6,63 @@ #include "core.h" +static ssize_t offset_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct region_extent *region_extent = to_region_extent(dev); + + return sysfs_emit(buf, "%#llx\n", region_extent->hpa_range.start); +} +static DEVICE_ATTR_RO(offset); + +static ssize_t length_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct region_extent *region_extent = to_region_extent(dev); + u64 length = range_len(®ion_extent->hpa_range); + + return sysfs_emit(buf, "%#llx\n", length); +} +static DEVICE_ATTR_RO(length); + +static ssize_t tag_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct region_extent *region_extent = to_region_extent(dev); + + return sysfs_emit(buf, "%pUb\n", ®ion_extent->tag); +} +static DEVICE_ATTR_RO(tag); + +static struct attribute *region_extent_attrs[] = { + &dev_attr_offset.attr, + &dev_attr_length.attr, + &dev_attr_tag.attr, + NULL +}; + +static uuid_t empty_tag = { 0 }; + +static umode_t region_extent_visible(struct kobject *kobj, + struct attribute *a, int n) +{ + struct device *dev = kobj_to_dev(kobj); + struct region_extent *region_extent = to_region_extent(dev); + + if (a == &dev_attr_tag.attr && + uuid_equal(®ion_extent->tag, &empty_tag)) + return 0; + + return a->mode; +} + +static const struct attribute_group region_extent_attribute_group = { + .attrs = region_extent_attrs, + .is_visible = region_extent_visible, +}; + +__ATTRIBUTE_GROUPS(region_extent_attribute); + static void cxled_release_extent(struct cxl_endpoint_decoder *cxled, struct cxled_extent *ed_extent) { @@ -45,6 +102,7 @@ static void region_extent_release(struct device *dev) static const struct device_type region_extent_type = { .name = "extent", .release = region_extent_release, + .groups = region_extent_attribute_groups, }; bool is_region_extent(struct device *dev)