Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit52839e6

Browse files
Andi Kleenacmel
Andi Kleen
authored andcommitted
perf tools: Add support for printing new mem_info encodings
Add decoding for the new "lvlx" and "snoopx" meminfo fields addedearlier to the kernel so that "perf mem report" and other tools canprint it properly.v2: Merge with persistent memory patch.Switch to new bit encoding for each combination.v3: Switch to generic lvlnum field.Signed-off-by: Andi Kleen <ak@linux.intel.com>Acked-by: Peter Zijlstra <peterz@infradead.org>Cc: Jiri Olsa <jolsa@kernel.org>Link:http://lkml.kernel.org/r/20170816222156.19953-4-andi@firstfloor.orgSigned-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent41d3d6d commit52839e6

File tree

2 files changed

+68
-5
lines changed

2 files changed

+68
-5
lines changed

‎tools/include/uapi/linux/perf_event.h‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,14 +954,20 @@ union perf_mem_data_src {
954954
mem_snoop:5,/* snoop mode */
955955
mem_lock:2,/* lock instr */
956956
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;
958961
};
959962
};
960963
#elif defined(__BIG_ENDIAN_BITFIELD)
961964
unionperf_mem_data_src {
962965
__u64val;
963966
struct {
964-
__u64mem_rsvd:31,
967+
__u64mem_rsvd:24,
968+
mem_snoopx:2,/* snoop mode, ext */
969+
mem_remote:1,/* remote */
970+
mem_lvl_num:4,/* memory hierarchy level number */
965971
mem_dtlb:7,/* tlb access */
966972
mem_lock:2,/* lock instr */
967973
mem_snoop:5,/* snoop mode */
@@ -998,6 +1004,22 @@ union perf_mem_data_src {
9981004
#definePERF_MEM_LVL_UNC0x2000/* Uncached memory */
9991005
#definePERF_MEM_LVL_SHIFT5
10001006

1007+
#definePERF_MEM_REMOTE_REMOTE0x01/* Remote */
1008+
#definePERF_MEM_REMOTE_SHIFT37
1009+
1010+
#definePERF_MEM_LVLNUM_L10x01/* L1 */
1011+
#definePERF_MEM_LVLNUM_L20x02/* L2 */
1012+
#definePERF_MEM_LVLNUM_L30x03/* L3 */
1013+
#definePERF_MEM_LVLNUM_L40x04/* L4 */
1014+
/* 5-0xa available */
1015+
#definePERF_MEM_LVLNUM_ANY_CACHE 0x0b/* Any cache */
1016+
#definePERF_MEM_LVLNUM_LFB0x0c/* LFB */
1017+
#definePERF_MEM_LVLNUM_RAM0x0d/* RAM */
1018+
#definePERF_MEM_LVLNUM_PMEM0x0e/* PMEM */
1019+
#definePERF_MEM_LVLNUM_NA0x0f/* N/A */
1020+
1021+
#definePERF_MEM_LVLNUM_SHIFT33
1022+
10011023
/* snoop mode */
10021024
#definePERF_MEM_SNOOP_NA0x01/* not available */
10031025
#definePERF_MEM_SNOOP_NONE0x02/* no snoop */
@@ -1006,6 +1028,10 @@ union perf_mem_data_src {
10061028
#definePERF_MEM_SNOOP_HITM0x10/* snoop hit modified */
10071029
#definePERF_MEM_SNOOP_SHIFT19
10081030

1031+
#definePERF_MEM_SNOOPX_FWD0x01/* forward */
1032+
/* 1 free */
1033+
#definePERF_MEM_SNOOPX_SHIFT37
1034+
10091035
/* locked instruction */
10101036
#definePERF_MEM_LOCK_NA0x01/* not available */
10111037
#definePERF_MEM_LOCK_LOCKED0x02/* locked transaction */

‎tools/perf/util/mem-events.c‎

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,20 @@ static const char * const mem_lvl[] = {
166166
"Uncached",
167167
};
168168

169+
staticconstchar*constmem_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+
169177
intperf_mem__lvl_scnprintf(char*out,size_tsz,structmem_info*mem_info)
170178
{
171179
size_ti,l=0;
172180
u64m=PERF_MEM_LVL_NA;
173181
u64hit,miss;
182+
intprinted;
174183

175184
if (mem_info)
176185
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)
184193
/* already taken care of */
185194
m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS);
186195

196+
197+
if (mem_info&&mem_info->data_src.mem_remote) {
198+
strcat(out,"Remote ");
199+
l+=7;
200+
}
201+
202+
printed=0;
187203
for (i=0;m&&i<ARRAY_SIZE(mem_lvl);i++,m >>=1) {
188204
if (!(m&0x1))
189205
continue;
190-
if (l) {
206+
if (printed++) {
191207
strcat(out," or ");
192208
l+=4;
193209
}
194210
l+=scnprintf(out+l,sz-l,mem_lvl[i]);
195211
}
196-
if (*out=='\0')
197-
l+=scnprintf(out,sz-l,"N/A");
212+
213+
if (mem_info&&mem_info->data_src.mem_lvl_num) {
214+
intlvl=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");
198227
if (hit)
199228
l+=scnprintf(out+l,sz-l," hit");
200229
if (miss)
@@ -231,6 +260,14 @@ int perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
231260
}
232261
l+=scnprintf(out+l,sz-l,snoop_access[i]);
233262
}
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+
}
234271

235272
if (*out=='\0')
236273
l+=scnprintf(out,sz-l,"N/A");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp