@@ -6041,6 +6041,18 @@ ssize_t tracing_resize_ring_buffer(struct trace_array *tr,
6041
6041
return ret ;
6042
6042
}
6043
6043
6044
+ static void update_last_data (struct trace_array * tr )
6045
+ {
6046
+ if (!tr -> text_delta && !tr -> data_delta )
6047
+ return ;
6048
+
6049
+ /* Clear old data */
6050
+ tracing_reset_online_cpus (& tr -> array_buffer );
6051
+
6052
+ /* Using current data now */
6053
+ tr -> text_delta = 0 ;
6054
+ tr -> data_delta = 0 ;
6055
+ }
6044
6056
6045
6057
/**
6046
6058
* tracing_update_buffers - used by tracing facility to expand ring buffers
@@ -6058,6 +6070,9 @@ int tracing_update_buffers(struct trace_array *tr)
6058
6070
int ret = 0 ;
6059
6071
6060
6072
mutex_lock (& trace_types_lock );
6073
+
6074
+ update_last_data (tr );
6075
+
6061
6076
if (!tr -> ring_buffer_expanded )
6062
6077
ret = __tracing_resize_ring_buffer (tr , trace_buf_size ,
6063
6078
RING_BUFFER_ALL_CPUS );
@@ -6113,6 +6128,8 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
6113
6128
6114
6129
mutex_lock (& trace_types_lock );
6115
6130
6131
+ update_last_data (tr );
6132
+
6116
6133
if (!tr -> ring_buffer_expanded ) {
6117
6134
ret = __tracing_resize_ring_buffer (tr , trace_buf_size ,
6118
6135
RING_BUFFER_ALL_CPUS );
@@ -6860,6 +6877,21 @@ tracing_total_entries_read(struct file *filp, char __user *ubuf,
6860
6877
return simple_read_from_buffer (ubuf , cnt , ppos , buf , r );
6861
6878
}
6862
6879
6880
+ static ssize_t
6881
+ tracing_last_boot_read (struct file * filp , char __user * ubuf , size_t cnt , loff_t * ppos )
6882
+ {
6883
+ struct trace_array * tr = filp -> private_data ;
6884
+ struct seq_buf seq ;
6885
+ char buf [64 ];
6886
+
6887
+ seq_buf_init (& seq , buf , 64 );
6888
+
6889
+ seq_buf_printf (& seq , "text delta:\t%ld\n" , tr -> text_delta );
6890
+ seq_buf_printf (& seq , "data delta:\t%ld\n" , tr -> data_delta );
6891
+
6892
+ return simple_read_from_buffer (ubuf , cnt , ppos , buf , seq_buf_used (& seq ));
6893
+ }
6894
+
6863
6895
static int tracing_buffer_meta_open (struct inode * inode , struct file * filp )
6864
6896
{
6865
6897
struct trace_array * tr = inode -> i_private ;
@@ -7499,6 +7531,13 @@ static const struct file_operations trace_time_stamp_mode_fops = {
7499
7531
.release = tracing_single_release_tr ,
7500
7532
};
7501
7533
7534
+ static const struct file_operations last_boot_fops = {
7535
+ .open = tracing_open_generic_tr ,
7536
+ .read = tracing_last_boot_read ,
7537
+ .llseek = generic_file_llseek ,
7538
+ .release = tracing_release_generic_tr ,
7539
+ };
7540
+
7502
7541
#ifdef CONFIG_TRACER_SNAPSHOT
7503
7542
static const struct file_operations snapshot_fops = {
7504
7543
.open = tracing_snapshot_open ,
@@ -9242,6 +9281,9 @@ allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int size
9242
9281
buf -> buffer = ring_buffer_alloc_range (size , rb_flags , 0 ,
9243
9282
tr -> range_addr_start ,
9244
9283
tr -> range_addr_size );
9284
+
9285
+ ring_buffer_last_boot_delta (buf -> buffer ,
9286
+ & tr -> text_delta , & tr -> data_delta );
9245
9287
/*
9246
9288
* This is basically the same as a mapped buffer,
9247
9289
* with the same restrictions.
@@ -9751,7 +9793,10 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
9751
9793
MEM_FAIL (1 , "Could not allocate function filter files" );
9752
9794
9753
9795
#ifdef CONFIG_TRACER_SNAPSHOT
9754
- if (!tr -> range_addr_start ) {
9796
+ if (tr -> range_addr_start ) {
9797
+ trace_create_file ("last_boot_info" , TRACE_MODE_READ , d_tracer ,
9798
+ tr , & last_boot_fops );
9799
+ } else {
9755
9800
trace_create_file ("snapshot" , TRACE_MODE_WRITE , d_tracer ,
9756
9801
tr , & snapshot_fops );
9757
9802
}
0 commit comments