Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf: arm_cspmu: nvidia: monitor all ports by default

Some NVIDIA PMUs like the NVLINK-C2C, CNVLINK, and PCIE PMU provide
port filtering. If the port filter is set to zero, the counter of
these PMUs will not capture any event. To avoid meaningless
experiment, the driver sets the port filter value to a default
non-zero value.

Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com>
Link: https://lore.kernel.org/r/20241031142118.1865965-5-bwicaksono@nvidia.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Besar Wicaksono and committed by
Will Deacon
bce61d5c ca26df4b

+12 -6
+8 -4
Documentation/admin-guide/perf/nvidia-pmu.rst
··· 89 89 The NVLink-C2C has two ports that can be connected to one GPU (occupying both 90 90 ports) or to two GPUs (one GPU per port). The user can use "port" bitmap 91 91 parameter to select the port(s) to monitor. Each bit represents the port number, 92 - e.g. "port=0x1" corresponds to port 0 and "port=0x3" is for port 0 and 1. 92 + e.g. "port=0x1" corresponds to port 0 and "port=0x3" is for port 0 and 1. The 93 + PMU will monitor both ports by default if not specified. 93 94 94 95 Example for port filtering: 95 96 ··· 135 134 The NVLink-C2C has two ports that can be connected to one GPU (occupying both 136 135 ports) or to two GPUs (one GPU per port). The user can use "port" bitmap 137 136 parameter to select the port(s) to monitor. Each bit represents the port number, 138 - e.g. "port=0x1" corresponds to port 0 and "port=0x3" is for port 0 and 1. 137 + e.g. "port=0x1" corresponds to port 0 and "port=0x3" is for port 0 and 1. The 138 + PMU will monitor both ports by default if not specified. 139 139 140 140 Example for port filtering: 141 141 ··· 162 160 Each SoC socket can be connected to one or more sockets via CNVLink. The user can 163 161 use "rem_socket" bitmap parameter to select the remote socket(s) to monitor. 164 162 Each bit represents the socket number, e.g. "rem_socket=0xE" corresponds to 165 - socket 1 to 3. 163 + socket 1 to 3. The PMU will monitor all remote sockets by default if not 164 + specified. 166 165 /sys/bus/event_source/devices/nvidia_cnvlink_pmu_<socket-id>/format/rem_socket 167 166 shows the valid bits that can be set in the "rem_socket" parameter. 168 167 ··· 202 199 203 200 Each SoC socket can support multiple root ports. The user can use 204 201 "root_port" bitmap parameter to select the port(s) to monitor, i.e. 205 - "root_port=0xF" corresponds to root port 0 to 3. 202 + "root_port=0xF" corresponds to root port 0 to 3. The PMU will monitor all root 203 + ports by default if not specified. 206 204 /sys/bus/event_source/devices/nvidia_pcie_pmu_<socket-id>/format/root_port 207 205 shows the valid bits that can be set in the "root_port" parameter. 208 206
+4 -2
drivers/perf/arm_cspmu/nvidia_cspmu.c
··· 175 175 const struct nv_cspmu_ctx *ctx = 176 176 to_nv_cspmu_ctx(to_arm_cspmu(event->pmu)); 177 177 178 - if (ctx->filter_mask == 0) 178 + const u32 filter_val = event->attr.config1 & ctx->filter_mask; 179 + 180 + if (filter_val == 0) 179 181 return ctx->filter_default_val; 180 182 181 - return event->attr.config1 & ctx->filter_mask; 183 + return filter_val; 182 184 } 183 185 184 186 enum nv_cspmu_name_fmt {