diff options
author | Kan Liang <kan.liang@intel.com> | 2014-12-02 10:06:53 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-12-09 08:06:29 -0500 |
commit | 2e77784bb7d882647c33d8e75a650625e6df0f8b (patch) | |
tree | 8b2eca2e80b1dceebab1d6a72249ef7f90d85a64 | |
parent | f70b4e39de4ef25aade966c0dfc69cfb97091be9 (diff) |
perf callchain: Move cpumode resolve code to add_callchain_ip
Using flag to distinguish between branch_history and normal callchain.
Move the cpumode to add_callchain_ip function.
No change in behavior.
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1417532814-26208-3-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/machine.c | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 15dd0a9691ce..94de3e48b490 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -1385,19 +1385,46 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample, | |||
1385 | static int add_callchain_ip(struct thread *thread, | 1385 | static int add_callchain_ip(struct thread *thread, |
1386 | struct symbol **parent, | 1386 | struct symbol **parent, |
1387 | struct addr_location *root_al, | 1387 | struct addr_location *root_al, |
1388 | int cpumode, | 1388 | bool branch_history, |
1389 | u64 ip) | 1389 | u64 ip) |
1390 | { | 1390 | { |
1391 | struct addr_location al; | 1391 | struct addr_location al; |
1392 | 1392 | ||
1393 | al.filtered = 0; | 1393 | al.filtered = 0; |
1394 | al.sym = NULL; | 1394 | al.sym = NULL; |
1395 | if (cpumode == -1) | 1395 | if (branch_history) |
1396 | thread__find_cpumode_addr_location(thread, MAP__FUNCTION, | 1396 | thread__find_cpumode_addr_location(thread, MAP__FUNCTION, |
1397 | ip, &al); | 1397 | ip, &al); |
1398 | else | 1398 | else { |
1399 | u8 cpumode = PERF_RECORD_MISC_USER; | ||
1400 | |||
1401 | if (ip >= PERF_CONTEXT_MAX) { | ||
1402 | switch (ip) { | ||
1403 | case PERF_CONTEXT_HV: | ||
1404 | cpumode = PERF_RECORD_MISC_HYPERVISOR; | ||
1405 | break; | ||
1406 | case PERF_CONTEXT_KERNEL: | ||
1407 | cpumode = PERF_RECORD_MISC_KERNEL; | ||
1408 | break; | ||
1409 | case PERF_CONTEXT_USER: | ||
1410 | cpumode = PERF_RECORD_MISC_USER; | ||
1411 | break; | ||
1412 | default: | ||
1413 | pr_debug("invalid callchain context: " | ||
1414 | "%"PRId64"\n", (s64) ip); | ||
1415 | /* | ||
1416 | * It seems the callchain is corrupted. | ||
1417 | * Discard all. | ||
1418 | */ | ||
1419 | callchain_cursor_reset(&callchain_cursor); | ||
1420 | return 1; | ||
1421 | } | ||
1422 | return 0; | ||
1423 | } | ||
1399 | thread__find_addr_location(thread, cpumode, MAP__FUNCTION, | 1424 | thread__find_addr_location(thread, cpumode, MAP__FUNCTION, |
1400 | ip, &al); | 1425 | ip, &al); |
1426 | } | ||
1427 | |||
1401 | if (al.sym != NULL) { | 1428 | if (al.sym != NULL) { |
1402 | if (sort__has_parent && !*parent && | 1429 | if (sort__has_parent && !*parent && |
1403 | symbol__match_regex(al.sym, &parent_regex)) | 1430 | symbol__match_regex(al.sym, &parent_regex)) |
@@ -1480,11 +1507,8 @@ static int thread__resolve_callchain_sample(struct thread *thread, | |||
1480 | struct addr_location *root_al, | 1507 | struct addr_location *root_al, |
1481 | int max_stack) | 1508 | int max_stack) |
1482 | { | 1509 | { |
1483 | u8 cpumode = PERF_RECORD_MISC_USER; | ||
1484 | int chain_nr = min(max_stack, (int)chain->nr); | 1510 | int chain_nr = min(max_stack, (int)chain->nr); |
1485 | int i; | 1511 | int i, j, err; |
1486 | int j; | ||
1487 | int err; | ||
1488 | int skip_idx = -1; | 1512 | int skip_idx = -1; |
1489 | int first_call = 0; | 1513 | int first_call = 0; |
1490 | 1514 | ||
@@ -1542,10 +1566,10 @@ static int thread__resolve_callchain_sample(struct thread *thread, | |||
1542 | 1566 | ||
1543 | for (i = 0; i < nr; i++) { | 1567 | for (i = 0; i < nr; i++) { |
1544 | err = add_callchain_ip(thread, parent, root_al, | 1568 | err = add_callchain_ip(thread, parent, root_al, |
1545 | -1, be[i].to); | 1569 | true, be[i].to); |
1546 | if (!err) | 1570 | if (!err) |
1547 | err = add_callchain_ip(thread, parent, root_al, | 1571 | err = add_callchain_ip(thread, parent, root_al, |
1548 | -1, be[i].from); | 1572 | true, be[i].from); |
1549 | if (err == -EINVAL) | 1573 | if (err == -EINVAL) |
1550 | break; | 1574 | break; |
1551 | if (err) | 1575 | if (err) |
@@ -1574,36 +1598,10 @@ check_calls: | |||
1574 | #endif | 1598 | #endif |
1575 | ip = chain->ips[j]; | 1599 | ip = chain->ips[j]; |
1576 | 1600 | ||
1577 | if (ip >= PERF_CONTEXT_MAX) { | 1601 | err = add_callchain_ip(thread, parent, root_al, false, ip); |
1578 | switch (ip) { | ||
1579 | case PERF_CONTEXT_HV: | ||
1580 | cpumode = PERF_RECORD_MISC_HYPERVISOR; | ||
1581 | break; | ||
1582 | case PERF_CONTEXT_KERNEL: | ||
1583 | cpumode = PERF_RECORD_MISC_KERNEL; | ||
1584 | break; | ||
1585 | case PERF_CONTEXT_USER: | ||
1586 | cpumode = PERF_RECORD_MISC_USER; | ||
1587 | break; | ||
1588 | default: | ||
1589 | pr_debug("invalid callchain context: " | ||
1590 | "%"PRId64"\n", (s64) ip); | ||
1591 | /* | ||
1592 | * It seems the callchain is corrupted. | ||
1593 | * Discard all. | ||
1594 | */ | ||
1595 | callchain_cursor_reset(&callchain_cursor); | ||
1596 | return 0; | ||
1597 | } | ||
1598 | continue; | ||
1599 | } | ||
1600 | 1602 | ||
1601 | err = add_callchain_ip(thread, parent, root_al, | ||
1602 | cpumode, ip); | ||
1603 | if (err == -EINVAL) | ||
1604 | break; | ||
1605 | if (err) | 1603 | if (err) |
1606 | return err; | 1604 | return (err < 0) ? err : 0; |
1607 | } | 1605 | } |
1608 | 1606 | ||
1609 | return 0; | 1607 | return 0; |