aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2016-07-14 04:34:43 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-07-15 16:27:50 -0400
commit057374645bd42e8bcf22aa4529f99cf7c920a1c6 (patch)
tree5fd80fb8cbfe69ec76253a956cf0d3391fff76bb /tools/perf/builtin-record.c
parent54cc54decd79b2c92f4db06001b4b245f38181b7 (diff)
perf record: Read from overwritable ring buffer
Drive the evlist->bkw_mmap_state state machine during draining and when SIGUSR2 is received. Read the backward ring buffer in record__mmap_read_all. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Nilay Vaish <nilayvaish@gmail.com> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1468485287-33422-12-git-send-email-wangnan0@huawei.com Signed-off-by: He Kuang <hekuang@huawei.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index d4f15e76c98a..b87070b1f492 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -555,7 +555,7 @@ static int record__mmap_read_all(struct record *rec)
555 if (err) 555 if (err)
556 return err; 556 return err;
557 557
558 return err; 558 return record__mmap_read_evlist(rec, rec->evlist, true);
559} 559}
560 560
561static void record__init_features(struct record *rec) 561static void record__init_features(struct record *rec)
@@ -953,6 +953,17 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
953 for (;;) { 953 for (;;) {
954 unsigned long long hits = rec->samples; 954 unsigned long long hits = rec->samples;
955 955
956 /*
957 * rec->evlist->bkw_mmap_state is possible to be
958 * BKW_MMAP_EMPTY here: when done == true and
959 * hits != rec->samples in previous round.
960 *
961 * perf_evlist__toggle_bkw_mmap ensure we never
962 * convert BKW_MMAP_EMPTY to BKW_MMAP_DATA_PENDING.
963 */
964 if (trigger_is_hit(&switch_output_trigger) || done || draining)
965 perf_evlist__toggle_bkw_mmap(rec->evlist, BKW_MMAP_DATA_PENDING);
966
956 if (record__mmap_read_all(rec) < 0) { 967 if (record__mmap_read_all(rec) < 0) {
957 trigger_error(&auxtrace_snapshot_trigger); 968 trigger_error(&auxtrace_snapshot_trigger);
958 trigger_error(&switch_output_trigger); 969 trigger_error(&switch_output_trigger);
@@ -972,8 +983,26 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
972 } 983 }
973 984
974 if (trigger_is_hit(&switch_output_trigger)) { 985 if (trigger_is_hit(&switch_output_trigger)) {
986 /*
987 * If switch_output_trigger is hit, the data in
988 * overwritable ring buffer should have been collected,
989 * so bkw_mmap_state should be set to BKW_MMAP_EMPTY.
990 *
991 * If SIGUSR2 raise after or during record__mmap_read_all(),
992 * record__mmap_read_all() didn't collect data from
993 * overwritable ring buffer. Read again.
994 */
995 if (rec->evlist->bkw_mmap_state == BKW_MMAP_RUNNING)
996 continue;
975 trigger_ready(&switch_output_trigger); 997 trigger_ready(&switch_output_trigger);
976 998
999 /*
1000 * Reenable events in overwrite ring buffer after
1001 * record__mmap_read_all(): we should have collected
1002 * data from it.
1003 */
1004 perf_evlist__toggle_bkw_mmap(rec->evlist, BKW_MMAP_RUNNING);
1005
977 if (!quiet) 1006 if (!quiet)
978 fprintf(stderr, "[ perf record: dump data: Woken up %ld times ]\n", 1007 fprintf(stderr, "[ perf record: dump data: Woken up %ld times ]\n",
979 waking); 1008 waking);