Skip to content

Commit 42834b1

Browse files
davejiangdjbw
authored andcommitted
cxl: Export sysfs attributes for memory device QoS class
Export qos_class sysfs attributes for the CXL memory device. The QoS clas should show up as /sys/bus/cxl/devices/memX/ram/qos_class for the volatile partition and /sys/bus/cxl/devices/memX/pmem/qos_class for the persistent partition. The QTG ID is retrieved via _DSM after supplying the calculated bandwidth and latency for the entire CXL path from device to the CPU. This ID is used to match up to the root decoder QoS class to determine which CFMWS the memory range of a hotplugged CXL mem device should be assigned under. While there may be multiple DSMAS exported by the device CDAT, the driver will only expose the first QTG ID per partition in sysfs for now. In the future when multiple QTG IDs are necessary, they can be exposed. [1] [1]: https://lore.kernel.org/linux-cxl/167571650007.587790.10040913293130712882.stgit@djiang5-mobl3.local/T/#md2a47b1ead3e1ba08f50eab29a4af1aed1d215ab Suggested-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/170319625698.2212653.17544381274847420961.stgit@djiang5-mobl3 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 86557b7 commit 42834b1

2 files changed

Lines changed: 95 additions & 6 deletions

File tree

Documentation/ABI/testing/sysfs-bus-cxl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ Description:
2828
Payload in the CXL-2.0 specification.
2929

3030

31+
What: /sys/bus/cxl/devices/memX/ram/qos_class
32+
Date: May, 2023
33+
KernelVersion: v6.8
34+
Contact: linux-cxl@vger.kernel.org
35+
Description:
36+
(RO) For CXL host platforms that support "QoS Telemmetry"
37+
this attribute conveys a comma delimited list of platform
38+
specific cookies that identifies a QoS performance class
39+
for the volatile partition of the CXL mem device. These
40+
class-ids can be compared against a similar "qos_class"
41+
published for a root decoder. While it is not required
42+
that the endpoints map their local memory-class to a
43+
matching platform class, mismatches are not recommended
44+
and there are platform specific performance related
45+
side-effects that may result. First class-id is displayed.
46+
47+
3148
What: /sys/bus/cxl/devices/memX/pmem/size
3249
Date: December, 2020
3350
KernelVersion: v5.12
@@ -38,6 +55,23 @@ Description:
3855
Payload in the CXL-2.0 specification.
3956

4057

58+
What: /sys/bus/cxl/devices/memX/pmem/qos_class
59+
Date: May, 2023
60+
KernelVersion: v6.8
61+
Contact: linux-cxl@vger.kernel.org
62+
Description:
63+
(RO) For CXL host platforms that support "QoS Telemmetry"
64+
this attribute conveys a comma delimited list of platform
65+
specific cookies that identifies a QoS performance class
66+
for the persistent partition of the CXL mem device. These
67+
class-ids can be compared against a similar "qos_class"
68+
published for a root decoder. While it is not required
69+
that the endpoints map their local memory-class to a
70+
matching platform class, mismatches are not recommended
71+
and there are platform specific performance related
72+
side-effects that may result. First class-id is displayed.
73+
74+
4175
What: /sys/bus/cxl/devices/memX/serial
4276
Date: January, 2022
4377
KernelVersion: v5.18

drivers/cxl/mem.c

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,78 @@ static ssize_t trigger_poison_list_store(struct device *dev,
215215
}
216216
static DEVICE_ATTR_WO(trigger_poison_list);
217217

218+
static ssize_t ram_qos_class_show(struct device *dev,
219+
struct device_attribute *attr, char *buf)
220+
{
221+
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
222+
struct cxl_dev_state *cxlds = cxlmd->cxlds;
223+
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
224+
struct cxl_dpa_perf *dpa_perf;
225+
226+
if (!dev->driver)
227+
return -ENOENT;
228+
229+
if (list_empty(&mds->ram_perf_list))
230+
return -ENOENT;
231+
232+
dpa_perf = list_first_entry(&mds->ram_perf_list, struct cxl_dpa_perf,
233+
list);
234+
235+
return sysfs_emit(buf, "%d\n", dpa_perf->qos_class);
236+
}
237+
238+
static struct device_attribute dev_attr_ram_qos_class =
239+
__ATTR(qos_class, 0444, ram_qos_class_show, NULL);
240+
241+
static ssize_t pmem_qos_class_show(struct device *dev,
242+
struct device_attribute *attr, char *buf)
243+
{
244+
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
245+
struct cxl_dev_state *cxlds = cxlmd->cxlds;
246+
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlds);
247+
struct cxl_dpa_perf *dpa_perf;
248+
249+
if (!dev->driver)
250+
return -ENOENT;
251+
252+
if (list_empty(&mds->pmem_perf_list))
253+
return -ENOENT;
254+
255+
dpa_perf = list_first_entry(&mds->pmem_perf_list, struct cxl_dpa_perf,
256+
list);
257+
258+
return sysfs_emit(buf, "%d\n", dpa_perf->qos_class);
259+
}
260+
261+
static struct device_attribute dev_attr_pmem_qos_class =
262+
__ATTR(qos_class, 0444, pmem_qos_class_show, NULL);
263+
218264
static umode_t cxl_mem_visible(struct kobject *kobj, struct attribute *a, int n)
219265
{
220-
if (a == &dev_attr_trigger_poison_list.attr) {
221-
struct device *dev = kobj_to_dev(kobj);
222-
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
223-
struct cxl_memdev_state *mds =
224-
to_cxl_memdev_state(cxlmd->cxlds);
266+
struct device *dev = kobj_to_dev(kobj);
267+
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
268+
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
225269

270+
if (a == &dev_attr_trigger_poison_list.attr)
226271
if (!test_bit(CXL_POISON_ENABLED_LIST,
227272
mds->poison.enabled_cmds))
228273
return 0;
229-
}
274+
275+
if (a == &dev_attr_pmem_qos_class.attr)
276+
if (list_empty(&mds->pmem_perf_list))
277+
return 0;
278+
279+
if (a == &dev_attr_ram_qos_class.attr)
280+
if (list_empty(&mds->ram_perf_list))
281+
return 0;
282+
230283
return a->mode;
231284
}
232285

233286
static struct attribute *cxl_mem_attrs[] = {
234287
&dev_attr_trigger_poison_list.attr,
288+
&dev_attr_ram_qos_class.attr,
289+
&dev_attr_pmem_qos_class.attr,
235290
NULL
236291
};
237292

0 commit comments

Comments
 (0)