struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu) { struct ring_buffer_event *e; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL, NULL); #else e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL); #endif if (e) goto event; if (ring_buffer_swap_cpu(op_ring_buffer_read, op_ring_buffer_write, cpu)) return NULL; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL, NULL); #else e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL); #endif if (e) goto event; return NULL; event: entry->event = e; entry->sample = ring_buffer_event_data(e); entry->size = (ring_buffer_event_length(e) - sizeof(struct op_sample)) / sizeof(entry->sample->data[0]); entry->data = entry->sample->data; return entry->sample; }
struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu) { struct ring_buffer_event *e; e = ring_buffer_consume(op_ring_buffer, cpu, NULL, NULL); if (!e) return NULL; entry->event = e; entry->sample = ring_buffer_event_data(e); entry->size = (ring_buffer_event_length(e) - sizeof(struct op_sample)) / sizeof(entry->sample->data[0]); entry->data = entry->sample->data; return entry->sample; }