|
| 1 | +CMN System Investigation Tools |
| 2 | +============================== |
| 3 | + |
| 4 | +These tools help developers understand system performance on |
| 5 | +systems based on Arm's CMN family interconnects (CMN-600, CMN-650, |
| 6 | +CMN-700, CI-700 etc.). |
| 7 | + |
| 8 | +The tools are aimed at developers of complex multithreaded |
| 9 | +applications and middleware, and at system administrators and |
| 10 | +others who need to understand whole-node performance. |
| 11 | + |
| 12 | +The tools generally assume root privilege, and direct access |
| 13 | +to a server or a "metal" instance. |
| 14 | + |
| 15 | +Tools are provided to: |
| 16 | + |
| 17 | + - discover the CMN mesh topology and record it in a JSON file |
| 18 | + |
| 19 | + - discover the mapping of Linux CPUs to mesh nodes |
| 20 | + |
| 21 | + - visualize the mesh topology as a 2-D diagram |
| 22 | + |
| 23 | + - construct PMU event specifiers (including complex watchpoints) |
| 24 | + for use with "perf" tools |
| 25 | + |
| 26 | + - collect histograms and metrics to understand system traffic |
| 27 | + behaviors associated with common scenarios |
| 28 | + |
| 29 | +The tools are mostly written in Python. Any recent version of |
| 30 | +Python3 should be sufficient. Some tools may work with Python2. |
| 31 | + |
| 32 | + |
| 33 | +Setup |
| 34 | +===== |
| 35 | + |
| 36 | +Some of the tools need a system topology description, to |
| 37 | +identify the specific configuration, topology and CPU locations |
| 38 | +for your system. This may already be available for your system. |
| 39 | +If not, it can be created using the discovery tools (see below). |
| 40 | + |
| 41 | +The default location for this file in your home directory is: |
| 42 | + |
| 43 | + ~/.cache/arm/cmn-system.json |
| 44 | + |
| 45 | +Discovery scripts and other tools will create, update or use |
| 46 | +this file as appropriate. |
| 47 | + |
| 48 | + |
| 49 | +Creating the topology description file |
| 50 | +-------------------------------------- |
| 51 | +This step should only need to be done once, but needs a |
| 52 | +significant level of system privilege. See README-discovery.md. |
| 53 | + |
| 54 | + |
| 55 | +Visualizing a CMN interconnect |
| 56 | +------------------------------ |
| 57 | + |
| 58 | +The interconnect can be visualized as a text diagram. Run: |
| 59 | + |
| 60 | + python cmn_diagram.py |
| 61 | + |
| 62 | +This will print a text diagram like this: |
| 63 | + |
| 64 | + 0c:RN-D 2c:RN-D 4c:RN-F:#0,#1 6c:SN-F |
| 65 | + / / / / |
| 66 | + 08(0,1)--------------28(1,1)--------------48(2,1)--------------68(3,1) |
| 67 | + /| /| /| /| |
| 68 | + 08:RN-D | 28:HN-F | 48:HN-F | 68:HN-D | |
| 69 | + | | | | |
| 70 | + | 04:RN-D | 24:HN-F | 44:HN-F | 64:SBSX |
| 71 | + |/ |/ |/ |/ |
| 72 | + 00(0,0)--------------20(1,0)--------------40(2,0)--------------60(3,0) |
| 73 | + / / / / |
| 74 | + 00:CXRH 20:RN-F:#2,#3 40:RN-D 60:SN-F |
| 75 | + |
| 76 | + |
| 77 | +Recap - discovering the mesh topology |
| 78 | +------------------------------------- |
| 79 | + |
| 80 | +Let's recap the CMN discovery process: |
| 81 | + |
| 82 | + sudo python cmn_discover.py |
| 83 | + python cmn_detect_cpu.py |
| 84 | + python cmn_diagram_py |
| 85 | + |
| 86 | +If this succeeds, you should have a cached CMN configuration file in |
| 87 | +``~/.cache/arm/cmn-system.json``, and a diagram of the mesh will |
| 88 | +appear on the console. |
| 89 | + |
| 90 | +If problems occur see the "troubleshooting" section. |
| 91 | + |
| 92 | + |
| 93 | +Top-down analysis |
| 94 | +----------------- |
| 95 | + |
| 96 | +Top-down performance analysis aims at finding the significant |
| 97 | +contributors to system bandwidth. It analyzes system usage, rather |
| 98 | +than specific applications. |
| 99 | + |
| 100 | +The ``cmn_topdown.py`` script provides several levels of top-down |
| 101 | +performance analysis, using CMN PMU events. Currently three |
| 102 | +levels are featured: |
| 103 | + |
| 104 | + - Level 1 identifies which requesters are dominant (CPU vs. I/O) |
| 105 | + |
| 106 | + - Level 2, for multi-die or multi-socket systems, measures local |
| 107 | + versus remote access |
| 108 | + |
| 109 | + - Level 3 further characterizes memory accesses into system |
| 110 | + cache hits and misses. |
| 111 | + |
| 112 | +The exact process of top-down analysis may vary across different |
| 113 | +systems, depending on CMN version and configuration. |
| 114 | + |
| 115 | +Top-down analysis is currently at an experimental stage and will |
| 116 | +be significantly enhanced in upcoming releases of these tools. |
| 117 | + |
| 118 | + |
| 119 | +Constructing CHI watchpoint strings |
| 120 | +----------------------------------- |
| 121 | + |
| 122 | +If the Linux CMN PMU driver is installed, CMN perf events are |
| 123 | +available through the ``perf_event_open`` interface and the ``perf`` |
| 124 | +userspace tools. These should be sufficient for many purposes. |
| 125 | + |
| 126 | +In some cases it may be useful to construct CMN watchpoints to |
| 127 | +match and count certan types of interconnect traffic. This generally |
| 128 | +requires some level of knowledge of the CHI architecture. |
| 129 | +The ``cmnwatch.py`` script can be used to generate strings that |
| 130 | +match CHI flits. The strings can be passed to the ``perf`` command. |
| 131 | + |
| 132 | + perf stat -e `python cmnwatch.py up:req:opcode=Evict` ... |
| 133 | + |
| 134 | +will expand into one or more CMN ``watchpoint_up`` events, |
| 135 | +that will count all flits (interconnect packets) matching the |
| 136 | +selected fields. |
| 137 | + |
| 138 | +Watchpoints can refer to a subset of CHI fields. Not all fields |
| 139 | +can be matched. |
| 140 | + |
| 141 | + |
| 142 | +Troubleshooting |
| 143 | +=============== |
| 144 | + |
| 145 | +It is difficult to cover all possible problems that might be |
| 146 | +encountered but we can cover some common issues: |
| 147 | + |
| 148 | + - the system might not be based on an Arm CMN interconnect. |
| 149 | + cmn_discover.py will report this. |
| 150 | + |
| 151 | + - the Linux CMN PMU driver might not be installed and enabled. |
| 152 | + Check for /sys/devices/arm_cmn_0. (A future version of this |
| 153 | + guide might explain how to enable the CMN PMU driver.) |
| 154 | + |
| 155 | + - insufficient privilege to see CMN PMU events. Try this: |
| 156 | + ``sysctl kernel.perf_event_paranoid=0`` |
| 157 | + |
| 158 | + - due to security settings, some systems do not provide |
| 159 | + visibility of the RSP and DAT channels in the interconnect. |
| 160 | + Some use cases for advanced watchpoints will not be |
| 161 | + available. |
| 162 | + |
| 163 | +Please also see TODO.md which lists some known limitations that |
| 164 | +may be addressed in future releases. |
| 165 | + |
| 166 | + |
| 167 | +License Information |
| 168 | +=================== |
| 169 | + |
| 170 | +*Copyright (C) ARM Limited, 2024. All rights reserved.* |
| 171 | + |
| 172 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 173 | +you may not use this file except in compliance with the License. |
| 174 | +You may obtain a copy of the License at: |
| 175 | + |
| 176 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 177 | + |
| 178 | +Unless required by applicable law or agreed to in writing, software |
| 179 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 180 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 181 | +See the License for the specific language governing permissions and |
| 182 | +limitations under the License. |
| 183 | + |
0 commit comments