Skip to contentSkip to conversation

perf tools: Remove HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE

PATCH Applied Ian Rogers 2 participants 5 messages Jan 11, 2023 – Jan 20, 2023 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH v2 1/3 perf tools: Remove HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE

Switch HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE to be a version number test on libtraceevent being >= to version 1.5.0. This also corrects a greater-than test to be greater-than-or-equal.

Discussed here:
https://lore.kernel.org/lkml/[email protected]/

Fixes b9a49f8cb02f ("perf tools: Check if libtracevent has TEP_FIELD_IS_RELATIVE")
---
 tools/perf/Makefile.config                             | 4 ----
 tools/perf/builtin-trace.c                             | 2 +-
 tools/perf/util/data-convert-bt.c                      | 2 +-
 tools/perf/util/evsel.c                                | 2 +-
 tools/perf/util/python.c                               | 2 +-
 tools/perf/util/scripting-engines/trace-event-perl.c   | 2 +-
 tools/perf/util/scripting-engines/trace-event-python.c | 2 +-
 tools/perf/util/sort.c                                 | 3 ++-
 tools/perf/util/trace-event.h                          | 3 +++
 9 files changed, 11 insertions(+), 11 deletions(-)
tools/perf/Makefile.config +0 -4
index c2504c39bdcb..f67ba8060162 100644
@@ -1204,10 +1204,6 @@ ifneq ($(NO_LIBTRACEEVENT),1)
     LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3))
     CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
     $(call detected,CONFIG_LIBTRACEEVENT)
-    LIBTRACEEVENT_VERSION_WITH_TEP_FIELD_IS_RELATIVE := $(shell expr 1 \* 255 \* 255 + 5 \* 255 + 0) # 1.5.0
-    ifeq ($(shell test $(LIBTRACEEVENT_VERSION_CPP) -gt $(LIBTRACEEVENT_VERSION_WITH_TEP_FIELD_IS_RELATIVE); echo $$?),0)
-      CFLAGS += -DHAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
-    endif
   else
     dummy := $(warning Warning: libtraceevent is missing limiting functionality, please install libtraceevent-dev/libtraceevent-devel)
   endif
tools/perf/builtin-trace.c +1 -1
index 86e06f136f40..927622ecc42e 100644
@@ -2729,7 +2729,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
 				offset = format_field__intval(field, sample, evsel->needs_swap);
 				syscall_arg.len = offset >> 16;
 				offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
 				if (field->flags & TEP_FIELD_IS_RELATIVE)
 					offset += field->offset + field->size;
 #endif
tools/perf/util/data-convert-bt.c +1 -1
index b842273458b8..98454f7a820c 100644
@@ -322,7 +322,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
 		offset = tmp_val;
 		len = offset >> 16;
 		offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
 		if (flags & TEP_FIELD_IS_RELATIVE)
 			offset += fmtf->offset + fmtf->size;
 #endif
tools/perf/util/evsel.c +1 -1
index 999dd1700502..296292fa2c04 100644
@@ -2784,7 +2784,7 @@ void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char
 	if (field->flags & TEP_FIELD_IS_DYNAMIC) {
 		offset = *(int *)(sample->raw_data + field->offset);
 		offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
 		if (field->flags & TEP_FIELD_IS_RELATIVE)
 			offset += field->offset + field->size;
 #endif
tools/perf/util/python.c +1 -1
index 212031b97910..25a276710dfb 100644
@@ -442,7 +442,7 @@ tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field)
 			offset  = val;
 			len     = offset >> 16;
 			offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
 			if (field->flags & TEP_FIELD_IS_RELATIVE)
 				offset += field->offset + field->size;
 #endif
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
index c097b7934fd4..5bcec514f697 100644
@@ -393,7 +393,7 @@ static void perl_process_tracepoint(struct perf_sample *sample,
 			if (field->flags & TEP_FIELD_IS_DYNAMIC) {
 				offset = *(int *)(data + field->offset);
 				offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
 				if (field->flags & TEP_FIELD_IS_RELATIVE)
 					offset += field->offset + field->size;
 #endif
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index e930f5f1f36d..759ed6eafa3c 100644
@@ -994,7 +994,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
 				offset  = val;
 				len     = offset >> 16;
 				offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
 				if (field->flags & TEP_FIELD_IS_RELATIVE)
 					offset += field->offset + field->size;
 #endif
tools/perf/util/sort.c +2 -1
index e188f74698dd..cfcc253239f0 100644
@@ -28,6 +28,7 @@
 #include "time-utils.h"
 #include "cgroup.h"
 #include "machine.h"
+#include "trace-event.h"
 #include <linux/kernel.h>
 #include <linux/string.h>
 
@@ -2667,7 +2668,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
 		tep_read_number_field(field, a->raw_data, &dyn);
 		offset = dyn & 0xffff;
 		size = (dyn >> 16) & 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
 		if (field->flags & TEP_FIELD_IS_RELATIVE)
 			offset += field->offset + field->size;
 #endif
tools/perf/util/trace-event.h +3 -0
index add6c5d9531c..1a1a2e6b24fb 100644
@@ -20,6 +20,9 @@ struct trace_event {
 	struct tep_plugin_list	*plugin_list;
 };
 
+/* Computes a version number comparable with LIBTRACEEVENT_VERSION from Makefile.config. */
+#define MAKE_LIBTRACEEVENT_VERSION(a, b, c) ((a)*255*255+(b)*255+(c))
+
 typedef char *(tep_func_resolver_t)(void *priv,
 				    unsigned long long *addrp, char **modp);
 
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
author reviewer
#1 lore raw

PATCH v2 2/3 perf trace: Reduce #ifdefs for TEP_FIELD_IS_RELATIVE

Add a helper function that applies the mask to test, or returns false if libtraceevent is too old or not present.

---
 tools/perf/builtin-trace.c                       |  4 +---
 tools/perf/util/data-convert-bt.c                |  4 +---
 tools/perf/util/evsel.c                          |  4 +---
 tools/perf/util/python.c                         |  4 +---
 .../util/scripting-engines/trace-event-perl.c    |  4 +---
 .../util/scripting-engines/trace-event-python.c  |  4 +---
 tools/perf/util/sort.c                           |  4 +---
 tools/perf/util/trace-event.h                    | 16 ++++++++++++++++
 8 files changed, 23 insertions(+), 21 deletions(-)
tools/perf/builtin-trace.c +1 -3
index 927622ecc42e..a4240adbe42f 100644
@@ -2729,10 +2729,8 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
 				offset = format_field__intval(field, sample, evsel->needs_swap);
 				syscall_arg.len = offset >> 16;
 				offset &= 0xffff;
-#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
-				if (field->flags & TEP_FIELD_IS_RELATIVE)
+				if (tep_field_is_relative(field->flags))
 					offset += field->offset + field->size;
-#endif
 			}
 
 			val = (uintptr_t)(sample->raw_data + offset);
tools/perf/util/data-convert-bt.c +1 -3
index 98454f7a820c..2b732bccabad 100644
@@ -322,10 +322,8 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
 		offset = tmp_val;
 		len = offset >> 16;
 		offset &= 0xffff;
-#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
-		if (flags & TEP_FIELD_IS_RELATIVE)
+		if (tep_field_is_relative(flags))
 			offset += fmtf->offset + fmtf->size;
-#endif
 	}
 
 	if (flags & TEP_FIELD_IS_ARRAY) {
tools/perf/util/evsel.c +1 -3
index 296292fa2c04..8550638587e5 100644
@@ -2784,10 +2784,8 @@ void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char
 	if (field->flags & TEP_FIELD_IS_DYNAMIC) {
 		offset = *(int *)(sample->raw_data + field->offset);
 		offset &= 0xffff;
-#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
-		if (field->flags & TEP_FIELD_IS_RELATIVE)
+		if (tep_field_is_relative(field->flags))
 			offset += field->offset + field->size;
-#endif
 	}
 
 	return sample->raw_data + offset;
tools/perf/util/python.c +1 -3
index 25a276710dfb..d948455e5ed4 100644
@@ -442,10 +442,8 @@ tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field)
 			offset  = val;
 			len     = offset >> 16;
 			offset &= 0xffff;
-#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
-			if (field->flags & TEP_FIELD_IS_RELATIVE)
+			if (tep_field_is_relative(field->flags))
 				offset += field->offset + field->size;
-#endif
 		}
 		if (field->flags & TEP_FIELD_IS_STRING &&
 		    is_printable_array(data + offset, len)) {
tools/perf/util/scripting-engines/trace-event-perl.c +1 -3
index 5bcec514f697..83fd2fd0ba16 100644
@@ -393,10 +393,8 @@ static void perl_process_tracepoint(struct perf_sample *sample,
 			if (field->flags & TEP_FIELD_IS_DYNAMIC) {
 				offset = *(int *)(data + field->offset);
 				offset &= 0xffff;
-#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
-				if (field->flags & TEP_FIELD_IS_RELATIVE)
+				if (tep_field_is_relative(field->flags))
 					offset += field->offset + field->size;
-#endif
 			} else
 				offset = field->offset;
 			XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0)));
tools/perf/util/scripting-engines/trace-event-python.c +1 -3
index 759ed6eafa3c..2c2697c5d025 100644
@@ -994,10 +994,8 @@ static void python_process_tracepoint(struct perf_sample *sample,
 				offset  = val;
 				len     = offset >> 16;
 				offset &= 0xffff;
-#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
-				if (field->flags & TEP_FIELD_IS_RELATIVE)
+				if (tep_field_is_relative(field->flags))
 					offset += field->offset + field->size;
-#endif
 			}
 			if (field->flags & TEP_FIELD_IS_STRING &&
 			    is_printable_array(data + offset, len)) {
tools/perf/util/sort.c +1 -3
index cfcc253239f0..dcc4ea96236d 100644
@@ -2668,10 +2668,8 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
 		tep_read_number_field(field, a->raw_data, &dyn);
 		offset = dyn & 0xffff;
 		size = (dyn >> 16) & 0xffff;
-#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
-		if (field->flags & TEP_FIELD_IS_RELATIVE)
+		if (tep_field_is_relative(field->flags))
 			offset += field->offset + field->size;
-#endif
 		/* record max width for output */
 		if (size > hde->dynamic_len)
 			hde->dynamic_len = size;
tools/perf/util/trace-event.h +16 -0
index 1a1a2e6b24fb..ee968e5f6b7a 100644
@@ -139,4 +139,20 @@ int common_lock_depth(struct scripting_context *context);
 #define SAMPLE_FLAGS_BUF_SIZE 64
 int perf_sample__sprintf_flags(u32 flags, char *str, size_t sz);
 
+#if defined(LIBTRACEEVENT_VERSION) &&  LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
+#include <traceevent/event-parse.h>
+
+static inline bool tep_field_is_relative(unsigned long flags)
+{
+	return (flags & TEP_FIELD_IS_RELATIVE) != 0;
+}
+#else
+#include <linux/compiler.h>
+
+static inline bool tep_field_is_relative(unsigned long flags __maybe_unused)
+{
+	return false;
+}
+#endif
+
 #endif /* _PERF_UTIL_TRACE_EVENT_H */
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
author reviewer
#2 lore raw

PATCH v2 3/3 perf debug: Increase libtraceevent logging when verbose

In reply to Ian Rogers

libtraceevent has added more levels of debug printout and with changes like:
https://lore.kernel.org/linux-trace-devel/[email protected]
previously generated output like "registering plugin" is no longer displayed. This change makes it so that if perf's verbose debug output is enabled then the debug and info libtraceevent messages can be displayed.

This change was previously posted:
https://lore.kernel.org/linux-perf-users/[email protected]/
and reverted:
https://lore.kernel.org/linux-perf-users/[email protected]/
The previous failure was due to -Itools/lib being on the include path and libtraceevent in tools/lib being version 1.1.0. This meant that when LIBTRACEEVENT_VERSION was 1.3.0 the #if succeeded, but the header file for libtraceevent (taken from tools/lib rather than the intended /usr/include) was for version 1.1.0 and function definitions were missing.

Since the previous issue the -Itools/lib include path has been removed:
https://lore.kernel.org/lkml/[email protected]/
As well as libtraceevent 1.1.0 has been removed from tools/lib:
https://lore.kernel.org/lkml/[email protected]/

---
 tools/perf/util/debug.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/perf/util/debug.c +15 -0
index 190e818a0717..88378c4c5dd9 100644
@@ -19,12 +19,19 @@
 #include "debug.h"
 #include "print_binary.h"
 #include "target.h"
+#include "trace-event.h"
 #include "ui/helpline.h"
 #include "ui/ui.h"
 #include "util/parse-sublevel-options.h"
 
 #include <linux/ctype.h>
 
+#ifdef HAVE_LIBTRACEEVENT
+#include <traceevent/event-parse.h>
+#else
+#define LIBTRACEEVENT_VERSION 0
+#endif
+
 int verbose;
 int debug_peo_args;
 bool dump_trace = false, quiet = false;
@@ -228,6 +235,14 @@ int perf_debug_option(const char *str)
 	/* Allow only verbose value in range (0, 10), otherwise set 0. */
 	verbose = (verbose < 0) || (verbose > 10) ? 0 : verbose;
 
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 3, 0)
+	if (verbose == 1)
+		tep_set_loglevel(TEP_LOG_INFO);
+	else if (verbose == 2)
+		tep_set_loglevel(TEP_LOG_DEBUG);
+	else if (verbose >= 3)
+		tep_set_loglevel(TEP_LOG_ALL);
+#endif
 	return 0;
 }
 
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
author reviewer
#3 lore raw
In reply to Ian Rogers
Quoted 10 lines · Ian Rogers

Switch HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE to be a version number test on libtraceevent being >= to version 1.5.0. This also corrects a greater-than test to be greater-than-or-equal.

Discussed here:
https://lore.kernel.org/lkml/[email protected]/

Fixes b9a49f8cb02f ("perf tools: Check if libtracevent has TEP_FIELD_IS_RELATIVE")

Ping. Remove one ifdef in favor of a consistent version check, gets debug logging from libtraceevent going.

Thanks,
Ian

Quoted 143 lines
---
 tools/perf/Makefile.config                             | 4 ----
 tools/perf/builtin-trace.c                             | 2 +-
 tools/perf/util/data-convert-bt.c                      | 2 +-
 tools/perf/util/evsel.c                                | 2 +-
 tools/perf/util/python.c                               | 2 +-
 tools/perf/util/scripting-engines/trace-event-perl.c   | 2 +-
 tools/perf/util/scripting-engines/trace-event-python.c | 2 +-
 tools/perf/util/sort.c                                 | 3 ++-
 tools/perf/util/trace-event.h                          | 3 +++
 9 files changed, 11 insertions(+), 11 deletions(-)
tools/perf/Makefile.config +0 -4
index c2504c39bdcb..f67ba8060162 100644
@@ -1204,10 +1204,6 @@ ifneq ($(NO_LIBTRACEEVENT),1)
     LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3))
     CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
     $(call detected,CONFIG_LIBTRACEEVENT)
-    LIBTRACEEVENT_VERSION_WITH_TEP_FIELD_IS_RELATIVE := $(shell expr 1 \* 255 \* 255 + 5 \* 255 + 0) # 1.5.0
-    ifeq ($(shell test $(LIBTRACEEVENT_VERSION_CPP) -gt $(LIBTRACEEVENT_VERSION_WITH_TEP_FIELD_IS_RELATIVE); echo $$?),0)
-      CFLAGS += -DHAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
-    endif
   else
     dummy := $(warning Warning: libtraceevent is missing limiting functionality, please install libtraceevent-dev/libtraceevent-devel)
   endif
tools/perf/builtin-trace.c +1 -1
index 86e06f136f40..927622ecc42e 100644
@@ -2729,7 +2729,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct evsel *evsel,
                                offset = format_field__intval(field, sample, evsel->needs_swap);
                                syscall_arg.len = offset >> 16;
                                offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
                                if (field->flags & TEP_FIELD_IS_RELATIVE)
                                        offset += field->offset + field->size;
 #endif
tools/perf/util/data-convert-bt.c +1 -1
index b842273458b8..98454f7a820c 100644
@@ -322,7 +322,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw,
                offset = tmp_val;
                len = offset >> 16;
                offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
                if (flags & TEP_FIELD_IS_RELATIVE)
                        offset += fmtf->offset + fmtf->size;
 #endif
tools/perf/util/evsel.c +1 -1
index 999dd1700502..296292fa2c04 100644
@@ -2784,7 +2784,7 @@ void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char
        if (field->flags & TEP_FIELD_IS_DYNAMIC) {
                offset = *(int *)(sample->raw_data + field->offset);
                offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
                if (field->flags & TEP_FIELD_IS_RELATIVE)
                        offset += field->offset + field->size;
 #endif
tools/perf/util/python.c +1 -1
index 212031b97910..25a276710dfb 100644
@@ -442,7 +442,7 @@ tracepoint_field(struct pyrf_event *pe, struct tep_format_field *field)
                        offset  = val;
                        len     = offset >> 16;
                        offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
                        if (field->flags & TEP_FIELD_IS_RELATIVE)
                                offset += field->offset + field->size;
 #endif
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
index c097b7934fd4..5bcec514f697 100644
@@ -393,7 +393,7 @@ static void perl_process_tracepoint(struct perf_sample *sample,
                        if (field->flags & TEP_FIELD_IS_DYNAMIC) {
                                offset = *(int *)(data + field->offset);
                                offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
                                if (field->flags & TEP_FIELD_IS_RELATIVE)
                                        offset += field->offset + field->size;
 #endif
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index e930f5f1f36d..759ed6eafa3c 100644
@@ -994,7 +994,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
                                offset  = val;
                                len     = offset >> 16;
                                offset &= 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
                                if (field->flags & TEP_FIELD_IS_RELATIVE)
                                        offset += field->offset + field->size;
 #endif
tools/perf/util/sort.c +2 -1
index e188f74698dd..cfcc253239f0 100644
@@ -28,6 +28,7 @@
 #include "time-utils.h"
 #include "cgroup.h"
 #include "machine.h"
+#include "trace-event.h"
 #include <linux/kernel.h>
 #include <linux/string.h>
 
@@ -2667,7 +2668,7 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
                tep_read_number_field(field, a->raw_data, &dyn);
                offset = dyn & 0xffff;
                size = (dyn >> 16) & 0xffff;
-#ifdef HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE
+#if LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0)
                if (field->flags & TEP_FIELD_IS_RELATIVE)
                        offset += field->offset + field->size;
 #endif
tools/perf/util/trace-event.h +3 -1
index add6c5d9531c..1a1a2e6b24fb 100644
@@ -20,6 +20,9 @@ struct trace_event {
        struct tep_plugin_list  *plugin_list;
 };
 
+/* Computes a version number comparable with LIBTRACEEVENT_VERSION from Makefile.config. */
+#define MAKE_LIBTRACEEVENT_VERSION(a, b, c) ((a)*255*255+(b)*255+(c))
+
 typedef char *(tep_func_resolver_t)(void *priv,
                                    unsigned long long *addrp, char **modp);
 
--

2.39.0.314.g84b9a713c41-goog

maintainer Applied
#4 lore raw

Em Thu, Jan 19, 2023 at 08:01:32AM -0800, Ian Rogers escreveu:

Quoted 6 lines · Ian Rogers
Quoted 5 lines

Switch HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE to be a version number test on libtraceevent being >= to version 1.5.0. This also corrects a greater-than test to be greater-than-or-equal.

Quoted 8 lines
Quoted 5 lines

Discussed here:
https://lore.kernel.org/lkml/[email protected]/

Fixes b9a49f8cb02f ("perf tools: Check if libtracevent has TEP_FIELD_IS_RELATIVE")

Ping. Remove one ifdef in favor of a consistent version check, gets debug logging from libtraceevent going.

Thanks, applied.

- Arnaldo