aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-18 11:48:00 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-18 11:48:00 -0500
commit5448653643d38dabdada497721d3c41bf32a621b (patch)
treeb9481321729bc1b7726568b6065ef6f16526f10e
parent3b1697097728ce78a19f1a09d4b1b725b3a3a18f (diff)
trace-cmd: Add tracecmd_refresh_record()
The data field in a struct record is a pointer to an mmap section of memory. If other records are read, this mmap section can be unmapped. The tracecmd_refresh_record() allows users to remap that mmapped section for the record. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-cmd.h2
-rw-r--r--trace-input.c20
2 files changed, 22 insertions, 0 deletions
diff --git a/trace-cmd.h b/trace-cmd.h
index a5cc217..f6141f4 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -72,6 +72,8 @@ struct record *
72tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu); 72tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu);
73struct record * 73struct record *
74tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu); 74tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu);
75int tracecmd_refresh_record(struct tracecmd_input *handle,
76 struct record *record);
75 77
76int tracecmd_set_cpu_to_timestamp(struct tracecmd_input *handle, 78int tracecmd_set_cpu_to_timestamp(struct tracecmd_input *handle,
77 int cpu, unsigned long long ts); 79 int cpu, unsigned long long ts);
diff --git a/trace-input.c b/trace-input.c
index 1657b2a..826fed9 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -815,6 +815,26 @@ tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset,
815} 815}
816 816
817/** 817/**
818 * tracecmd_refresh_record - remaps the records data
819 * @handle: input handle for the trace.dat file
820 * @record: the record to be refreshed
821 *
822 * A record data points to a mmap section of memory.
823 * by reading new records the mmap section may be unmapped.
824 * This will refresh the record's data mapping.
825 */
826int tracecmd_refresh_record(struct tracecmd_input *handle,
827 struct record *record)
828{
829 unsigned long long page_offset;
830
831 page_offset = record->offset & ~(handle->page_size - 1);
832 get_page(handle, record->cpu, page_offset);
833
834 return 0;
835}
836
837/**
818 * tracecmd_read_cpu_first - get the first record in a CPU 838 * tracecmd_read_cpu_first - get the first record in a CPU
819 * @handle: input handle for the trace.dat file 839 * @handle: input handle for the trace.dat file
820 * @cpu: the CPU to search 840 * @cpu: the CPU to search