|
|
14fa54 |
From c4cdbe3c18bca496dc6b4af17e2637379528ad02 Mon Sep 17 00:00:00 2001
|
|
|
14fa54 |
From: Valentin Schneider <valentin.schneider@arm.com>
|
|
|
14fa54 |
Date: Thu, 3 Sep 2020 21:28:46 +0100
|
|
|
14fa54 |
Subject: [PATCH 2/3] extensions/trace: Rename trace_buffer to array_buffer
|
|
|
14fa54 |
|
|
|
14fa54 |
This renaming is present from Linux v5.6 upwards, and was introduced by
|
|
|
14fa54 |
commit:
|
|
|
14fa54 |
|
|
|
14fa54 |
1c5eb4481e01 ("tracing: Rename trace_buffer to array_buffer")
|
|
|
14fa54 |
|
|
|
14fa54 |
Rename the internal references from trace_buffer to array_buffer. Backwards
|
|
|
14fa54 |
compatibility with older kernels is provided by checking whether struct
|
|
|
14fa54 |
trace_array has an array_buffer field - should that not be the case, the
|
|
|
14fa54 |
old naming scheme is used instead.
|
|
|
14fa54 |
|
|
|
14fa54 |
Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
|
|
|
14fa54 |
---
|
|
|
14fa54 |
trace.c | 53 +++++++++++++++++++++++++++++++++++------------------
|
|
|
14fa54 |
1 file changed, 35 insertions(+), 18 deletions(-)
|
|
|
14fa54 |
|
|
|
14fa54 |
diff --git a/trace.c b/trace.c
|
|
|
14fa54 |
index c26b6c7ec475..2cea5b2d650a 100644
|
|
|
14fa54 |
--- a/trace.c
|
|
|
14fa54 |
+++ b/trace.c
|
|
|
14fa54 |
@@ -31,9 +31,9 @@ static int per_cpu_buffer_sizes;
|
|
|
14fa54 |
*/
|
|
|
14fa54 |
static int encapsulated_current_trace;
|
|
|
14fa54 |
/*
|
|
|
14fa54 |
- * trace_buffer is supported
|
|
|
14fa54 |
+ * array_buffer (trace_buffer pre v5.6) is supported
|
|
|
14fa54 |
*/
|
|
|
14fa54 |
-static int trace_buffer_available;
|
|
|
14fa54 |
+static int array_buffer_available;
|
|
|
14fa54 |
/*
|
|
|
14fa54 |
* max_buffer is supported
|
|
|
14fa54 |
*/
|
|
|
14fa54 |
@@ -51,9 +51,9 @@ static int buffer_page_real_end_available;
|
|
|
14fa54 |
#define koffset(struct, member) struct##_##member##_offset
|
|
|
14fa54 |
|
|
|
14fa54 |
static int koffset(trace_array, current_trace);
|
|
|
14fa54 |
-static int koffset(trace_array, trace_buffer);
|
|
|
14fa54 |
+static int koffset(trace_array, array_buffer);
|
|
|
14fa54 |
static int koffset(trace_array, max_buffer);
|
|
|
14fa54 |
-static int koffset(trace_buffer, buffer);
|
|
|
14fa54 |
+static int koffset(array_buffer, buffer);
|
|
|
14fa54 |
static int koffset(trace_array, buffer);
|
|
|
14fa54 |
static int koffset(tracer, name);
|
|
|
14fa54 |
|
|
|
14fa54 |
@@ -117,7 +117,7 @@ static ulong max_tr_trace;
|
|
|
14fa54 |
|
|
|
14fa54 |
struct trace_instance {
|
|
|
14fa54 |
char name[NAME_MAX + 1];
|
|
|
14fa54 |
- ulong trace_buffer;
|
|
|
14fa54 |
+ ulong array_buffer;
|
|
|
14fa54 |
ulong max_buffer;
|
|
|
14fa54 |
ulong ring_buffer;
|
|
|
14fa54 |
unsigned pages;
|
|
|
14fa54 |
@@ -174,8 +174,7 @@ static int write_and_check(int fd, void *data, size_t size)
|
|
|
14fa54 |
|
|
|
14fa54 |
static int init_offsets(void)
|
|
|
14fa54 |
{
|
|
|
14fa54 |
-#define init_offset(struct, member) do { \
|
|
|
14fa54 |
- koffset(struct, member) = MEMBER_OFFSET(#struct, #member);\
|
|
|
14fa54 |
+#define check_offset(struct, member) do { \
|
|
|
14fa54 |
if (koffset(struct, member) < 0) { \
|
|
|
14fa54 |
fprintf(fp, "failed to init the offset, struct:"\
|
|
|
14fa54 |
#struct ", member:" #member); \
|
|
|
14fa54 |
@@ -184,12 +183,29 @@ static int init_offsets(void)
|
|
|
14fa54 |
} \
|
|
|
14fa54 |
} while (0)
|
|
|
14fa54 |
|
|
|
14fa54 |
+#define init_offset(struct, member) do { \
|
|
|
14fa54 |
+ koffset(struct, member) = MEMBER_OFFSET(#struct, #member); \
|
|
|
14fa54 |
+ check_offset(struct, member); \
|
|
|
14fa54 |
+ } while (0)
|
|
|
14fa54 |
+
|
|
|
14fa54 |
+#define init_offset_alternative(struct, member, alt_struct, alt_member) do { \
|
|
|
14fa54 |
+ koffset(struct, member) = MEMBER_OFFSET(#alt_struct, #alt_member); \
|
|
|
14fa54 |
+ check_offset(struct, member); \
|
|
|
14fa54 |
+ } while (0)
|
|
|
14fa54 |
+
|
|
|
14fa54 |
if (encapsulated_current_trace)
|
|
|
14fa54 |
init_offset(trace_array, current_trace);
|
|
|
14fa54 |
|
|
|
14fa54 |
- if (trace_buffer_available) {
|
|
|
14fa54 |
- init_offset(trace_array, trace_buffer);
|
|
|
14fa54 |
- init_offset(trace_buffer, buffer);
|
|
|
14fa54 |
+ if (array_buffer_available) {
|
|
|
14fa54 |
+ if (MEMBER_EXISTS("trace_array", "array_buffer")) {
|
|
|
14fa54 |
+ init_offset(trace_array, array_buffer);
|
|
|
14fa54 |
+ init_offset(array_buffer, buffer);
|
|
|
14fa54 |
+ } else {
|
|
|
14fa54 |
+ init_offset_alternative(trace_array, array_buffer,
|
|
|
14fa54 |
+ trace_array, trace_buffer);
|
|
|
14fa54 |
+ init_offset_alternative(array_buffer, buffer,
|
|
|
14fa54 |
+ trace_buffer, buffer);
|
|
|
14fa54 |
+ }
|
|
|
14fa54 |
|
|
|
14fa54 |
if (max_buffer_available)
|
|
|
14fa54 |
init_offset(trace_array, max_buffer);
|
|
|
14fa54 |
@@ -486,17 +502,17 @@ out_fail:
|
|
|
14fa54 |
|
|
|
14fa54 |
static int ftrace_init_trace(struct trace_instance *ti, ulong instance_addr)
|
|
|
14fa54 |
{
|
|
|
14fa54 |
- if (trace_buffer_available) {
|
|
|
14fa54 |
- ti->trace_buffer = instance_addr +
|
|
|
14fa54 |
- koffset(trace_array, trace_buffer);
|
|
|
14fa54 |
- read_value(ti->ring_buffer, ti->trace_buffer,
|
|
|
14fa54 |
- trace_buffer, buffer);
|
|
|
14fa54 |
+ if (array_buffer_available) {
|
|
|
14fa54 |
+ ti->array_buffer = instance_addr +
|
|
|
14fa54 |
+ koffset(trace_array, array_buffer);
|
|
|
14fa54 |
+ read_value(ti->ring_buffer, ti->array_buffer,
|
|
|
14fa54 |
+ array_buffer, buffer);
|
|
|
14fa54 |
|
|
|
14fa54 |
if (max_buffer_available) {
|
|
|
14fa54 |
ti->max_buffer = instance_addr +
|
|
|
14fa54 |
koffset(trace_array, max_buffer);
|
|
|
14fa54 |
read_value(ti->max_tr_ring_buffer, ti->max_buffer,
|
|
|
14fa54 |
- trace_buffer, buffer);
|
|
|
14fa54 |
+ array_buffer, buffer);
|
|
|
14fa54 |
}
|
|
|
14fa54 |
} else {
|
|
|
14fa54 |
read_value(ti->ring_buffer, instance_addr, trace_array, buffer);
|
|
|
14fa54 |
@@ -683,8 +699,9 @@ static int ftrace_init(void)
|
|
|
14fa54 |
current_trace = sym_current_trace->value;
|
|
|
14fa54 |
}
|
|
|
14fa54 |
|
|
|
14fa54 |
- if (MEMBER_EXISTS("trace_array", "trace_buffer")) {
|
|
|
14fa54 |
- trace_buffer_available = 1;
|
|
|
14fa54 |
+ if (MEMBER_EXISTS("trace_array", "array_buffer") ||
|
|
|
14fa54 |
+ MEMBER_EXISTS("trace_array", "trace_buffer")) {
|
|
|
14fa54 |
+ array_buffer_available = 1;
|
|
|
14fa54 |
|
|
|
14fa54 |
if (MEMBER_EXISTS("trace_array", "max_buffer"))
|
|
|
14fa54 |
max_buffer_available = 1;
|
|
|
14fa54 |
--
|
|
|
14fa54 |
2.17.1
|
|
|
14fa54 |
|