aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-record.c20
-rw-r--r--tools/perf/builtin-report.c29
2 files changed, 44 insertions, 5 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index e1dfef24887f..06fdfb8b4828 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -78,10 +78,10 @@ struct mmap_data {
78 78
79static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS]; 79static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
80 80
81static unsigned int mmap_read_head(struct mmap_data *md) 81static unsigned long mmap_read_head(struct mmap_data *md)
82{ 82{
83 struct perf_counter_mmap_page *pc = md->base; 83 struct perf_counter_mmap_page *pc = md->base;
84 int head; 84 long head;
85 85
86 head = pc->data_head; 86 head = pc->data_head;
87 rmb(); 87 rmb();
@@ -89,6 +89,17 @@ static unsigned int mmap_read_head(struct mmap_data *md)
89 return head; 89 return head;
90} 90}
91 91
92static void mmap_write_tail(struct mmap_data *md, unsigned long tail)
93{
94 struct perf_counter_mmap_page *pc = md->base;
95
96 /*
97 * ensure all reads are done before we write the tail out.
98 */
99 /* mb(); */
100 pc->data_tail = tail;
101}
102
92static void mmap_read(struct mmap_data *md) 103static void mmap_read(struct mmap_data *md)
93{ 104{
94 unsigned int head = mmap_read_head(md); 105 unsigned int head = mmap_read_head(md);
@@ -109,7 +120,7 @@ static void mmap_read(struct mmap_data *md)
109 * In either case, truncate and restart at head. 120 * In either case, truncate and restart at head.
110 */ 121 */
111 diff = head - old; 122 diff = head - old;
112 if (diff > md->mask / 2 || diff < 0) { 123 if (diff < 0) {
113 struct timeval iv; 124 struct timeval iv;
114 unsigned long msecs; 125 unsigned long msecs;
115 126
@@ -167,6 +178,7 @@ static void mmap_read(struct mmap_data *md)
167 } 178 }
168 179
169 md->prev = old; 180 md->prev = old;
181 mmap_write_tail(md, old);
170} 182}
171 183
172static volatile int done = 0; 184static volatile int done = 0;
@@ -424,7 +436,7 @@ try_again:
424 mmap_array[nr_cpu][counter].prev = 0; 436 mmap_array[nr_cpu][counter].prev = 0;
425 mmap_array[nr_cpu][counter].mask = mmap_pages*page_size - 1; 437 mmap_array[nr_cpu][counter].mask = mmap_pages*page_size - 1;
426 mmap_array[nr_cpu][counter].base = mmap(NULL, (mmap_pages+1)*page_size, 438 mmap_array[nr_cpu][counter].base = mmap(NULL, (mmap_pages+1)*page_size,
427 PROT_READ, MAP_SHARED, fd[nr_cpu][counter], 0); 439 PROT_READ|PROT_WRITE, MAP_SHARED, fd[nr_cpu][counter], 0);
428 if (mmap_array[nr_cpu][counter].base == MAP_FAILED) { 440 if (mmap_array[nr_cpu][counter].base == MAP_FAILED) {
429 error("failed to mmap with %d (%s)\n", errno, strerror(errno)); 441 error("failed to mmap with %d (%s)\n", errno, strerror(errno));
430 exit(-1); 442 exit(-1);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 9a3805f0c9f2..fe66895111b1 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -83,6 +83,12 @@ struct period_event {
83 __u64 sample_period; 83 __u64 sample_period;
84}; 84};
85 85
86struct lost_event {
87 struct perf_event_header header;
88 __u64 id;
89 __u64 lost;
90};
91
86typedef union event_union { 92typedef union event_union {
87 struct perf_event_header header; 93 struct perf_event_header header;
88 struct ip_event ip; 94 struct ip_event ip;
@@ -90,6 +96,7 @@ typedef union event_union {
90 struct comm_event comm; 96 struct comm_event comm;
91 struct fork_event fork; 97 struct fork_event fork;
92 struct period_event period; 98 struct period_event period;
99 struct lost_event lost;
93} event_t; 100} event_t;
94 101
95static LIST_HEAD(dsos); 102static LIST_HEAD(dsos);
@@ -1068,7 +1075,8 @@ static unsigned long total = 0,
1068 total_mmap = 0, 1075 total_mmap = 0,
1069 total_comm = 0, 1076 total_comm = 0,
1070 total_fork = 0, 1077 total_fork = 0,
1071 total_unknown = 0; 1078 total_unknown = 0,
1079 total_lost = 0;
1072 1080
1073static int validate_chain(struct perf_callchain_entry *chain, event_t *event) 1081static int validate_chain(struct perf_callchain_entry *chain, event_t *event)
1074{ 1082{
@@ -1260,6 +1268,20 @@ process_period_event(event_t *event, unsigned long offset, unsigned long head)
1260 return 0; 1268 return 0;
1261} 1269}
1262 1270
1271static int
1272process_lost_event(event_t *event, unsigned long offset, unsigned long head)
1273{
1274 dprintf("%p [%p]: PERF_EVENT_LOST: id:%Ld: lost:%Ld\n",
1275 (void *)(offset + head),
1276 (void *)(long)(event->header.size),
1277 event->lost.id,
1278 event->lost.lost);
1279
1280 total_lost += event->lost.lost;
1281
1282 return 0;
1283}
1284
1263static void trace_event(event_t *event) 1285static void trace_event(event_t *event)
1264{ 1286{
1265 unsigned char *raw_event = (void *)event; 1287 unsigned char *raw_event = (void *)event;
@@ -1316,6 +1338,10 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1316 1338
1317 case PERF_EVENT_PERIOD: 1339 case PERF_EVENT_PERIOD:
1318 return process_period_event(event, offset, head); 1340 return process_period_event(event, offset, head);
1341
1342 case PERF_EVENT_LOST:
1343 return process_lost_event(event, offset, head);
1344
1319 /* 1345 /*
1320 * We dont process them right now but they are fine: 1346 * We dont process them right now but they are fine:
1321 */ 1347 */
@@ -1444,6 +1470,7 @@ more:
1444 dprintf(" mmap events: %10ld\n", total_mmap); 1470 dprintf(" mmap events: %10ld\n", total_mmap);
1445 dprintf(" comm events: %10ld\n", total_comm); 1471 dprintf(" comm events: %10ld\n", total_comm);
1446 dprintf(" fork events: %10ld\n", total_fork); 1472 dprintf(" fork events: %10ld\n", total_fork);
1473 dprintf(" lost events: %10ld\n", total_lost);
1447 dprintf(" unknown events: %10ld\n", total_unknown); 1474 dprintf(" unknown events: %10ld\n", total_unknown);
1448 1475
1449 if (dump_trace) 1476 if (dump_trace)