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")
Signed-off-by: Ian Rogers <[email protected]>
---
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(-)
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index c2504c39bdcb..f67ba8060162 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 86e06f136f40..927622ecc42e 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -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
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index b842273458b8..98454f7a820c 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -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
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 999dd1700502..296292fa2c04 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 212031b97910..25a276710dfb 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -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
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index c097b7934fd4..5bcec514f697 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -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
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index e930f5f1f36d..759ed6eafa3c 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -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
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index e188f74698dd..cfcc253239f0 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -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
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index add6c5d9531c..1a1a2e6b24fb 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -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
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]/
Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/util/debug.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 190e818a0717..88378c4c5dd9 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -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;
}
--
2.39.0.314.g84b9a713c41-goog
On Mon, Jan 9, 2023 at 2:57 PM Namhyung Kim <[email protected]> wrote:
>
> Hi Ian,
>
> On Mon, Jan 9, 2023 at 2:31 PM Ian Rogers <[email protected]> wrote:
> >
> > 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")
> > Signed-off-by: Ian Rogers <[email protected]>
> > ---
> > 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(-)
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index c2504c39bdcb..f67ba8060162 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -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
> > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > index 86e06f136f40..927622ecc42e 100644
> > --- a/tools/perf/builtin-trace.c
> > +++ b/tools/perf/builtin-trace.c
> > @@ -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
> > diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
> > index b842273458b8..98454f7a820c 100644
> > --- a/tools/perf/util/data-convert-bt.c
> > +++ b/tools/perf/util/data-convert-bt.c
> > @@ -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
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index 999dd1700502..296292fa2c04 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -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
> > diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> > index 212031b97910..25a276710dfb 100644
> > --- a/tools/perf/util/python.c
> > +++ b/tools/perf/util/python.c
> > @@ -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
> > diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
> > index c097b7934fd4..5bcec514f697 100644
> > --- a/tools/perf/util/scripting-engines/trace-event-perl.c
> > +++ b/tools/perf/util/scripting-engines/trace-event-perl.c
> > @@ -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
> > diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> > index e930f5f1f36d..759ed6eafa3c 100644
> > --- a/tools/perf/util/scripting-engines/trace-event-python.c
> > +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> > @@ -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
> > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > index e188f74698dd..cfcc253239f0 100644
> > --- a/tools/perf/util/sort.c
> > +++ b/tools/perf/util/sort.c
> > @@ -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;
>
> 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
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
> > #endif
> > diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
> > index add6c5d9531c..1a1a2e6b24fb 100644
> > --- a/tools/perf/util/trace-event.h
> > +++ b/tools/perf/util/trace-event.h
> > @@ -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
> >
Hi Ian,
On Mon, Jan 9, 2023 at 2:31 PM Ian Rogers <[email protected]> wrote:
>
> 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")
> Signed-off-by: Ian Rogers <[email protected]>
> ---
> 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(-)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index c2504c39bdcb..f67ba8060162 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -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
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 86e06f136f40..927622ecc42e 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -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
> diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
> index b842273458b8..98454f7a820c 100644
> --- a/tools/perf/util/data-convert-bt.c
> +++ b/tools/perf/util/data-convert-bt.c
> @@ -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
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 999dd1700502..296292fa2c04 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -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
> diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> index 212031b97910..25a276710dfb 100644
> --- a/tools/perf/util/python.c
> +++ b/tools/perf/util/python.c
> @@ -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
> diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
> index c097b7934fd4..5bcec514f697 100644
> --- a/tools/perf/util/scripting-engines/trace-event-perl.c
> +++ b/tools/perf/util/scripting-engines/trace-event-perl.c
> @@ -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
> diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
> index e930f5f1f36d..759ed6eafa3c 100644
> --- a/tools/perf/util/scripting-engines/trace-event-python.c
> +++ b/tools/perf/util/scripting-engines/trace-event-python.c
> @@ -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
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index e188f74698dd..cfcc253239f0 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -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;
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
> #endif
> diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
> index add6c5d9531c..1a1a2e6b24fb 100644
> --- a/tools/perf/util/trace-event.h
> +++ b/tools/perf/util/trace-event.h
> @@ -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
>
On Mon, Jan 9, 2023 at 3:38 PM Ian Rogers <[email protected]> wrote:
>
> On Mon, Jan 9, 2023 at 2:57 PM Namhyung Kim <[email protected]> wrote:
> >
> > Hi Ian,
> >
> > On Mon, Jan 9, 2023 at 2:31 PM Ian Rogers <[email protected]> wrote:
> > > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > > index e188f74698dd..cfcc253239f0 100644
> > > --- a/tools/perf/util/sort.c
> > > +++ b/tools/perf/util/sort.c
> > > @@ -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;
> >
> > 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
>
> 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
On Tue, Jan 10, 2023 at 11:09 AM Namhyung Kim <[email protected]> wrote:
>
> On Mon, Jan 9, 2023 at 3:38 PM Ian Rogers <[email protected]> wrote:
> >
> > On Mon, Jan 9, 2023 at 2:57 PM Namhyung Kim <[email protected]> wrote:
> > >
> > > Hi Ian,
> > >
> > > On Mon, Jan 9, 2023 at 2:31 PM Ian Rogers <[email protected]> wrote:
> > > > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > > > index e188f74698dd..cfcc253239f0 100644
> > > > --- a/tools/perf/util/sort.c
> > > > +++ b/tools/perf/util/sort.c
> > > > @@ -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;
> > >
> > > 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
> >
> > 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
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
On Tue, Jan 10, 2023 at 11:55 AM Ian Rogers <[email protected]> wrote:
>
> On Tue, Jan 10, 2023 at 11:09 AM Namhyung Kim <[email protected]> wrote:
> >
> > On Mon, Jan 9, 2023 at 3:38 PM Ian Rogers <[email protected]> wrote:
> > >
> > > On Mon, Jan 9, 2023 at 2:57 PM Namhyung Kim <[email protected]> wrote:
> > > >
> > > > Hi Ian,
> > > >
> > > > On Mon, Jan 9, 2023 at 2:31 PM Ian Rogers <[email protected]> wrote:
> > > > > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> > > > > index e188f74698dd..cfcc253239f0 100644
> > > > > --- a/tools/perf/util/sort.c
> > > > > +++ b/tools/perf/util/sort.c
> > > > > @@ -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;
> > > >
> > > > 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
> > >
> > > 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
>
> 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