History

perf tools: Add support for printing new mem_info encodings

Add decoding for the new "lvlx" and "snoopx" meminfo fields added earlier to the kernel so that "perf mem report" and other tools can print it properly. v2: Merge with persistent memory patch. Switch to new bit encoding for each combination. v3: Switch to generic lvlnum field.

Andi Kleen committed 9 years ago

Commit 52839e61 parent 41d3d6d2 files · +68 −5Browse files

Unified · Split

2 files
  1. tools/include/uapi/linux/perf_event.h +28 −2
  2. tools/perf/util/mem-events.c +40 −3
tools/include/uapi/linux/perf_event.h+28−2
@@ -954,14 +954,20 @@ union perf_mem_data_src { · 953 unmodified lines
954 mem_snoop:5, /* snoop mode */954 mem_snoop:5, /* snoop mode */
955 mem_lock:2, /* lock instr */955 mem_lock:2, /* lock instr */
956 mem_dtlb:7, /* tlb access */956 mem_dtlb:7, /* tlb access */
957 mem_rsvd:31;957 mem_lvl_num:4, /* memory hierarchy level number */
958 mem_remote:1, /* remote */
959 mem_snoopx:2, /* snoop mode, ext */
960 mem_rsvd:24;
958 };961 };
959};962};
960#elif defined(__BIG_ENDIAN_BITFIELD)963#elif defined(__BIG_ENDIAN_BITFIELD)
961union perf_mem_data_src {964union perf_mem_data_src {
962 __u64 val;965 __u64 val;
963 struct {966 struct {
964 __u64 mem_rsvd:31,967 __u64 mem_rsvd:24,
968 mem_snoopx:2, /* snoop mode, ext */
969 mem_remote:1, /* remote */
970 mem_lvl_num:4, /* memory hierarchy level number */
965 mem_dtlb:7, /* tlb access */971 mem_dtlb:7, /* tlb access */
966 mem_lock:2, /* lock instr */972 mem_lock:2, /* lock instr */
967 mem_snoop:5, /* snoop mode */973 mem_snoop:5, /* snoop mode */
@@ -998,6 +1004,22 @@ union perf_mem_data_src { · 30 unmodified lines
998#define PERF_MEM_LVL_UNC 0x2000 /* Uncached memory */1004#define PERF_MEM_LVL_UNC 0x2000 /* Uncached memory */
999#define PERF_MEM_LVL_SHIFT 51005#define PERF_MEM_LVL_SHIFT 5
1000 1006
1007#define PERF_MEM_REMOTE_REMOTE 0x01 /* Remote */
1008#define PERF_MEM_REMOTE_SHIFT 37
1009
1010#define PERF_MEM_LVLNUM_L1 0x01 /* L1 */
1011#define PERF_MEM_LVLNUM_L2 0x02 /* L2 */
1012#define PERF_MEM_LVLNUM_L3 0x03 /* L3 */
1013#define PERF_MEM_LVLNUM_L4 0x04 /* L4 */
1014/* 5-0xa available */
1015#define PERF_MEM_LVLNUM_ANY_CACHE 0x0b /* Any cache */
1016#define PERF_MEM_LVLNUM_LFB 0x0c /* LFB */
1017#define PERF_MEM_LVLNUM_RAM 0x0d /* RAM */
1018#define PERF_MEM_LVLNUM_PMEM 0x0e /* PMEM */
1019#define PERF_MEM_LVLNUM_NA 0x0f /* N/A */
1020
1021#define PERF_MEM_LVLNUM_SHIFT 33
1022
1001/* snoop mode */1023/* snoop mode */
1002#define PERF_MEM_SNOOP_NA 0x01 /* not available */1024#define PERF_MEM_SNOOP_NA 0x01 /* not available */
1003#define PERF_MEM_SNOOP_NONE 0x02 /* no snoop */1025#define PERF_MEM_SNOOP_NONE 0x02 /* no snoop */
@@ -1006,6 +1028,10 @@ union perf_mem_data_src { · 2 unmodified lines
1006#define PERF_MEM_SNOOP_HITM 0x10 /* snoop hit modified */1028#define PERF_MEM_SNOOP_HITM 0x10 /* snoop hit modified */
1007#define PERF_MEM_SNOOP_SHIFT 191029#define PERF_MEM_SNOOP_SHIFT 19
1008 1030
1031#define PERF_MEM_SNOOPX_FWD 0x01 /* forward */
1032/* 1 free */
1033#define PERF_MEM_SNOOPX_SHIFT 37
1034
1009/* locked instruction */1035/* locked instruction */
1010#define PERF_MEM_LOCK_NA 0x01 /* not available */1036#define PERF_MEM_LOCK_NA 0x01 /* not available */
1011#define PERF_MEM_LOCK_LOCKED 0x02 /* locked transaction */1037#define PERF_MEM_LOCK_LOCKED 0x02 /* locked transaction */
tools/perf/util/mem-events.c+40−3
@@ -166,11 +166,20 @@ static const char * const mem_lvl[] = { · 165 unmodified lines
166 "Uncached",166 "Uncached",
167};167};
168 168
169static const char * const mem_lvlnum[] = {
170 [PERF_MEM_LVLNUM_ANY_CACHE] = "Any cache",
171 [PERF_MEM_LVLNUM_LFB] = "LFB",
172 [PERF_MEM_LVLNUM_RAM] = "RAM",
173 [PERF_MEM_LVLNUM_PMEM] = "PMEM",
174 [PERF_MEM_LVLNUM_NA] = "N/A",
175};
176
169int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)177int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
170{178{
171 size_t i, l = 0;179 size_t i, l = 0;
172 u64 m = PERF_MEM_LVL_NA;180 u64 m = PERF_MEM_LVL_NA;
173 u64 hit, miss;181 u64 hit, miss;
182 int printed;
174 183
175 if (mem_info)184 if (mem_info)
176 m = mem_info->data_src.mem_lvl;185 m = mem_info->data_src.mem_lvl;
@@ -184,17 +193,37 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info) · 7 unmodified lines
184 /* already taken care of */193 /* already taken care of */
185 m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS);194 m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS);
186 195
196
197 if (mem_info && mem_info->data_src.mem_remote) {
198 strcat(out, "Remote ");
199 l += 7;
200 }
201
202 printed = 0;
187 for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) {203 for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) {
188 if (!(m & 0x1))204 if (!(m & 0x1))
189 continue;205 continue;
190 if (l) {206 if (printed++) {
191 strcat(out, " or ");207 strcat(out, " or ");
192 l += 4;208 l += 4;
193 }209 }
194 l += scnprintf(out + l, sz - l, mem_lvl[i]);210 l += scnprintf(out + l, sz - l, mem_lvl[i]);
195 }211 }
196 if (*out == '\0')212
197 l += scnprintf(out, sz - l, "N/A");213 if (mem_info && mem_info->data_src.mem_lvl_num) {
214 int lvl = mem_info->data_src.mem_lvl_num;
215 if (printed++) {
216 strcat(out, " or ");
217 l += 4;
218 }
219 if (mem_lvlnum[lvl])
220 l += scnprintf(out + l, sz - l, mem_lvlnum[lvl]);
221 else
222 l += scnprintf(out + l, sz - l, "L%d", lvl);
223 }
224
225 if (l == 0)
226 l += scnprintf(out + l, sz - l, "N/A");
198 if (hit)227 if (hit)
199 l += scnprintf(out + l, sz - l, " hit");228 l += scnprintf(out + l, sz - l, " hit");
200 if (miss)229 if (miss)
@@ -231,6 +260,14 @@ int perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info) · 30 unmodified lines
231 }260 }
232 l += scnprintf(out + l, sz - l, snoop_access[i]);261 l += scnprintf(out + l, sz - l, snoop_access[i]);
233 }262 }
263 if (mem_info &&
264 (mem_info->data_src.mem_snoopx & PERF_MEM_SNOOPX_FWD)) {
265 if (l) {
266 strcat(out, " or ");
267 l += 4;
268 }
269 l += scnprintf(out + l, sz - l, "Fwd");
270 }
234 271
235 if (*out == '\0')272 if (*out == '\0')
236 l += scnprintf(out, sz - l, "N/A");273 l += scnprintf(out, sz - l, "N/A");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t