From nobody Sun Nov 24 15:08:44 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 D47D21F8904; Tue, 5 Nov 2024 18:39:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730831968; cv=none; b=r72xCVIFyfmrHMoWV10ohiQaNeZLjlaPLUnnR7wuGRfoJ1aNl7bYqFY67erUuzH93fpm12F6o3Mp/zvNtcoCNoOkpw/r0IXX4W09YzdsILZ0JC9DN7KAwT1ykX7TEZ9bRT7Sd3Y8s18fcyR8hUd7zEzYqOMW9dfTuzGRYyvqATk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730831968; c=relaxed/simple; bh=/z57Di8+4MoIcNaFT/SVhi/tHc+RshShPSpFz6BZQZM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QmMG7e5G/KuEsDSYBEobJVUYSO6TZMxafLzyUOfTRGjfvedwikyCgvEkldoRU0+or8iUOWqmMeeGN2qM9nyZfzcpbLOn9BdLtG+3jG+iY35SZl96r+NxaRYg8LeTMSmztgHUuKWdFjp2b5zsNwK3PDj8Huii0eeGZ7s31yst15E= 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=HP/SSinM; arc=none smtp.client-ip=192.198.163.19 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="HP/SSinM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730831966; x=1762367966; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=/z57Di8+4MoIcNaFT/SVhi/tHc+RshShPSpFz6BZQZM=; b=HP/SSinMCe3ZbpuQrETRynwiD6fGPfHqlQtwfKn96hIuc+9ozP1Arf5R 5Xayuuwq/B7BWJFAd9/ZWZgQF7nMUPiME+Y5q9GkYOJAB/TwH2vxhGVWb Fl5kp2wrfTZGfXLiGtryv1fXIRQ4GMc+4/GmYOTkOBh5PRPoyTom3e8lL w9A1NgwApncT418/CoP1kvvsbQCt7kXQDvMGUIRC1WmVxRDLvoYOV0+u+ Z5WEHWFZznxZjSrghJQ5U98f2bRA4yxR16F3mEfViEcb21c1Wh18PnE3X lhK+J5XXfuerTh7b7ana7KHROBI6SGz7abOXrtireVJKDa2gfAVSbe3vq A==; X-CSE-ConnectionGUID: bmZ8J8MKSB6INdgD6rPjnA== X-CSE-MsgGUID: bf0koGywTcaxgxaDTPTcYg== X-IronPort-AV: E=McAfee;i="6700,10204,11247"; a="30012782" X-IronPort-AV: E=Sophos;i="6.11,260,1725346800"; d="scan'208";a="30012782" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2024 10:39:25 -0800 X-CSE-ConnectionGUID: O1OiMiHkR4KiOSYwSgy44g== X-CSE-MsgGUID: oXYJfTjfQ4mAXdMNOsFU7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,260,1725346800"; d="scan'208";a="88624682" Received: from spandruv-mobl4.amr.corp.intel.com (HELO localhost) ([10.125.109.247]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2024 10:39:23 -0800 From: ira.weiny@intel.com Date: Tue, 05 Nov 2024 12:38:43 -0600 Subject: [PATCH v6 21/27] cxl/region/extent: Expose region extent information in sysfs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241105-dcd-type2-upstream-v6-21-85c7fa2140fe@intel.com> References: <20241105-dcd-type2-upstream-v6-0-85c7fa2140fe@intel.com> In-Reply-To: <20241105-dcd-type2-upstream-v6-0-85c7fa2140fe@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=1730831904; l=4991; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=jn/tPekUkdIM6oMRPpacsGan7cxQjZRBW1QHWy0/zyY=; b=tKjIjyB9wwApsdn1dAu0rdVaEQUChUzf4mZME6aLe+w4F7bTViUoxcVz7jGrLO3f37vbESmDg i1zUkHT97wIA8+r9LzEpiUSHy757Yhm6wCtrhcpXUnfHCc7WNlwhdbZ 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 --- 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/te= sting/sysfs-bus-cxl index aeff248ea368cf49c9977fcaf43ab4def978e896..ee2ef4ea33e17cbc65e1252753f= 46f6d0dce1aee 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 bb12abe4792bcadd2442de3c21bf5ce4d48edf06..9f493aa8a5a26ca1dbaae48a396= f67f0e644e1ce 100644 --- a/drivers/cxl/core/extent.c +++ b/drivers/cxl/core/extent.c @@ -6,6 +6,63 @@ =20 #include "core.h" =20 +static ssize_t offset_show(struct device *dev, struct device_attribute *at= tr, + char *buf) +{ + struct region_extent *region_extent =3D 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 *at= tr, + char *buf) +{ + struct region_extent *region_extent =3D to_region_extent(dev); + u64 length =3D 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 =3D to_region_extent(dev); + + return sysfs_emit(buf, "%pUb\n", ®ion_extent->tag); +} +static DEVICE_ATTR_RO(tag); + +static struct attribute *region_extent_attrs[] =3D { + &dev_attr_offset.attr, + &dev_attr_length.attr, + &dev_attr_tag.attr, + NULL +}; + +static uuid_t empty_tag =3D { 0 }; + +static umode_t region_extent_visible(struct kobject *kobj, + struct attribute *a, int n) +{ + struct device *dev =3D kobj_to_dev(kobj); + struct region_extent *region_extent =3D to_region_extent(dev); + + if (a =3D=3D &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 =3D { + .attrs =3D region_extent_attrs, + .is_visible =3D 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 =3D { .name =3D "extent", .release =3D region_extent_release, + .groups =3D region_extent_attribute_groups, }; =20 bool is_region_extent(struct device *dev) --=20 2.47.0