Skip to contentSkip to conversation

perf tools: Remove HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE

PATCH Superseded Ian Rogers 2 participants 7 messages Jan 9, 2023 – Jan 11, 2023 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/2 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 2/2 perf debug: Increase libtraceevent logging when verbose

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
maintainer
#2 lore raw
In reply to Ian Rogers

Hi Ian,

Quoted 128 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")
---
 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 +1 -0
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>
 

tools/perf/util/sort.c static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, · line 2673

Quoted 7 lines
tools/perf/util/sort.c +1 -1
@@ -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;

Maybe I missed the previous discussion.

As it's only used in the bit test, can we have something like this in the header file?

#if LIBTRACE_EVENT_VERSION < ...(1, 5, 0)

# define TEP_FIELD_IS_RELATIVE  0
#endif

Thanks,
Namhyung

Quoted 18 lines
tools/perf/util/sort.c +0 -0
 #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

author reviewer
#3 lore raw
Quoted 145 lines · Namhyung Kim

Hi Ian,

Quoted 128 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")
---
 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 +1 -0
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>
 

tools/perf/util/sort.c static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, · line 2673

Quoted 7 lines
tools/perf/util/sort.c +1 -1
@@ -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;

Maybe I missed the previous discussion.

As it's only used in the bit test, can we have something like this in the header file?

Quoted 6 lines

#if LIBTRACE_EVENT_VERSION < ...(1, 5, 0)

# define TEP_FIELD_IS_RELATIVE  0
#endif

Thanks,
Namhyung

We could but I think we lose some of the intention revealing-ness that TEP_FIELD_IS_RELATIVE is only present with libtraceevent 1.5.0 or newer.

Thanks,
Ian

Quoted 18 lines
Quoted 18 lines
tools/perf/util/sort.c +0 -0
 #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
#4 lore raw
Quoted 36 lines · Ian Rogers
Quoted 34 lines · Namhyung Kim

Hi Ian,

Quoted 13 lines · Ian Rogers
tools/perf/util/sort.c +1 -0
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>
 

tools/perf/util/sort.c static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, · line 2673

Quoted 7 lines
tools/perf/util/sort.c +1 -1
@@ -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;

Maybe I missed the previous discussion.

As it's only used in the bit test, can we have something like this in the header file?

#if LIBTRACE_EVENT_VERSION < ...(1, 5, 0)

# define TEP_FIELD_IS_RELATIVE  0
#endif
Quoted 6 lines
Quoted 2 lines

Thanks,
Namhyung

We could but I think we lose some of the intention revealing-ness that TEP_FIELD_IS_RELATIVE is only present with libtraceevent 1.5.0 or newer.

I'm not sure how important it is to reveal the intention. I think we wanted to minimize #ifdef-ery in the .c file and moved the conditionals to the header. Maybe we can add a wrapper like this.

#if LIBTRACEEVENT_VERSION >= ...(1, 5, 0)
static inline bool is_relative_field(field)

{
    return field->flags & TEP_FIELD_IS_RELATIVE;
}
#else
static inline bool is_relative_field(field)
{
    return false;
}

#endif

Thanks,
Namhyung

author reviewer
#5 lore raw
Quoted 60 lines · Namhyung Kim
Quoted 36 lines · Ian Rogers
Quoted 34 lines · Namhyung Kim

Hi Ian,

Quoted 13 lines · Ian Rogers
tools/perf/util/sort.c +1 -0
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>
 

tools/perf/util/sort.c static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, · line 2673

Quoted 7 lines
tools/perf/util/sort.c +1 -1
@@ -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;

Maybe I missed the previous discussion.

As it's only used in the bit test, can we have something like this in the header file?

#if LIBTRACE_EVENT_VERSION < ...(1, 5, 0)

# define TEP_FIELD_IS_RELATIVE  0
#endif
Quoted 6 lines
Quoted 2 lines

Thanks,
Namhyung

We could but I think we lose some of the intention revealing-ness that TEP_FIELD_IS_RELATIVE is only present with libtraceevent 1.5.0 or newer.

I'm not sure how important it is to reveal the intention. I think we wanted to minimize #ifdef-ery in the .c file and moved the conditionals to the header. Maybe we can add a wrapper like this.

#if LIBTRACEEVENT_VERSION >= ...(1, 5, 0)
static inline bool is_relative_field(field)

{
    return field->flags & TEP_FIELD_IS_RELATIVE;
}
#else
static inline bool is_relative_field(field)
{
    return false;
}
Quoted 4 lines

#endif

Thanks,
Namhyung

Sounds good. Should the change be part of this one or a follow up patch? A follow up patch seems cleanest, I can add it to v2.

Thanks,
Ian

maintainer
#6 lore raw
Quoted 64 lines · Ian Rogers
Quoted 62 lines · Namhyung Kim
Quoted 36 lines · Ian Rogers
Quoted 34 lines · Namhyung Kim

Hi Ian,

Quoted 13 lines · Ian Rogers
tools/perf/util/sort.c +1 -0
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>
 

tools/perf/util/sort.c static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt, · line 2673

Quoted 7 lines
tools/perf/util/sort.c +1 -1
@@ -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;

Maybe I missed the previous discussion.

As it's only used in the bit test, can we have something like this in the header file?

#if LIBTRACE_EVENT_VERSION < ...(1, 5, 0)

# define TEP_FIELD_IS_RELATIVE  0
#endif
Quoted 6 lines
Quoted 2 lines

Thanks,
Namhyung

We could but I think we lose some of the intention revealing-ness that TEP_FIELD_IS_RELATIVE is only present with libtraceevent 1.5.0 or newer.

I'm not sure how important it is to reveal the intention. I think we wanted to minimize #ifdef-ery in the .c file and moved the conditionals to the header. Maybe we can add a wrapper like this.

#if LIBTRACEEVENT_VERSION >= ...(1, 5, 0)
static inline bool is_relative_field(field)

{
    return field->flags & TEP_FIELD_IS_RELATIVE;
}
#else
static inline bool is_relative_field(field)
{
    return false;
}

#endif

Quoted 5 lines
Quoted 2 lines

Thanks,
Namhyung

Sounds good. Should the change be part of this one or a follow up patch? A follow up patch seems cleanest, I can add it to v2.

Sounds good.

Thanks,
Namhyung