Blame SOURCES/0003-extensions-trace-Rename-ring_buffer-to-trace_buffer.patch

6adb17
From 1d4357ba0e0e1ec8267c32855aec5fe5abbcfec8 Mon Sep 17 00:00:00 2001
6adb17
From: Valentin Schneider <valentin.schneider@arm.com>
6adb17
Date: Thu, 3 Sep 2020 21:28:47 +0100
6adb17
Subject: [PATCH 3/3] extensions/trace: Rename ring_buffer to trace_buffer
6adb17
6adb17
This renaming is present from Linux v5.6 upwards, and was introduced by
6adb17
commit:
6adb17
6adb17
  13292494379f ("tracing: Make struct ring_buffer less ambiguous")
6adb17
6adb17
Rename the internal references from ring_buffer to trace_buffer. Backwards
6adb17
compatibility with older kernels is provided by checking whether struct
6adb17
trace_buffer has a buffer field of type struct ring buffer - should that
6adb17
not be the case, the newer naming scheme is used instead.
6adb17
6adb17
Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
6adb17
---
6adb17
 trace.c | 50 +++++++++++++++++++++++++++++---------------------
6adb17
 1 file changed, 29 insertions(+), 21 deletions(-)
6adb17
6adb17
diff --git a/trace.c b/trace.c
6adb17
index 2cea5b2d650a..c33907f98b00 100644
6adb17
--- a/trace.c
6adb17
+++ b/trace.c
6adb17
@@ -57,10 +57,10 @@ static int koffset(array_buffer, buffer);
6adb17
 static int koffset(trace_array, buffer);
6adb17
 static int koffset(tracer, name);
6adb17
 
6adb17
-static int koffset(ring_buffer, pages);
6adb17
-static int koffset(ring_buffer, flags);
6adb17
-static int koffset(ring_buffer, cpus);
6adb17
-static int koffset(ring_buffer, buffers);
6adb17
+static int koffset(trace_buffer, pages);
6adb17
+static int koffset(trace_buffer, flags);
6adb17
+static int koffset(trace_buffer, cpus);
6adb17
+static int koffset(trace_buffer, buffers);
6adb17
 
6adb17
 static int koffset(ring_buffer_per_cpu, cpu);
6adb17
 static int koffset(ring_buffer_per_cpu, pages);
6adb17
@@ -119,7 +119,7 @@ struct trace_instance {
6adb17
 	char name[NAME_MAX + 1];
6adb17
 	ulong array_buffer;
6adb17
 	ulong max_buffer;
6adb17
-	ulong ring_buffer;
6adb17
+	ulong trace_buffer;
6adb17
 	unsigned pages;
6adb17
 	struct ring_buffer_per_cpu *buffers;
6adb17
 
6adb17
@@ -225,11 +225,19 @@ static int init_offsets(void)
6adb17
 	else if (kernel_symbol_exists("ring_buffer_read"))
6adb17
 		gdb_set_crash_scope(symbol_value("ring_buffer_read"), "ring_buffer_read");
6adb17
 
6adb17
-	if (!per_cpu_buffer_sizes)
6adb17
-		init_offset(ring_buffer, pages);
6adb17
-	init_offset(ring_buffer, flags);
6adb17
-	init_offset(ring_buffer, cpus);
6adb17
-	init_offset(ring_buffer, buffers);
6adb17
+	if (STREQ(MEMBER_TYPE_NAME("trace_buffer", "buffer"), "ring_buffer")) {
6adb17
+		if (!per_cpu_buffer_sizes)
6adb17
+			init_offset_alternative(trace_buffer, pages, ring_buffer, pages);
6adb17
+		init_offset_alternative(trace_buffer, flags, ring_buffer, flags);
6adb17
+		init_offset_alternative(trace_buffer, cpus, ring_buffer, cpus);
6adb17
+		init_offset_alternative(trace_buffer, buffers, ring_buffer, buffers);
6adb17
+	} else {
6adb17
+		if (!per_cpu_buffer_sizes)
6adb17
+			init_offset(trace_buffer, pages);
6adb17
+		init_offset(trace_buffer, flags);
6adb17
+		init_offset(trace_buffer, cpus);
6adb17
+		init_offset(trace_buffer, buffers);
6adb17
+	}
6adb17
 
6adb17
 	if (MEMBER_SIZE("ring_buffer_per_cpu", "pages") == sizeof(ulong)) {
6adb17
 		lockless_ring_buffer = 1;
6adb17
@@ -287,10 +295,10 @@ static void print_offsets(void)
6adb17
 	print_offset(trace_array, buffer);
6adb17
 	print_offset(tracer, name);
6adb17
 
6adb17
-	print_offset(ring_buffer, pages);
6adb17
-	print_offset(ring_buffer, flags);
6adb17
-	print_offset(ring_buffer, cpus);
6adb17
-	print_offset(ring_buffer, buffers);
6adb17
+	print_offset(trace_buffer, pages);
6adb17
+	print_offset(trace_buffer, flags);
6adb17
+	print_offset(trace_buffer, cpus);
6adb17
+	print_offset(trace_buffer, buffers);
6adb17
 
6adb17
 	print_offset(ring_buffer_per_cpu, cpu);
6adb17
 	print_offset(ring_buffer_per_cpu, pages);
6adb17
@@ -445,12 +453,12 @@ static void ftrace_destroy_buffers(struct ring_buffer_per_cpu *buffers)
6adb17
 }
6adb17
 
6adb17
 static int ftrace_init_buffers(struct ring_buffer_per_cpu *buffers,
6adb17
-		ulong ring_buffer, unsigned pages)
6adb17
+			       ulong trace_buffer, unsigned pages)
6adb17
 {
6adb17
 	int i;
6adb17
 	ulong buffers_array;
6adb17
 
6adb17
-	read_value(buffers_array, ring_buffer, ring_buffer, buffers);
6adb17
+	read_value(buffers_array, trace_buffer, trace_buffer, buffers);
6adb17
 
6adb17
 	for (i = 0; i < nr_cpu_ids; i++) {
6adb17
 		if (!readmem(buffers_array + sizeof(ulong) * i, KVADDR,
6adb17
@@ -505,7 +513,7 @@ static int ftrace_init_trace(struct trace_instance *ti, ulong instance_addr)
6adb17
 	if (array_buffer_available) {
6adb17
 		ti->array_buffer = instance_addr +
6adb17
 				koffset(trace_array, array_buffer);
6adb17
-		read_value(ti->ring_buffer, ti->array_buffer,
6adb17
+		read_value(ti->trace_buffer, ti->array_buffer,
6adb17
 			   array_buffer, buffer);
6adb17
 
6adb17
 		if (max_buffer_available) {
6adb17
@@ -515,19 +523,19 @@ static int ftrace_init_trace(struct trace_instance *ti, ulong instance_addr)
6adb17
 					array_buffer, buffer);
6adb17
 		}
6adb17
 	} else {
6adb17
-		read_value(ti->ring_buffer, instance_addr, trace_array, buffer);
6adb17
-		read_value(ti->pages, ti->ring_buffer, ring_buffer, pages);
6adb17
+		read_value(ti->trace_buffer, instance_addr, trace_array, buffer);
6adb17
+		read_value(ti->pages, ti->trace_buffer, trace_buffer, pages);
6adb17
 
6adb17
 		read_value(ti->max_tr_ring_buffer, max_tr_trace, trace_array, buffer);
6adb17
 		if (ti->max_tr_ring_buffer)
6adb17
-			read_value(ti->max_tr_pages, ti->max_tr_ring_buffer, ring_buffer, pages);
6adb17
+			read_value(ti->max_tr_pages, ti->max_tr_ring_buffer, trace_buffer, pages);
6adb17
 	}
6adb17
 
6adb17
 	ti->buffers = calloc(sizeof(*ti->buffers), nr_cpu_ids);
6adb17
 	if (ti->buffers == NULL)
6adb17
 		goto out_fail;
6adb17
 
6adb17
-	if (ftrace_init_buffers(ti->buffers, ti->ring_buffer,
6adb17
+	if (ftrace_init_buffers(ti->buffers, ti->trace_buffer,
6adb17
 			ti->pages) < 0)
6adb17
 		goto out_fail;
6adb17
 
6adb17
-- 
6adb17
2.17.1
6adb17