Skip to content

Commit 8f3e665

Browse files
committed
ring-buffer: Save text and data locations in mapped meta data
When a ring buffer is mapped to a specific address, save the address of a text function and some data. This will be used to determine the delta between the last boot and the current boot for pointers to functions as well as to data. Link: https://lkml.kernel.org/r/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Vincent Donnefort <[email protected]> Cc: Joel Fernandes <[email protected]> Cc: Daniel Bristot de Oliveira <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vineeth Pillai <[email protected]> Cc: Youssef Esmat <[email protected]> Cc: Beau Belgrave <[email protected]> Cc: Alexander Graf <[email protected]> Cc: Baoquan He <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: David Howells <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Tony Luck <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Ross Zwisler <[email protected]> Cc: Kees Cook <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent e645535 commit 8f3e665

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

kernel/trace/ring_buffer.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
static void update_pages_handler(struct work_struct *work);
4646

4747
struct ring_buffer_meta {
48+
unsigned long text_addr;
49+
unsigned long data_addr;
4850
unsigned long first_buffer;
4951
unsigned long head_buffer;
5052
unsigned long commit_buffer;
@@ -542,6 +544,9 @@ struct trace_buffer {
542544
unsigned long range_addr_start;
543545
unsigned long range_addr_end;
544546

547+
long last_text_delta;
548+
long last_data_delta;
549+
545550
unsigned int subbuf_size;
546551
unsigned int subbuf_order;
547552
unsigned int max_data_size;
@@ -1821,10 +1826,15 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
18211826
}
18221827
}
18231828

1829+
/* Used to calculate data delta */
1830+
static char rb_data_ptr[] = "";
1831+
18241832
static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages)
18251833
{
18261834
struct ring_buffer_meta *meta;
18271835
unsigned long delta;
1836+
unsigned long this_text = (unsigned long)rb_range_meta_init;
1837+
unsigned long this_data = (unsigned long)rb_data_ptr;
18281838
void *subbuf;
18291839
int cpu;
18301840
int i;
@@ -1841,6 +1851,10 @@ static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages)
18411851
meta->first_buffer += delta;
18421852
meta->head_buffer += delta;
18431853
meta->commit_buffer += delta;
1854+
buffer->last_text_delta = this_text - meta->text_addr;
1855+
buffer->last_data_delta = this_data - meta->data_addr;
1856+
meta->text_addr = this_text;
1857+
meta->data_addr = this_data;
18441858
continue;
18451859
}
18461860

@@ -1857,6 +1871,8 @@ static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages)
18571871
subbuf = rb_subbufs_from_meta(meta);
18581872

18591873
meta->first_buffer = (unsigned long)subbuf;
1874+
meta->text_addr = this_text;
1875+
meta->data_addr = this_data;
18601876

18611877
/*
18621878
* The buffers[] array holds the order of the sub-buffers

0 commit comments

Comments
 (0)