diff options
-rw-r--r-- | tools/perf/builtin-sched.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index e00e2eaf89da..a3ebf1d3c29d 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1439,8 +1439,7 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_ | |||
1439 | return err; | 1439 | return err; |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | static int perf_sched__read_events(struct perf_sched *sched, | 1442 | static int perf_sched__read_events(struct perf_sched *sched) |
1443 | struct perf_session **psession) | ||
1444 | { | 1443 | { |
1445 | const struct perf_evsel_str_handler handlers[] = { | 1444 | const struct perf_evsel_str_handler handlers[] = { |
1446 | { "sched:sched_switch", process_sched_switch_event, }, | 1445 | { "sched:sched_switch", process_sched_switch_event, }, |
@@ -1454,6 +1453,7 @@ static int perf_sched__read_events(struct perf_sched *sched, | |||
1454 | .path = input_name, | 1453 | .path = input_name, |
1455 | .mode = PERF_DATA_MODE_READ, | 1454 | .mode = PERF_DATA_MODE_READ, |
1456 | }; | 1455 | }; |
1456 | int rc = -1; | ||
1457 | 1457 | ||
1458 | session = perf_session__new(&file, false, &sched->tool); | 1458 | session = perf_session__new(&file, false, &sched->tool); |
1459 | if (session == NULL) { | 1459 | if (session == NULL) { |
@@ -1478,16 +1478,10 @@ static int perf_sched__read_events(struct perf_sched *sched, | |||
1478 | sched->nr_lost_chunks = session->evlist->stats.nr_events[PERF_RECORD_LOST]; | 1478 | sched->nr_lost_chunks = session->evlist->stats.nr_events[PERF_RECORD_LOST]; |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | if (psession) | 1481 | rc = 0; |
1482 | *psession = session; | ||
1483 | else | ||
1484 | perf_session__delete(session); | ||
1485 | |||
1486 | return 0; | ||
1487 | |||
1488 | out_delete: | 1482 | out_delete: |
1489 | perf_session__delete(session); | 1483 | perf_session__delete(session); |
1490 | return -1; | 1484 | return rc; |
1491 | } | 1485 | } |
1492 | 1486 | ||
1493 | static void print_bad_events(struct perf_sched *sched) | 1487 | static void print_bad_events(struct perf_sched *sched) |
@@ -1515,12 +1509,10 @@ static void print_bad_events(struct perf_sched *sched) | |||
1515 | static int perf_sched__lat(struct perf_sched *sched) | 1509 | static int perf_sched__lat(struct perf_sched *sched) |
1516 | { | 1510 | { |
1517 | struct rb_node *next; | 1511 | struct rb_node *next; |
1518 | struct perf_session *session; | ||
1519 | 1512 | ||
1520 | setup_pager(); | 1513 | setup_pager(); |
1521 | 1514 | ||
1522 | /* save session -- references to threads are held in work_list */ | 1515 | if (perf_sched__read_events(sched)) |
1523 | if (perf_sched__read_events(sched, &session)) | ||
1524 | return -1; | 1516 | return -1; |
1525 | 1517 | ||
1526 | perf_sched__sort_lat(sched); | 1518 | perf_sched__sort_lat(sched); |
@@ -1537,6 +1529,7 @@ static int perf_sched__lat(struct perf_sched *sched) | |||
1537 | work_list = rb_entry(next, struct work_atoms, node); | 1529 | work_list = rb_entry(next, struct work_atoms, node); |
1538 | output_lat_thread(sched, work_list); | 1530 | output_lat_thread(sched, work_list); |
1539 | next = rb_next(next); | 1531 | next = rb_next(next); |
1532 | thread__zput(work_list->thread); | ||
1540 | } | 1533 | } |
1541 | 1534 | ||
1542 | printf(" -----------------------------------------------------------------------------------------------------------------\n"); | 1535 | printf(" -----------------------------------------------------------------------------------------------------------------\n"); |
@@ -1548,7 +1541,6 @@ static int perf_sched__lat(struct perf_sched *sched) | |||
1548 | print_bad_events(sched); | 1541 | print_bad_events(sched); |
1549 | printf("\n"); | 1542 | printf("\n"); |
1550 | 1543 | ||
1551 | perf_session__delete(session); | ||
1552 | return 0; | 1544 | return 0; |
1553 | } | 1545 | } |
1554 | 1546 | ||
@@ -1557,7 +1549,7 @@ static int perf_sched__map(struct perf_sched *sched) | |||
1557 | sched->max_cpu = sysconf(_SC_NPROCESSORS_CONF); | 1549 | sched->max_cpu = sysconf(_SC_NPROCESSORS_CONF); |
1558 | 1550 | ||
1559 | setup_pager(); | 1551 | setup_pager(); |
1560 | if (perf_sched__read_events(sched, NULL)) | 1552 | if (perf_sched__read_events(sched)) |
1561 | return -1; | 1553 | return -1; |
1562 | print_bad_events(sched); | 1554 | print_bad_events(sched); |
1563 | return 0; | 1555 | return 0; |
@@ -1572,7 +1564,7 @@ static int perf_sched__replay(struct perf_sched *sched) | |||
1572 | 1564 | ||
1573 | test_calibrations(sched); | 1565 | test_calibrations(sched); |
1574 | 1566 | ||
1575 | if (perf_sched__read_events(sched, NULL)) | 1567 | if (perf_sched__read_events(sched)) |
1576 | return -1; | 1568 | return -1; |
1577 | 1569 | ||
1578 | printf("nr_run_events: %ld\n", sched->nr_run_events); | 1570 | printf("nr_run_events: %ld\n", sched->nr_run_events); |