aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-06-08 20:04:22 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-06-08 20:06:46 -0400
commit58f367f42eb159e8d3b1d0c07252aa6a0ce63a9c (patch)
tree626d6c1e51966ff37646f5ced7bbdbde623539ff
parentab08efc4cfe5a8d2c29eb0b4e1a9faa11da3060d (diff)
trace-cmd: Revert need to free peek event
Freeing records that were returned via "peek event" made things a bit more complex. Since the original code was written to determine that peek events should not be freed. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-ftrace.c9
-rw-r--r--trace-input.c24
-rw-r--r--trace-plot-cpu.c2
3 files changed, 12 insertions, 23 deletions
diff --git a/trace-ftrace.c b/trace-ftrace.c
index 7cd5032..af9ac8d 100644
--- a/trace-ftrace.c
+++ b/trace-ftrace.c
@@ -255,13 +255,8 @@ fgraph_ent_handler(struct trace_seq *s, struct record *record,
255 return trace_seq_putc(s, '!'); 255 return trace_seq_putc(s, '!');
256 256
257 rec = tracecmd_peek_data(tracecmd_curr_thread_handle, cpu); 257 rec = tracecmd_peek_data(tracecmd_curr_thread_handle, cpu);
258 if (rec) { 258 if (rec)
259 struct record *tmp; 259 rec = get_return_for_leaf(s, cpu, pid, val, rec);
260
261 tmp = get_return_for_leaf(s, cpu, pid, val, rec);
262 free_record(rec);
263 rec = tmp;
264 }
265 260
266 if (rec) { 261 if (rec) {
267 /* 262 /*
diff --git a/trace-input.c b/trace-input.c
index 3a70aec..5e92cb3 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -664,6 +664,9 @@ void free_record(struct record *record)
664 die("record ref count is zero!"); 664 die("record ref count is zero!");
665 665
666 record->ref_count--; 666 record->ref_count--;
667
668 if (record->ref_count)
669 breakpoint();
667 if (record->ref_count) 670 if (record->ref_count)
668 return; 671 return;
669 672
@@ -910,14 +913,12 @@ peek_event(struct tracecmd_input *handle, unsigned long long offset,
910 * tracecmd_read_at. 913 * tracecmd_read_at.
911 */ 914 */
912 update_page_info(handle, cpu); 915 update_page_info(handle, cpu);
913 free_next(handle, cpu);
914 916
915 do { 917 do {
918 free_next(handle, cpu);
916 record = tracecmd_peek_data(handle, cpu); 919 record = tracecmd_peek_data(handle, cpu);
917 if (record && (record->offset + record->record_size) > offset) 920 if (record && (record->offset + record->record_size) > offset)
918 break; 921 break;
919 free_record(record);
920 free_next(handle, cpu);
921 } while (record); 922 } while (record);
922 923
923 return record; 924 return record;
@@ -930,10 +931,8 @@ read_event(struct tracecmd_input *handle, unsigned long long offset,
930 struct record *record; 931 struct record *record;
931 932
932 record = peek_event(handle, offset, cpu); 933 record = peek_event(handle, offset, cpu);
933 if (record) { 934 if (record)
934 free_record(record);
935 record = tracecmd_read_data(handle, cpu); 935 record = tracecmd_read_data(handle, cpu);
936 }
937 return record; 936 return record;
938} 937}
939 938
@@ -1314,7 +1313,7 @@ int tracecmd_set_cursor(struct tracecmd_input *handle,
1314 if (get_page(handle, cpu, page_offset) < 0) 1313 if (get_page(handle, cpu, page_offset) < 0)
1315 return -1; 1314 return -1;
1316 1315
1317 free_record(peek_event(handle, offset, cpu)); 1316 peek_event(handle, offset, cpu);
1318 1317
1319 return 0; 1318 return 0;
1320} 1319}
@@ -1491,10 +1490,8 @@ tracecmd_peek_data(struct tracecmd_input *handle, int cpu)
1491 if (!record->data) 1490 if (!record->data)
1492 die("Something freed the record"); 1491 die("Something freed the record");
1493 1492
1494 if (handle->cpu_data[cpu].timestamp == record->ts) { 1493 if (handle->cpu_data[cpu].timestamp == record->ts)
1495 record->ref_count++;
1496 return record; 1494 return record;
1497 }
1498 1495
1499 /* 1496 /*
1500 * The timestamp changed, which means the cached 1497 * The timestamp changed, which means the cached
@@ -1567,7 +1564,7 @@ read_again:
1567 record->data = ptr; 1564 record->data = ptr;
1568 record->offset = handle->cpu_data[cpu].offset + index; 1565 record->offset = handle->cpu_data[cpu].offset + index;
1569 record->missed_events = missed_events; 1566 record->missed_events = missed_events;
1570 record->ref_count = 2; /* will be returned and stored in page */ 1567 record->ref_count = 1;
1571 record->locked = 1; 1568 record->locked = 1;
1572 1569
1573 ptr += length; 1570 ptr += length;
@@ -1599,10 +1596,8 @@ tracecmd_read_data(struct tracecmd_input *handle, int cpu)
1599 1596
1600 record = tracecmd_peek_data(handle, cpu); 1597 record = tracecmd_peek_data(handle, cpu);
1601 handle->cpu_data[cpu].next = NULL; 1598 handle->cpu_data[cpu].next = NULL;
1602 if (record) { 1599 if (record)
1603 record->ref_count--;
1604 record->locked = 0; 1600 record->locked = 0;
1605 }
1606 1601
1607 return record; 1602 return record;
1608} 1603}
@@ -1644,7 +1639,6 @@ tracecmd_read_next_data(struct tracecmd_input *handle, int *rec_cpu)
1644 ts = record->ts; 1639 ts = record->ts;
1645 next = cpu; 1640 next = cpu;
1646 } 1641 }
1647 free_record(record);
1648 } 1642 }
1649 1643
1650 if (next >= 0) { 1644 if (next >= 0) {
diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c
index fdfbdf7..50d720b 100644
--- a/trace-plot-cpu.c
+++ b/trace-plot-cpu.c
@@ -137,7 +137,7 @@ static int cpu_plot_display_last_event(struct graph_info *ginfo,
137 record = tracecmd_peek_data(ginfo->handle, cpu); 137 record = tracecmd_peek_data(ginfo->handle, cpu);
138 if (record) 138 if (record)
139 offset = record->offset; 139 offset = record->offset;
140 free_record(record); 140 /* Don't need to free a peek */
141 141
142 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time); 142 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time);
143 143