builtin-mem.c (407ee5c920dfead7b3fcff0644843c2f84d24245) | builtin-mem.c (06280e3b15fdaa28f02d995c0a74ec46f75db90a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2#include <inttypes.h> 3#include <sys/types.h> 4#include <sys/stat.h> 5#include <unistd.h> 6#include "builtin.h" 7#include "perf.h" 8 --- 16 unchanged lines hidden (view full) --- 25 26struct perf_mem { 27 struct perf_tool tool; 28 char const *input_name; 29 bool hide_unresolved; 30 bool dump_raw; 31 bool force; 32 bool phys_addr; | 1// SPDX-License-Identifier: GPL-2.0 2#include <inttypes.h> 3#include <sys/types.h> 4#include <sys/stat.h> 5#include <unistd.h> 6#include "builtin.h" 7#include "perf.h" 8 --- 16 unchanged lines hidden (view full) --- 25 26struct perf_mem { 27 struct perf_tool tool; 28 char const *input_name; 29 bool hide_unresolved; 30 bool dump_raw; 31 bool force; 32 bool phys_addr; |
33 bool data_page_size; |
|
33 int operation; 34 const char *cpu_list; 35 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 36}; 37 38static int parse_record_events(const struct option *opt, 39 const char *str, int unset __maybe_unused) 40{ --- 78 unchanged lines hidden (view full) --- 119 if (e->record) 120 rec_argv[i++] = "-W"; 121 122 rec_argv[i++] = "-d"; 123 124 if (mem->phys_addr) 125 rec_argv[i++] = "--phys-data"; 126 | 34 int operation; 35 const char *cpu_list; 36 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 37}; 38 39static int parse_record_events(const struct option *opt, 40 const char *str, int unset __maybe_unused) 41{ --- 78 unchanged lines hidden (view full) --- 120 if (e->record) 121 rec_argv[i++] = "-W"; 122 123 rec_argv[i++] = "-d"; 124 125 if (mem->phys_addr) 126 rec_argv[i++] = "--phys-data"; 127 |
128 if (mem->data_page_size) 129 rec_argv[i++] = "--data-page-size"; 130 |
|
127 for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { 128 e = perf_mem_events__ptr(j); 129 if (!e->record) 130 continue; 131 132 if (!e->supported) { 133 pr_err("failed: event '%s' not supported\n", 134 perf_mem_events__name(j)); --- 33 unchanged lines hidden (view full) --- 168dump_raw_samples(struct perf_tool *tool, 169 union perf_event *event, 170 struct perf_sample *sample, 171 struct machine *machine) 172{ 173 struct perf_mem *mem = container_of(tool, struct perf_mem, tool); 174 struct addr_location al; 175 const char *fmt, *field_sep; | 131 for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { 132 e = perf_mem_events__ptr(j); 133 if (!e->record) 134 continue; 135 136 if (!e->supported) { 137 pr_err("failed: event '%s' not supported\n", 138 perf_mem_events__name(j)); --- 33 unchanged lines hidden (view full) --- 172dump_raw_samples(struct perf_tool *tool, 173 union perf_event *event, 174 struct perf_sample *sample, 175 struct machine *machine) 176{ 177 struct perf_mem *mem = container_of(tool, struct perf_mem, tool); 178 struct addr_location al; 179 const char *fmt, *field_sep; |
180 char str[PAGE_SIZE_NAME_LEN]; |
|
176 177 if (machine__resolve(machine, &al, sample) < 0) { 178 fprintf(stderr, "problem processing %d event, skipping it.\n", 179 event->header.type); 180 return -1; 181 } 182 183 if (al.filtered || (mem->hide_unresolved && al.sym == NULL)) --- 20 unchanged lines hidden (view full) --- 204 symbol_conf.field_sep); 205 206 if (mem->phys_addr) { 207 printf("0x%016"PRIx64"%s", 208 sample->phys_addr, 209 symbol_conf.field_sep); 210 } 211 | 181 182 if (machine__resolve(machine, &al, sample) < 0) { 183 fprintf(stderr, "problem processing %d event, skipping it.\n", 184 event->header.type); 185 return -1; 186 } 187 188 if (al.filtered || (mem->hide_unresolved && al.sym == NULL)) --- 20 unchanged lines hidden (view full) --- 209 symbol_conf.field_sep); 210 211 if (mem->phys_addr) { 212 printf("0x%016"PRIx64"%s", 213 sample->phys_addr, 214 symbol_conf.field_sep); 215 } 216 |
217 if (mem->data_page_size) { 218 printf("%s%s", 219 get_page_size_name(sample->data_page_size, str), 220 symbol_conf.field_sep); 221 } 222 |
|
212 if (field_sep) 213 fmt = "%"PRIu64"%s0x%"PRIx64"%s%s:%s\n"; 214 else 215 fmt = "%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n"; 216 217 printf(fmt, 218 sample->weight, 219 symbol_conf.field_sep, --- 48 unchanged lines hidden (view full) --- 268 if (ret < 0) 269 goto out_delete; 270 271 printf("# PID, TID, IP, ADDR, "); 272 273 if (mem->phys_addr) 274 printf("PHYS ADDR, "); 275 | 223 if (field_sep) 224 fmt = "%"PRIu64"%s0x%"PRIx64"%s%s:%s\n"; 225 else 226 fmt = "%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n"; 227 228 printf(fmt, 229 sample->weight, 230 symbol_conf.field_sep, --- 48 unchanged lines hidden (view full) --- 279 if (ret < 0) 280 goto out_delete; 281 282 printf("# PID, TID, IP, ADDR, "); 283 284 if (mem->phys_addr) 285 printf("PHYS ADDR, "); 286 |
287 if (mem->data_page_size) 288 printf("DATA PAGE SIZE, "); 289 |
|
276 printf("LOCAL WEIGHT, DSRC, SYMBOL\n"); 277 278 ret = perf_session__process_events(session); 279 280out_delete: 281 perf_session__delete(session); 282 return ret; 283} 284static char *get_sort_order(struct perf_mem *mem) 285{ | 290 printf("LOCAL WEIGHT, DSRC, SYMBOL\n"); 291 292 ret = perf_session__process_events(session); 293 294out_delete: 295 perf_session__delete(session); 296 return ret; 297} 298static char *get_sort_order(struct perf_mem *mem) 299{ |
286 bool has_extra_options = mem->phys_addr ? true : false; | 300 bool has_extra_options = (mem->phys_addr | mem->data_page_size) ? true : false; |
287 char sort[128]; 288 289 /* 290 * there is no weight (cost) associated with stores, so don't print 291 * the column 292 */ 293 if (!(mem->operation & MEM_OPERATION_LOAD)) { 294 strcpy(sort, "--sort=mem,sym,dso,symbol_daddr," 295 "dso_daddr,tlb,locked"); 296 } else if (has_extra_options) { 297 strcpy(sort, "--sort=local_weight,mem,sym,dso,symbol_daddr," 298 "dso_daddr,snoop,tlb,locked"); 299 } else 300 return NULL; 301 302 if (mem->phys_addr) 303 strcat(sort, ",phys_daddr"); 304 | 301 char sort[128]; 302 303 /* 304 * there is no weight (cost) associated with stores, so don't print 305 * the column 306 */ 307 if (!(mem->operation & MEM_OPERATION_LOAD)) { 308 strcpy(sort, "--sort=mem,sym,dso,symbol_daddr," 309 "dso_daddr,tlb,locked"); 310 } else if (has_extra_options) { 311 strcpy(sort, "--sort=local_weight,mem,sym,dso,symbol_daddr," 312 "dso_daddr,snoop,tlb,locked"); 313 } else 314 return NULL; 315 316 if (mem->phys_addr) 317 strcat(sort, ",phys_daddr"); 318 |
319 if (mem->data_page_size) 320 strcat(sort, ",data_page_size"); 321 |
|
305 return strdup(sort); 306} 307 308static int report_events(int argc, const char **argv, struct perf_mem *mem) 309{ 310 const char **rep_argv; 311 int ret, i = 0, j, rep_argc; 312 char *new_sort_order; --- 129 unchanged lines hidden (view full) --- 442 OPT_STRING('C', "cpu", &mem.cpu_list, "cpu", 443 "list of cpus to profile"), 444 OPT_STRING_NOEMPTY('x', "field-separator", &symbol_conf.field_sep, 445 "separator", 446 "separator for columns, no spaces will be added" 447 " between columns '.' is reserved."), 448 OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"), 449 OPT_BOOLEAN('p', "phys-data", &mem.phys_addr, "Record/Report sample physical addresses"), | 322 return strdup(sort); 323} 324 325static int report_events(int argc, const char **argv, struct perf_mem *mem) 326{ 327 const char **rep_argv; 328 int ret, i = 0, j, rep_argc; 329 char *new_sort_order; --- 129 unchanged lines hidden (view full) --- 459 OPT_STRING('C', "cpu", &mem.cpu_list, "cpu", 460 "list of cpus to profile"), 461 OPT_STRING_NOEMPTY('x', "field-separator", &symbol_conf.field_sep, 462 "separator", 463 "separator for columns, no spaces will be added" 464 " between columns '.' is reserved."), 465 OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"), 466 OPT_BOOLEAN('p', "phys-data", &mem.phys_addr, "Record/Report sample physical addresses"), |
467 OPT_BOOLEAN(0, "data-page-size", &mem.data_page_size, "Record/Report sample data address page size"), |
|
450 OPT_END() 451 }; 452 const char *const mem_subcommands[] = { "record", "report", NULL }; 453 const char *mem_usage[] = { 454 NULL, 455 NULL 456 }; 457 --- 22 unchanged lines hidden --- | 468 OPT_END() 469 }; 470 const char *const mem_subcommands[] = { "record", "report", NULL }; 471 const char *mem_usage[] = { 472 NULL, 473 NULL 474 }; 475 --- 22 unchanged lines hidden --- |