-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'for-6.5/cxl-perf' into for-6.5/cxl
Pick up initial support for the CXL 3.0 performance monitoring definition. Small conflicts with the firmware update work as they both placed their init code in the same location.
- Loading branch information
Showing
19 changed files
with
1,307 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
.. SPDX-License-Identifier: GPL-2.0 | ||
====================================== | ||
CXL Performance Monitoring Unit (CPMU) | ||
====================================== | ||
|
||
The CXL rev 3.0 specification provides a definition of CXL Performance | ||
Monitoring Unit in section 13.2: Performance Monitoring. | ||
|
||
CXL components (e.g. Root Port, Switch Upstream Port, End Point) may have | ||
any number of CPMU instances. CPMU capabilities are fully discoverable from | ||
the devices. The specification provides event definitions for all CXL protocol | ||
message types and a set of additional events for things commonly counted on | ||
CXL devices (e.g. DRAM events). | ||
|
||
CPMU driver | ||
=========== | ||
|
||
The CPMU driver registers a perf PMU with the name pmu_mem<X>.<Y> on the CXL bus | ||
representing the Yth CPMU for memX. | ||
|
||
/sys/bus/cxl/device/pmu_mem<X>.<Y> | ||
|
||
The associated PMU is registered as | ||
|
||
/sys/bus/event_sources/devices/cxl_pmu_mem<X>.<Y> | ||
|
||
In common with other CXL bus devices, the id has no specific meaning and the | ||
relationship to specific CXL device should be established via the device parent | ||
of the device on the CXL bus. | ||
|
||
PMU driver provides description of available events and filter options in sysfs. | ||
|
||
The "format" directory describes all formats of the config (event vendor id, | ||
group id and mask) config1 (threshold, filter enables) and config2 (filter | ||
parameters) fields of the perf_event_attr structure. The "events" directory | ||
describes all documented events show in perf list. | ||
|
||
The events shown in perf list are the most fine grained events with a single | ||
bit of the event mask set. More general events may be enable by setting | ||
multiple mask bits in config. For example, all Device to Host Read Requests | ||
may be captured on a single counter by setting the bits for all of | ||
|
||
* d2h_req_rdcurr | ||
* d2h_req_rdown | ||
* d2h_req_rdshared | ||
* d2h_req_rdany | ||
* d2h_req_rdownnodata | ||
|
||
Example of usage:: | ||
|
||
$#perf list | ||
cxl_pmu_mem0.0/clock_ticks/ [Kernel PMU event] | ||
cxl_pmu_mem0.0/d2h_req_rdshared/ [Kernel PMU event] | ||
cxl_pmu_mem0.0/h2d_req_snpcur/ [Kernel PMU event] | ||
cxl_pmu_mem0.0/h2d_req_snpdata/ [Kernel PMU event] | ||
cxl_pmu_mem0.0/h2d_req_snpinv/ [Kernel PMU event] | ||
----------------------------------------------------------- | ||
|
||
$# perf stat -a -e cxl_pmu_mem0.0/clock_ticks/ -e cxl_pmu_mem0.0/d2h_req_rdshared/ | ||
|
||
Vendor specific events may also be available and if so can be used via | ||
|
||
$# perf stat -a -e cxl_pmu_mem0.0/vid=VID,gid=GID,mask=MASK/ | ||
|
||
The driver does not support sampling so "perf record" is unsupported. | ||
It only supports system-wide counting so attaching to a task is | ||
unsupported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ Performance monitor support | |
alibaba_pmu | ||
nvidia-pmu | ||
meson-ddr-pmu | ||
cxl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* Copyright(c) 2023 Huawei. All rights reserved. */ | ||
|
||
#include <linux/device.h> | ||
#include <linux/slab.h> | ||
#include <linux/idr.h> | ||
#include <cxlmem.h> | ||
#include <pmu.h> | ||
#include <cxl.h> | ||
#include "core.h" | ||
|
||
static void cxl_pmu_release(struct device *dev) | ||
{ | ||
struct cxl_pmu *pmu = to_cxl_pmu(dev); | ||
|
||
kfree(pmu); | ||
} | ||
|
||
const struct device_type cxl_pmu_type = { | ||
.name = "cxl_pmu", | ||
.release = cxl_pmu_release, | ||
}; | ||
|
||
static void remove_dev(void *dev) | ||
{ | ||
device_del(dev); | ||
} | ||
|
||
int devm_cxl_pmu_add(struct device *parent, struct cxl_pmu_regs *regs, | ||
int assoc_id, int index, enum cxl_pmu_type type) | ||
{ | ||
struct cxl_pmu *pmu; | ||
struct device *dev; | ||
int rc; | ||
|
||
pmu = kzalloc(sizeof(*pmu), GFP_KERNEL); | ||
if (!pmu) | ||
return -ENOMEM; | ||
|
||
pmu->assoc_id = assoc_id; | ||
pmu->index = index; | ||
pmu->type = type; | ||
pmu->base = regs->pmu; | ||
dev = &pmu->dev; | ||
device_initialize(dev); | ||
device_set_pm_not_required(dev); | ||
dev->parent = parent; | ||
dev->bus = &cxl_bus_type; | ||
dev->type = &cxl_pmu_type; | ||
switch (pmu->type) { | ||
case CXL_PMU_MEMDEV: | ||
rc = dev_set_name(dev, "pmu_mem%d.%d", assoc_id, index); | ||
break; | ||
} | ||
if (rc) | ||
goto err; | ||
|
||
rc = device_add(dev); | ||
if (rc) | ||
goto err; | ||
|
||
return devm_add_action_or_reset(parent, remove_dev, dev); | ||
|
||
err: | ||
put_device(&pmu->dev); | ||
return rc; | ||
} | ||
EXPORT_SYMBOL_NS_GPL(devm_cxl_pmu_add, CXL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.