static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
-static unsigned int mmap_read_head(struct mmap_data *md)
+static unsigned long mmap_read_head(struct mmap_data *md)
{
struct perf_counter_mmap_page *pc = md->base;
- int head;
+ long head;
head = pc->data_head;
rmb();
return head;
}
+static void mmap_write_tail(struct mmap_data *md, unsigned long tail)
+{
+ struct perf_counter_mmap_page *pc = md->base;
+
+ /*
+ * ensure all reads are done before we write the tail out.
+ */
+ /* mb(); */
+ pc->data_tail = tail;
+}
+
static void mmap_read(struct mmap_data *md)
{
unsigned int head = mmap_read_head(md);
* In either case, truncate and restart at head.
*/
diff = head - old;
- if (diff > md->mask / 2 || diff < 0) {
+ if (diff < 0) {
struct timeval iv;
unsigned long msecs;
}
md->prev = old;
+ mmap_write_tail(md, old);
}
static volatile int done = 0;
mmap_array[nr_cpu][counter].prev = 0;
mmap_array[nr_cpu][counter].mask = mmap_pages*page_size - 1;
mmap_array[nr_cpu][counter].base = mmap(NULL, (mmap_pages+1)*page_size,
- PROT_READ, MAP_SHARED, fd[nr_cpu][counter], 0);
+ PROT_READ|PROT_WRITE, MAP_SHARED, fd[nr_cpu][counter], 0);
if (mmap_array[nr_cpu][counter].base == MAP_FAILED) {
error("failed to mmap with %d (%s)\n", errno, strerror(errno));
exit(-1);
__u64 sample_period;
};
+struct lost_event {
+ struct perf_event_header header;
+ __u64 id;
+ __u64 lost;
+};
+
typedef union event_union {
struct perf_event_header header;
struct ip_event ip;
struct comm_event comm;
struct fork_event fork;
struct period_event period;
+ struct lost_event lost;
} event_t;
static LIST_HEAD(dsos);
total_mmap = 0,
total_comm = 0,
total_fork = 0,
- total_unknown = 0;
+ total_unknown = 0,
+ total_lost = 0;
static int validate_chain(struct perf_callchain_entry *chain, event_t *event)
{
return 0;
}
+static int
+process_lost_event(event_t *event, unsigned long offset, unsigned long head)
+{
+ dprintf("%p [%p]: PERF_EVENT_LOST: id:%Ld: lost:%Ld\n",
+ (void *)(offset + head),
+ (void *)(long)(event->header.size),
+ event->lost.id,
+ event->lost.lost);
+
+ total_lost += event->lost.lost;
+
+ return 0;
+}
+
static void trace_event(event_t *event)
{
unsigned char *raw_event = (void *)event;
case PERF_EVENT_PERIOD:
return process_period_event(event, offset, head);
+
+ case PERF_EVENT_LOST:
+ return process_lost_event(event, offset, head);
+
/*
* We dont process them right now but they are fine:
*/
dprintf(" mmap events: %10ld\n", total_mmap);
dprintf(" comm events: %10ld\n", total_comm);
dprintf(" fork events: %10ld\n", total_fork);
+ dprintf(" lost events: %10ld\n", total_lost);
dprintf(" unknown events: %10ld\n", total_unknown);
if (dump_trace)