hi,
as a preparation for sampling libperf interface, moving event
definitions into the library header. Moving just the kernel
non-AUX events now.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
It's also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
---
Jiri Olsa (12):
libperf: Add mmap_event to perf/event.h
libperf: Add mmap2_event to perf/event.h
libperf: Add comm_event to perf/event.h
libperf: Add namespaces_event to perf/event.h
libperf: Add fork_event to perf/event.h
libperf: Add lost_event to perf/event.h
libperf: Add lost_samples_event to perf/event.h
libperf: Add read_event to perf/event.h
libperf: Add throttle_event to perf/event.h
libperf: Add ksymbol_event to perf/event.h
libperf: Add bpf_event to perf/event.h
libperf: Add sample_event to perf/event.h
tools/perf/builtin-sched.c | 2 +-
tools/perf/lib/include/perf/event.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/event.c | 12 ++++++------
tools/perf/util/event.h | 104 +++-----------------------------------------------------------------------------------------------------
tools/perf/util/evlist.c | 2 +-
tools/perf/util/evsel.c | 8 ++++----
tools/perf/util/machine.c | 4 ++--
tools/perf/util/python.c | 14 +++++++-------
tools/perf/util/session.c | 8 ++++----
9 files changed, 140 insertions(+), 126 deletions(-)
create mode 100644 tools/perf/lib/include/perf/event.h
Moving mmap2_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 15 +++++++++++++++
tools/perf/util/event.c | 6 +++---
tools/perf/util/event.h | 15 ---------------
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 8eeba16e3ff7..f1f5b0787782 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -15,4 +15,19 @@ struct mmap_event {
char filename[PATH_MAX];
};
+struct mmap2_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 start;
+ __u64 len;
+ __u64 pgoff;
+ __u32 maj;
+ __u32 min;
+ __u64 ino;
+ __u64 ino_generation;
+ __u32 prot;
+ __u32 flags;
+ char filename[PATH_MAX];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 43c86257e7fa..0954f980574f 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -387,7 +387,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
strcpy(execname, "");
/* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
- n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %[^\n]\n",
+ n = sscanf(bf, "%"PRI_lx64"-%"PRI_lx64" %s %"PRI_lx64" %x:%x %u %[^\n]\n",
&event->mmap2.start, &event->mmap2.len, prot,
&event->mmap2.pgoff, &event->mmap2.maj,
&event->mmap2.min,
@@ -1362,8 +1362,8 @@ size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64
- " %02x:%02x %"PRIu64" %"PRIu64"]: %c%c%c%c %s\n",
+ return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64
+ " %02x:%02x %"PRI_lu64" %"PRI_lu64"]: %c%c%c%c %s\n",
event->mmap2.pid, event->mmap2.tid, event->mmap2.start,
event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj,
event->mmap2.min, event->mmap2.ino,
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index b244f9e77fa8..fdff9dcd7c2b 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,21 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct mmap2_event {
- struct perf_event_header header;
- u32 pid, tid;
- u64 start;
- u64 len;
- u64 pgoff;
- u32 maj;
- u32 min;
- u64 ino;
- u64 ino_generation;
- u32 prot;
- u32 flags;
- char filename[PATH_MAX];
-};
-
struct comm_event {
struct perf_event_header header;
u32 pid, tid;
--
2.21.0
Moving fork_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 7 +++++++
tools/perf/util/event.h | 7 -------
tools/perf/util/python.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 265bb01029f0..7a34221abbba 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -43,4 +43,11 @@ struct namespaces_event {
struct perf_ns_link_info link_info[];
};
+struct fork_event {
+ struct perf_event_header header;
+ __u32 pid, ppid;
+ __u32 tid, ptid;
+ __u64 time;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index e8c57c23aa24..817f12643f11 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,13 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct fork_event {
- struct perf_event_header header;
- u32 pid, ppid;
- u32 tid, ptid;
- u64 time;
-};
-
struct lost_event {
struct perf_event_header header;
u64 id;
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 55ff0c3182d6..8bdadb24f6ba 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -170,7 +170,7 @@ static PyMemberDef pyrf_task_event__members[] = {
static PyObject *pyrf_task_event__repr(struct pyrf_event *pevent)
{
return _PyUnicode_FromFormat("{ type: %s, pid: %u, ppid: %u, tid: %u, "
- "ptid: %u, time: %" PRIu64 "}",
+ "ptid: %u, time: %" PRI_lu64 "}",
pevent->event.header.type == PERF_RECORD_FORK ? "fork" : "exit",
pevent->event.fork.pid,
pevent->event.fork.ppid,
--
2.21.0
Moving comm_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 6 ++++++
tools/perf/util/event.h | 6 ------
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index f1f5b0787782..11adfb1b1524 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -30,4 +30,10 @@ struct mmap2_event {
char filename[PATH_MAX];
};
+struct comm_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ char comm[16];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index fdff9dcd7c2b..12bc9de3d539 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,12 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct comm_event {
- struct perf_event_header header;
- u32 pid, tid;
- char comm[16];
-};
-
struct namespaces_event {
struct perf_event_header header;
u32 pid, tid;
--
2.21.0
Moving lost_samples_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 5 +++++
tools/perf/util/event.h | 5 -----
tools/perf/util/machine.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 6c25d0adbe6d..3bd2727ac5f9 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -56,4 +56,9 @@ struct lost_event {
__u64 lost;
};
+struct lost_samples_event {
+ struct perf_event_header header;
+ __u64 lost;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index cc9cc38f0bf7..1bf44b73fbbf 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,11 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct lost_samples_event {
- struct perf_event_header header;
- u64 lost;
-};
-
/*
* PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
*/
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index f61349d1d0d4..9094e86e4db8 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -650,7 +650,7 @@ int machine__process_lost_event(struct machine *machine __maybe_unused,
int machine__process_lost_samples_event(struct machine *machine __maybe_unused,
union perf_event *event, struct perf_sample *sample)
{
- dump_printf(": id:%" PRIu64 ": lost samples :%" PRIu64 "\n",
+ dump_printf(": id:%" PRIu64 ": lost samples :%" PRI_lu64 "\n",
sample->id, event->lost_samples.lost);
return 0;
}
--
2.21.0
Moving mmap_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 18 ++++++++++++++++++
tools/perf/util/event.c | 2 +-
tools/perf/util/event.h | 11 +++--------
tools/perf/util/python.c | 4 ++--
4 files changed, 24 insertions(+), 11 deletions(-)
create mode 100644 tools/perf/lib/include/perf/event.h
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
new file mode 100644
index 000000000000..8eeba16e3ff7
--- /dev/null
+++ b/tools/perf/lib/include/perf/event.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LIBPERF_EVENT_H
+#define __LIBPERF_EVENT_H
+
+#include <linux/perf_event.h>
+#include <linux/types.h>
+#include <linux/limits.h>
+
+struct mmap_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 start;
+ __u64 len;
+ __u64 pgoff;
+ char filename[PATH_MAX];
+};
+
+#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 332edef8d394..43c86257e7fa 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1353,7 +1353,7 @@ int perf_event__process_bpf_event(struct perf_tool *tool __maybe_unused,
size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %c %s\n",
+ return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 "]: %c %s\n",
event->mmap.pid, event->mmap.tid, event->mmap.start,
event->mmap.len, event->mmap.pgoff,
(event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x',
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 0e164e8ae28d..b244f9e77fa8 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -7,19 +7,14 @@
#include <linux/kernel.h>
#include <linux/bpf.h>
#include <linux/perf_event.h>
+#include <perf/event.h>
#include "../perf.h"
#include "build-id.h"
#include "perf_regs.h"
-struct mmap_event {
- struct perf_event_header header;
- u32 pid, tid;
- u64 start;
- u64 len;
- u64 pgoff;
- char filename[PATH_MAX];
-};
+#define PRI_lu64 "l" PRIu64
+#define PRI_lx64 "l" PRIx64
struct mmap2_event {
struct perf_event_header header;
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 75ecc32a4427..55ff0c3182d6 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -130,8 +130,8 @@ static PyObject *pyrf_mmap_event__repr(struct pyrf_event *pevent)
PyObject *ret;
char *s;
- if (asprintf(&s, "{ type: mmap, pid: %u, tid: %u, start: %#" PRIx64 ", "
- "length: %#" PRIx64 ", offset: %#" PRIx64 ", "
+ if (asprintf(&s, "{ type: mmap, pid: %u, tid: %u, start: %#" PRI_lx64 ", "
+ "length: %#" PRI_lx64 ", offset: %#" PRI_lx64 ", "
"filename: %s }",
pevent->event.mmap.pid, pevent->event.mmap.tid,
pevent->event.mmap.start, pevent->event.mmap.len,
--
2.21.0
Moving namespaces_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 7 +++++++
tools/perf/util/event.h | 7 -------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 11adfb1b1524..265bb01029f0 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -36,4 +36,11 @@ struct comm_event {
char comm[16];
};
+struct namespaces_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 nr_namespaces;
+ struct perf_ns_link_info link_info[];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 12bc9de3d539..e8c57c23aa24 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,13 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct namespaces_event {
- struct perf_event_header header;
- u32 pid, tid;
- u64 nr_namespaces;
- struct perf_ns_link_info link_info[];
-};
-
struct fork_event {
struct perf_event_header header;
u32 pid, ppid;
--
2.21.0
Moving read_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 12 ++++++++++++
tools/perf/util/event.h | 12 ------------
tools/perf/util/session.c | 8 ++++----
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 3bd2727ac5f9..a03dbe776a44 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -61,4 +61,16 @@ struct lost_samples_event {
__u64 lost;
};
+/*
+ * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
+ */
+struct read_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 value;
+ __u64 time_enabled;
+ __u64 time_running;
+ __u64 id;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 1bf44b73fbbf..89872279a5af 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,18 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-/*
- * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
- */
-struct read_event {
- struct perf_event_header header;
- u32 pid, tid;
- u64 value;
- u64 time_enabled;
- u64 time_running;
- u64 id;
-};
-
struct throttle_event {
struct perf_event_header header;
u64 time;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 82e0438a9160..cb1d8dcd0c19 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1260,7 +1260,7 @@ static void dump_read(struct evsel *evsel, union perf_event *event)
if (!dump_trace)
return;
- printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
+ printf(": %d %d %s %" PRI_lu64 "\n", event->read.pid, event->read.tid,
perf_evsel__name(evsel),
event->read.value);
@@ -1270,13 +1270,13 @@ static void dump_read(struct evsel *evsel, union perf_event *event)
read_format = evsel->core.attr.read_format;
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
- printf("... time enabled : %" PRIu64 "\n", read_event->time_enabled);
+ printf("... time enabled : %" PRI_lu64 "\n", read_event->time_enabled);
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
- printf("... time running : %" PRIu64 "\n", read_event->time_running);
+ printf("... time running : %" PRI_lu64 "\n", read_event->time_running);
if (read_format & PERF_FORMAT_ID)
- printf("... id : %" PRIu64 "\n", read_event->id);
+ printf("... id : %" PRI_lu64 "\n", read_event->id);
}
static struct machine *machines__find_for_cpumode(struct machines *machines,
--
2.21.0
Moving ksymbol_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 13 +++++++++++++
tools/perf/util/event.c | 2 +-
tools/perf/util/event.h | 13 -------------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 80d0bc48baff..ecab3246913d 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -80,4 +80,17 @@ struct throttle_event {
__u64 stream_id;
};
+#ifndef KSYM_NAME_LEN
+#define KSYM_NAME_LEN 256
+#endif
+
+struct ksymbol_event {
+ struct perf_event_header header;
+ __u64 addr;
+ __u32 len;
+ __u16 ksym_type;
+ __u16 flags;
+ char name[KSYM_NAME_LEN];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 3bd9fc2a3ae8..4447cd25e3f2 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1485,7 +1485,7 @@ static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp)
size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " addr %" PRIx64 " len %u type %u flags 0x%x name %s\n",
+ return fprintf(fp, " addr %" PRI_lx64 " len %u type %u flags 0x%x name %s\n",
event->ksymbol_event.addr, event->ksymbol_event.len,
event->ksymbol_event.ksym_type,
event->ksymbol_event.flags, event->ksymbol_event.name);
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index d03a70e2e6a4..dbabde3a43a6 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,19 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-#ifndef KSYM_NAME_LEN
-#define KSYM_NAME_LEN 256
-#endif
-
-struct ksymbol_event {
- struct perf_event_header header;
- u64 addr;
- u32 len;
- u16 ksym_type;
- u16 flags;
- char name[KSYM_NAME_LEN];
-};
-
struct bpf_event {
struct perf_event_header header;
u16 type;
--
2.21.0
Moving throttle_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 7 +++++++
tools/perf/util/event.h | 7 -------
tools/perf/util/python.c | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index a03dbe776a44..80d0bc48baff 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -73,4 +73,11 @@ struct read_event {
__u64 id;
};
+struct throttle_event {
+ struct perf_event_header header;
+ __u64 time;
+ __u64 id;
+ __u64 stream_id;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 89872279a5af..d03a70e2e6a4 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,13 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct throttle_event {
- struct perf_event_header header;
- u64 time;
- u64 id;
- u64 stream_id;
-};
-
#ifndef KSYM_NAME_LEN
#define KSYM_NAME_LEN 256
#endif
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 5be85f50cd1c..d21e270c7823 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -233,8 +233,8 @@ static PyObject *pyrf_throttle_event__repr(struct pyrf_event *pevent)
{
struct throttle_event *te = (struct throttle_event *)(&pevent->event.header + 1);
- return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRIu64 ", id: %" PRIu64
- ", stream_id: %" PRIu64 " }",
+ return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRI_lu64 ", id: %" PRI_lu64
+ ", stream_id: %" PRI_lu64 " }",
pevent->event.header.type == PERF_RECORD_THROTTLE ? "" : "un",
te->time, te->id, te->stream_id);
}
--
2.21.0
Moving lost_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
that. Using extra '_' to ease up the reading and differentiate
them from standard PRI*64 macros.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/builtin-sched.c | 2 +-
tools/perf/lib/include/perf/event.h | 6 ++++++
tools/perf/util/event.c | 2 +-
tools/perf/util/event.h | 6 ------
tools/perf/util/machine.c | 2 +-
tools/perf/util/python.c | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0d6b4c3b1a51..025151dcb651 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2643,7 +2643,7 @@ static int process_lost(struct perf_tool *tool __maybe_unused,
timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr));
printf("%15s ", tstr);
- printf("lost %" PRIu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
+ printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
return 0;
}
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 7a34221abbba..6c25d0adbe6d 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -50,4 +50,10 @@ struct fork_event {
__u64 time;
};
+struct lost_event {
+ struct perf_event_header header;
+ __u64 id;
+ __u64 lost;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 0954f980574f..3bd9fc2a3ae8 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1480,7 +1480,7 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " lost %" PRIu64 "\n", event->lost.lost);
+ return fprintf(fp, " lost %" PRI_lu64 "\n", event->lost.lost);
}
size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 817f12643f11..cc9cc38f0bf7 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,12 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct lost_event {
- struct perf_event_header header;
- u64 id;
- u64 lost;
-};
-
struct lost_samples_event {
struct perf_event_header header;
u64 lost;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 5734460fc89e..f61349d1d0d4 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -642,7 +642,7 @@ int machine__process_namespaces_event(struct machine *machine __maybe_unused,
int machine__process_lost_event(struct machine *machine __maybe_unused,
union perf_event *event, struct perf_sample *sample __maybe_unused)
{
- dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n",
+ dump_printf(": id:%" PRI_lu64 ": lost:%" PRI_lu64 "\n",
event->lost.id, event->lost.lost);
return 0;
}
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 8bdadb24f6ba..5be85f50cd1c 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -263,8 +263,8 @@ static PyObject *pyrf_lost_event__repr(struct pyrf_event *pevent)
PyObject *ret;
char *s;
- if (asprintf(&s, "{ type: lost, id: %#" PRIx64 ", "
- "lost: %#" PRIx64 " }",
+ if (asprintf(&s, "{ type: lost, id: %#" PRI_lx64 ", "
+ "lost: %#" PRI_lx64 " }",
pevent->event.lost.id, pevent->event.lost.lost) < 0) {
ret = PyErr_NoMemory();
} else {
--
2.21.0
Moving lost_samples_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 11 +++++++++++
tools/perf/util/event.h | 10 ----------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index ecab3246913d..74317bcf74bf 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -5,6 +5,7 @@
#include <linux/perf_event.h>
#include <linux/types.h>
#include <linux/limits.h>
+#include <linux/bpf.h>
struct mmap_event {
struct perf_event_header header;
@@ -93,4 +94,14 @@ struct ksymbol_event {
char name[KSYM_NAME_LEN];
};
+struct bpf_event {
+ struct perf_event_header header;
+ __u16 type;
+ __u16 flags;
+ __u32 id;
+
+ /* for bpf_prog types */
+ __u8 tag[BPF_TAG_SIZE]; // prog tag
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index dbabde3a43a6..cd1d8d1007dc 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -16,16 +16,6 @@
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
-struct bpf_event {
- struct perf_event_header header;
- u16 type;
- u16 flags;
- u32 id;
-
- /* for bpf_prog types */
- u8 tag[BPF_TAG_SIZE]; // prog tag
-};
-
#define PERF_SAMPLE_MASK \
(PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \
--
2.21.0
Moving sample_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/perf/lib/include/perf/event.h | 5 +++++
tools/perf/util/event.h | 5 -----
tools/perf/util/evlist.c | 2 +-
tools/perf/util/evsel.c | 8 ++++----
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 74317bcf74bf..daa1924c1d11 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -104,4 +104,9 @@ struct bpf_event {
__u8 tag[BPF_TAG_SIZE]; // prog tag
};
+struct sample_event {
+ struct perf_event_header header;
+ __u64 array[];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index cd1d8d1007dc..37349ddb30f0 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -26,11 +26,6 @@
/* perf sample has 16 bits size limit */
#define PERF_SAMPLE_MAX_SIZE (1 << 16)
-struct sample_event {
- struct perf_event_header header;
- u64 array[];
-};
-
struct regs_dump {
u64 abi;
u64 mask;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index ff415680fe0a..47bc54111f57 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -587,7 +587,7 @@ struct evsel *perf_evlist__id2evsel_strict(struct evlist *evlist,
static int perf_evlist__event2id(struct evlist *evlist,
union perf_event *event, u64 *id)
{
- const u64 *array = event->sample.array;
+ const __u64 *array = event->sample.array;
ssize_t n;
n = (event->header.size - sizeof(event->header)) >> 3;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index e983e721beca..552bc4c839f4 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2008,7 +2008,7 @@ static int perf_evsel__parse_id_sample(const struct evsel *evsel,
struct perf_sample *sample)
{
u64 type = evsel->core.attr.sample_type;
- const u64 *array = event->sample.array;
+ const __u64 *array = event->sample.array;
bool swapped = evsel->needs_swap;
union u64_swap u;
@@ -2098,7 +2098,7 @@ int perf_evsel__parse_sample(struct evsel *evsel, union perf_event *event,
{
u64 type = evsel->core.attr.sample_type;
bool swapped = evsel->needs_swap;
- const u64 *array;
+ const __u64 *array;
u16 max_size = event->header.size;
const void *endp = (void *)event + max_size;
u64 sz;
@@ -2377,7 +2377,7 @@ int perf_evsel__parse_sample_timestamp(struct evsel *evsel,
u64 *timestamp)
{
u64 type = evsel->core.attr.sample_type;
- const u64 *array;
+ const __u64 *array;
if (!(type & PERF_SAMPLE_TIME))
return -1;
@@ -2528,7 +2528,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
u64 read_format,
const struct perf_sample *sample)
{
- u64 *array;
+ __u64 *array;
size_t sz;
/*
* used for cross-endian analysis. See git commit 65014ab3
--
2.21.0
Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> hi,
> as a preparation for sampling libperf interface, moving event
> definitions into the library header. Moving just the kernel
> non-AUX events now.
>
> In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> types used events to their generic '__u*' versions.
>
> Perf added 'u*' types mainly to ease up printing __u64 values
> as stated in the linux/types.h comment:
>
> /*
> * We define u64 as uint64_t for every architecture
> * so that we can print it with "%"PRIx64 without getting warnings.
> *
> * typedef __u64 u64;
> * typedef __s64 s64;
> */
>
> Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> that. Using extra '_' to ease up the reading and differentiate
> them from standard PRI*64 macros.
I think we should take advantage of this moment to rename those structs
to have the 'perf_record_' prefix on them, I guess we could even remove
the _event from them, i.e.:
'struct mmap_event' becomes 'perf_record_mmap', as it is the description
for the PERF_RECORD_MMAP meta-data event, are you ok with that?
I can go ahead and do it myself, updating each patch on this series to
do that.
- Arnaldo
> It's also available in here:
> git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> perf/fixes
>
> thanks,
> jirka
>
>
> ---
> Jiri Olsa (12):
> libperf: Add mmap_event to perf/event.h
> libperf: Add mmap2_event to perf/event.h
> libperf: Add comm_event to perf/event.h
> libperf: Add namespaces_event to perf/event.h
> libperf: Add fork_event to perf/event.h
> libperf: Add lost_event to perf/event.h
> libperf: Add lost_samples_event to perf/event.h
> libperf: Add read_event to perf/event.h
> libperf: Add throttle_event to perf/event.h
> libperf: Add ksymbol_event to perf/event.h
> libperf: Add bpf_event to perf/event.h
> libperf: Add sample_event to perf/event.h
>
> tools/perf/builtin-sched.c | 2 +-
> tools/perf/lib/include/perf/event.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/event.c | 12 ++++++------
> tools/perf/util/event.h | 104 +++-----------------------------------------------------------------------------------------------------
> tools/perf/util/evlist.c | 2 +-
> tools/perf/util/evsel.c | 8 ++++----
> tools/perf/util/machine.c | 4 ++--
> tools/perf/util/python.c | 14 +++++++-------
> tools/perf/util/session.c | 8 ++++----
> 9 files changed, 140 insertions(+), 126 deletions(-)
> create mode 100644 tools/perf/lib/include/perf/event.h
--
- Arnaldo
On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
> [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' /tmp/build/perf/builtin-sched.i
> printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, sample->cpu);
> [perfbuilder@490c2c7bdaab ~]$
>
> And if we do this on a fedora:30 x86_64:
>
> $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> [acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
> printf("lost %" "l"
> # 2646 "builtin-sched.c" 3 4
> "l" "u"
> # 2646 "builtin-sched.c"
> " events on cpu %d\n", event->lost.lost, sample->cpu);
> [acme@quaco perf]$
>
> I.e. on 32-bit arches we shouldn't add that extra "l", right?
hum, I guess we could #ifdef it 64/32 bits
>
> I bet the build for the mips/mipsel will fail too, lemme see... Yeah,
> both failed:
>
>
> [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mips
> builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> ^~~~~~~~
> In file included from builtin-sched.c:31:
> /usr/mips-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
> # define __PRI64_PREFIX "ll"
> ^
> [root@quaco ~]#
>
> [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mipsel
> builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> ^~~~~~~~
> In file included from builtin-sched.c:31:
> /usr/mipsel-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
> # define __PRI64_PREFIX "ll"
> ^
> [root@quaco ~]#
>
> And also on a uclibc ARC arch container:
>
> [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/fedora\:24-x-ARC-uClibc
> builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> ^~~~~~~~
> In file included from builtin-sched.c:31:0:
> /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/inttypes.h:47:28: note: format string is defined here
> # define __PRI64_PREFIX "ll"
> ^
> [root@quaco ~]#
>
> The _fix_ will come after lunch :)
thanks ;-)
jirka
Em Mon, Aug 26, 2019 at 01:06:28PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> > hi,
> > as a preparation for sampling libperf interface, moving event
> > definitions into the library header. Moving just the kernel
> > non-AUX events now.
> >
> > In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> > types used events to their generic '__u*' versions.
> >
> > Perf added 'u*' types mainly to ease up printing __u64 values
> > as stated in the linux/types.h comment:
> >
> > /*
> > * We define u64 as uint64_t for every architecture
> > * so that we can print it with "%"PRIx64 without getting warnings.
> > *
> > * typedef __u64 u64;
> > * typedef __s64 s64;
> > */
> >
> > Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> > that. Using extra '_' to ease up the reading and differentiate
> > them from standard PRI*64 macros.
>
> So, this is not building on android env:
>
> builtin-sched.c: In function 'process_lost':
> builtin-sched.c:2646:2: error: unknown conversion type character 'l' in format [-Werror=format=]
> printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> ^
> builtin-sched.c:2646:2: error: format '%d' expects argument of type 'int', but argument 2 has type '__u64' [-Werror=format=]
> builtin-sched.c:2646:2: error: too many arguments for format [-Werror=format-extra-args]
> MKDIR /tmp/build/perf/util/
>
>
> [perfbuilder@490c2c7bdaab ~]$ /opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -v
> Using built-in specs.
> COLLECT_GCC=/opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
> COLLECT_LTO_WRAPPER=/opt/android-ndk-r12b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper
> Target: arm-linux-androideabi
> Configured with: /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install --with-mpfr=/buildbot/tmp/build/toolchain/temp-install --with-mpc=/buildbot/tmp/build/toolchain/temp-install --with-cloog=/buildbot/tmp/build/toolchain/temp-install --with-isl=/buildbot/tmp/build/toolchain/temp-install --with-ppl=/buildbot/tmp/build/toolchain/temp-install --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array --disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot --with-binutils-version=2.25 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none --with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x --with-bugurl=http://source.android.com/source/report-bugs.html --enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default
> Thread model: posix
> gcc version 4.9.x 20150123 (prerelease) (GCC)
> [perfbuilder@490c2c7bdaab ~]$
>
> It doesn't build on the r15b as well.
>
> I'll investigate after lunch.
$ make $EXTRA_MAKE_ARGS ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE EXTRA_CFLAGS="$EXTRA_CFLAGS" -C /git/perf/tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
We end up with one 'l' too many?
[perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' /tmp/build/perf/builtin-sched.i
printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, sample->cpu);
[perfbuilder@490c2c7bdaab ~]$
And if we do this on a fedora:30 x86_64:
$ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
[acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
printf("lost %" "l"
# 2646 "builtin-sched.c" 3 4
"l" "u"
# 2646 "builtin-sched.c"
" events on cpu %d\n", event->lost.lost, sample->cpu);
[acme@quaco perf]$
I.e. on 32-bit arches we shouldn't add that extra "l", right?
I bet the build for the mips/mipsel will fail too, lemme see... Yeah,
both failed:
[root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mips
builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
^~~~~~~~
In file included from builtin-sched.c:31:
/usr/mips-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
# define __PRI64_PREFIX "ll"
^
[root@quaco ~]#
[root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mipsel
builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
^~~~~~~~
In file included from builtin-sched.c:31:
/usr/mipsel-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
# define __PRI64_PREFIX "ll"
^
[root@quaco ~]#
And also on a uclibc ARC arch container:
[root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/fedora\:24-x-ARC-uClibc
builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
^~~~~~~~
In file included from builtin-sched.c:31:0:
/arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/inttypes.h:47:28: note: format string is defined here
# define __PRI64_PREFIX "ll"
^
[root@quaco ~]#
The _fix_ will come after lunch :)
- Arnaldo
Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> hi,
> as a preparation for sampling libperf interface, moving event
> definitions into the library header. Moving just the kernel
> non-AUX events now.
>
> In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> types used events to their generic '__u*' versions.
>
> Perf added 'u*' types mainly to ease up printing __u64 values
> as stated in the linux/types.h comment:
>
> /*
> * We define u64 as uint64_t for every architecture
> * so that we can print it with "%"PRIx64 without getting warnings.
> *
> * typedef __u64 u64;
> * typedef __s64 s64;
> */
>
> Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> that. Using extra '_' to ease up the reading and differentiate
> them from standard PRI*64 macros.
So, this is not building on android env:
builtin-sched.c: In function 'process_lost':
builtin-sched.c:2646:2: error: unknown conversion type character 'l' in format [-Werror=format=]
printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
^
builtin-sched.c:2646:2: error: format '%d' expects argument of type 'int', but argument 2 has type '__u64' [-Werror=format=]
builtin-sched.c:2646:2: error: too many arguments for format [-Werror=format-extra-args]
MKDIR /tmp/build/perf/util/
[perfbuilder@490c2c7bdaab ~]$ /opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/android-ndk-r12b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
COLLECT_LTO_WRAPPER=/opt/android-ndk-r12b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper
Target: arm-linux-androideabi
Configured with: /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install --with-mpfr=/buildbot/tmp/build/toolchain/temp-install --with-mpc=/buildbot/tmp/build/toolchain/temp-install --with-cloog=/buildbot/tmp/build/toolchain/temp-install --with-isl=/buildbot/tmp/build/toolchain/temp-install --with-ppl=/buildbot/tmp/build/toolchain/temp-install --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array --disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot --with-binutils-version=2.25 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none --with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x --with-bugurl=http://source.android.com/source/report-bugs.html --enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default
Thread model: posix
gcc version 4.9.x 20150123 (prerelease) (GCC)
[perfbuilder@490c2c7bdaab ~]$
It doesn't build on the r15b as well.
I'll investigate after lunch.
- Arnaldo
> It's also available in here:
> git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> perf/fixes
>
> thanks,
> jirka
>
>
> ---
> Jiri Olsa (12):
> libperf: Add mmap_event to perf/event.h
> libperf: Add mmap2_event to perf/event.h
> libperf: Add comm_event to perf/event.h
> libperf: Add namespaces_event to perf/event.h
> libperf: Add fork_event to perf/event.h
> libperf: Add lost_event to perf/event.h
> libperf: Add lost_samples_event to perf/event.h
> libperf: Add read_event to perf/event.h
> libperf: Add throttle_event to perf/event.h
> libperf: Add ksymbol_event to perf/event.h
> libperf: Add bpf_event to perf/event.h
> libperf: Add sample_event to perf/event.h
>
> tools/perf/builtin-sched.c | 2 +-
> tools/perf/lib/include/perf/event.h | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/event.c | 12 ++++++------
> tools/perf/util/event.h | 104 +++-----------------------------------------------------------------------------------------------------
> tools/perf/util/evlist.c | 2 +-
> tools/perf/util/evsel.c | 8 ++++----
> tools/perf/util/machine.c | 4 ++--
> tools/perf/util/python.c | 14 +++++++-------
> tools/perf/util/session.c | 8 ++++----
> 9 files changed, 140 insertions(+), 126 deletions(-)
> create mode 100644 tools/perf/lib/include/perf/event.h
--
- Arnaldo
On Mon, Aug 26, 2019 at 12:41:38PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> > hi,
> > as a preparation for sampling libperf interface, moving event
> > definitions into the library header. Moving just the kernel
> > non-AUX events now.
> >
> > In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> > types used events to their generic '__u*' versions.
> >
> > Perf added 'u*' types mainly to ease up printing __u64 values
> > as stated in the linux/types.h comment:
> >
> > /*
> > * We define u64 as uint64_t for every architecture
> > * so that we can print it with "%"PRIx64 without getting warnings.
> > *
> > * typedef __u64 u64;
> > * typedef __s64 s64;
> > */
> >
> > Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> > that. Using extra '_' to ease up the reading and differentiate
> > them from standard PRI*64 macros.
>
> I think we should take advantage of this moment to rename those structs
> to have the 'perf_record_' prefix on them, I guess we could even remove
> the _event from them, i.e.:
>
> 'struct mmap_event' becomes 'perf_record_mmap', as it is the description
> for the PERF_RECORD_MMAP meta-data event, are you ok with that?
hum, not sure about loosing the '_event' here, but we are
not public yet, so we can always change back ;-) I do like
it'd follow the enum name
> I can go ahead and do it myself, updating each patch on this series to
> do that.
sure, I thought we'd do it later, but feel free to do it,
maybe in separate changes?
thanks,
jirka
Em Mon, Aug 26, 2019 at 06:47:34PM +0200, Jiri Olsa escreveu:
> On Mon, Aug 26, 2019 at 12:41:38PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Sun, Aug 25, 2019 at 08:17:40PM +0200, Jiri Olsa escreveu:
> > > hi,
> > > as a preparation for sampling libperf interface, moving event
> > > definitions into the library header. Moving just the kernel
> > > non-AUX events now.
> > >
> > > In order to keep libperf simple, we switch 'u64/u32/u16/u8'
> > > types used events to their generic '__u*' versions.
> > >
> > > Perf added 'u*' types mainly to ease up printing __u64 values
> > > as stated in the linux/types.h comment:
> > >
> > > /*
> > > * We define u64 as uint64_t for every architecture
> > > * so that we can print it with "%"PRIx64 without getting warnings.
> > > *
> > > * typedef __u64 u64;
> > > * typedef __s64 s64;
> > > */
> > >
> > > Adding and using new PRI_lu64 and PRI_lx64 macros to be used for
> > > that. Using extra '_' to ease up the reading and differentiate
> > > them from standard PRI*64 macros.
> >
> > I think we should take advantage of this moment to rename those structs
> > to have the 'perf_record_' prefix on them, I guess we could even remove
> > the _event from them, i.e.:
> >
> > 'struct mmap_event' becomes 'perf_record_mmap', as it is the description
> > for the PERF_RECORD_MMAP meta-data event, are you ok with that?
>
> hum, not sure about loosing the '_event' here, but we are
> not public yet, so we can always change back ;-) I do like
> it'd follow the enum name
So I'm making the already exported to libperf to be renamed to have the
same name as the PERF_RECORD_ enum they map to, just all lowercase.
Looks nice and also makes something exported by libperf to have a perf_
namespace prefix.
BTW: you forgot to move PERF_RECORD_CONTEXT_SWITCH :-)
> > I can go ahead and do it myself, updating each patch on this series to
> > do that.
>
> sure, I thought we'd do it later, but feel free to do it,
> maybe in separate changes?
I did it as a separate patch, one patch for all the PERF_RECORD_ already
moved to libperf.
Also some other minor stuff, like having that
perf_event.{bpf,ksymbol}_event renamed to play perf_event.{bpf,ksymbol},
like the other records. so to make this idiom more compact and less
redundant:
event->bpf_event
becomes:
event->bpf
ditto for ksymbol_event.
- Arnaldo
Em Mon, Aug 26, 2019 at 06:58:52PM +0200, Jiri Olsa escreveu:
> On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
>
> SNIP
>
> > [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' /tmp/build/perf/builtin-sched.i
> > printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, sample->cpu);
> > [perfbuilder@490c2c7bdaab ~]$
> >
> > And if we do this on a fedora:30 x86_64:
> >
> > $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> > [acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
> > printf("lost %" "l"
> > # 2646 "builtin-sched.c" 3 4
> > "l" "u"
> > # 2646 "builtin-sched.c"
> > " events on cpu %d\n", event->lost.lost, sample->cpu);
> > [acme@quaco perf]$
> >
> > I.e. on 32-bit arches we shouldn't add that extra "l", right?
>
> hum, I guess we could #ifdef it 64/32 bits
I tried to figure out how to fix this better, but the int-ll64.h versus
int-l64.h versus how __u64 is defined got me confused and I ended up
with:
#if __WORDSIZE == 64
/*
* /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining
* __u64 as long long unsigned int, and then -Werror=format= kicks in and
* complains of the mismatched types, so use these two special extra PRI
* macros to overcome that.
*/
#define PRI_lu64 "l" PRIu64
#define PRI_lx64 "l" PRIx64
#else
#define PRI_lu64 PRIu64
#define PRI_lx64 PRIx64
#endif
Builds in all the containers I have, 32-bit, 64-bit, old gccs/clangs,
new ones, uclibc, musl libc, glibc, etc
> >
> > I bet the build for the mips/mipsel will fail too, lemme see... Yeah,
> > both failed:
> >
> >
>> [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mips
> > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> > printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> > ^~~~~~~~
> > In file included from builtin-sched.c:31:
> > /usr/mips-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
> > # define __PRI64_PREFIX "ll"
> > ^
> > [root@quaco ~]#
> >
> > [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mipsel
> > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> > printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> > ^~~~~~~~
> > In file included from builtin-sched.c:31:
> > /usr/mipsel-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
> > # define __PRI64_PREFIX "ll"
> > ^
> > [root@quaco ~]#
> >
> > And also on a uclibc ARC arch container:
> >
> > [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/fedora\:24-x-ARC-uClibc
> > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> > printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> > ^~~~~~~~
> > In file included from builtin-sched.c:31:0:
> > /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/inttypes.h:47:28: note: format string is defined here
> > # define __PRI64_PREFIX "ll"
> > ^
> > [root@quaco ~]#
> >
> > The _fix_ will come after lunch :)
>
> thanks ;-)
>
> jirka
--
- Arnaldo
Em Mon, Aug 26, 2019 at 07:14:19PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Aug 26, 2019 at 06:58:52PM +0200, Jiri Olsa escreveu:
> > On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> >
> > SNIP
> >
> > > [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' /tmp/build/perf/builtin-sched.i
> > > printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, sample->cpu);
> > > [perfbuilder@490c2c7bdaab ~]$
> > >
> > > And if we do this on a fedora:30 x86_64:
> > >
> > > $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> > > [acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
> > > printf("lost %" "l"
> > > # 2646 "builtin-sched.c" 3 4
> > > "l" "u"
> > > # 2646 "builtin-sched.c"
> > > " events on cpu %d\n", event->lost.lost, sample->cpu);
> > > [acme@quaco perf]$
> > >
> > > I.e. on 32-bit arches we shouldn't add that extra "l", right?
> >
> > hum, I guess we could #ifdef it 64/32 bits
>
> I tried to figure out how to fix this better, but the int-ll64.h versus
> int-l64.h versus how __u64 is defined got me confused and I ended up
> with:
>
> #if __WORDSIZE == 64
Make that:
#ifdef __LP64__ to build on Alpine/musl libc.
- Arnaldo
> /*
> * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining
> * __u64 as long long unsigned int, and then -Werror=format= kicks in and
> * complains of the mismatched types, so use these two special extra PRI
> * macros to overcome that.
> */
> #define PRI_lu64 "l" PRIu64
> #define PRI_lx64 "l" PRIx64
> #else
> #define PRI_lu64 PRIu64
> #define PRI_lx64 PRIx64
> #endif
>
> Builds in all the containers I have, 32-bit, 64-bit, old gccs/clangs,
> new ones, uclibc, musl libc, glibc, etc
>
> > >
> > > I bet the build for the mips/mipsel will fail too, lemme see... Yeah,
> > > both failed:
> > >
> > >
> >> [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mips
> > > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> > > printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> > > ^~~~~~~~
> > > In file included from builtin-sched.c:31:
> > > /usr/mips-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
> > > # define __PRI64_PREFIX "ll"
> > > ^
> > > [root@quaco ~]#
> > >
> > > [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/debian\:experimental-x-mipsel
> > > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> > > printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> > > ^~~~~~~~
> > > In file included from builtin-sched.c:31:
> > > /usr/mipsel-linux-gnu/include/inttypes.h:47:28: note: format string is defined here
> > > # define __PRI64_PREFIX "ll"
> > > ^
> > > [root@quaco ~]#
> > >
> > > And also on a uclibc ARC arch container:
> > >
> > > [root@quaco ~]# grep -m1 -A6 -- -Werror=format= dm.log/fedora\:24-x-ARC-uClibc
> > > builtin-sched.c:2646:9: error: unknown conversion type character 'l' in format [-Werror=format=]
> > > printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
> > > ^~~~~~~~
> > > In file included from builtin-sched.c:31:0:
> > > /arc_gnu_2017.09-rc2_prebuilt_uclibc_le_arc700_linux_install/arc-snps-linux-uclibc/sysroot/usr/include/inttypes.h:47:28: note: format string is defined here
> > > # define __PRI64_PREFIX "ll"
> > > ^
> > > [root@quaco ~]#
> > >
> > > The _fix_ will come after lunch :)
> >
> > thanks ;-)
> >
> > jirka
>
> --
>
> - Arnaldo
--
- Arnaldo
On Mon, Aug 26, 2019 at 07:41:36PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Aug 26, 2019 at 07:14:19PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Mon, Aug 26, 2019 at 06:58:52PM +0200, Jiri Olsa escreveu:
> > > On Mon, Aug 26, 2019 at 01:18:49PM -0300, Arnaldo Carvalho de Melo wrote:
> > >
> > > SNIP
> > >
> > > > [perfbuilder@490c2c7bdaab ~]$ grep 'printf("lost' /tmp/build/perf/builtin-sched.i
> > > > printf("lost %" "l" "ll""u" " events on cpu %d\n", event->lost.lost, sample->cpu);
> > > > [perfbuilder@490c2c7bdaab ~]$
> > > >
> > > > And if we do this on a fedora:30 x86_64:
> > > >
> > > > $ make -C tools/perf O=/tmp/build/perf /tmp/build/perf/builtin-sched.i
> > > > [acme@quaco perf]$ grep -A4 'printf("lost' /tmp/build/perf/builtin-sched.i
> > > > printf("lost %" "l"
> > > > # 2646 "builtin-sched.c" 3 4
> > > > "l" "u"
> > > > # 2646 "builtin-sched.c"
> > > > " events on cpu %d\n", event->lost.lost, sample->cpu);
> > > > [acme@quaco perf]$
> > > >
> > > > I.e. on 32-bit arches we shouldn't add that extra "l", right?
> > >
> > > hum, I guess we could #ifdef it 64/32 bits
> >
> > I tried to figure out how to fix this better, but the int-ll64.h versus
> > int-l64.h versus how __u64 is defined got me confused and I ended up
> > with:
> >
> > #if __WORDSIZE == 64
>
> Make that:
>
> #ifdef __LP64__ to build on Alpine/musl libc.
awesome, thanks ;-)
jirka
The following commit has been merged into the perf/core branch of tip:
Commit-ID: bceb59b1f28d1ca812d816fd8f33c72b1a8378fb
Gitweb: https://git.kernel.org/tip/bceb59b1f28d1ca812d816fd8f33c72b1a8378fb
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:45 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:09 -03:00
libperf: Add PERF_RECORD_FORK 'struct fork_event' to perf/event.h
Move the fork_event event definition into libperf's event.h header
include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Add and use new PRI_lu64 and PRI_lx64 macros for that. Using extra '_'
to ease up the reading and differentiate them from standard PRI*64
macros.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 7 +++++++
tools/perf/util/event.h | 7 -------
tools/perf/util/python.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index b90a8a2..c7cae58 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -43,4 +43,11 @@ struct namespaces_event {
struct perf_ns_link_info link_info[];
};
+struct fork_event {
+ struct perf_event_header header;
+ __u32 pid, ppid;
+ __u32 tid, ptid;
+ __u64 time;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 0d3ac4f..38b258c 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,13 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-struct fork_event {
- struct perf_event_header header;
- u32 pid, ppid;
- u32 tid, ptid;
- u64 time;
-};
-
struct lost_event {
struct perf_event_header header;
u64 id;
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 55ff0c3..8bdadb2 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -170,7 +170,7 @@ static PyMemberDef pyrf_task_event__members[] = {
static PyObject *pyrf_task_event__repr(struct pyrf_event *pevent)
{
return _PyUnicode_FromFormat("{ type: %s, pid: %u, ppid: %u, tid: %u, "
- "ptid: %u, time: %" PRIu64 "}",
+ "ptid: %u, time: %" PRI_lu64 "}",
pevent->event.header.type == PERF_RECORD_FORK ? "fork" : "exit",
pevent->event.fork.pid,
pevent->event.fork.ppid,
The following commit has been merged into the perf/core branch of tip:
Commit-ID: b1fcd190bb3fc1234dca60390d171a4cc75b21b2
Gitweb: https://git.kernel.org/tip/b1fcd190bb3fc1234dca60390d171a4cc75b21b2
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:52 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:10 -03:00
libperf: Add PERF_RECORD_SAMPLE 'struct sample_event' to perf/event.h
Move the PERF_RECORD_SAMPLE event definition to libperf's event.h header
include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 5 +++++
tools/perf/util/event.h | 5 -----
tools/perf/util/evlist.c | 2 +-
tools/perf/util/evsel.c | 8 ++++----
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 585c9d8..e768a2d 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -104,4 +104,9 @@ struct bpf_event {
__u8 tag[BPF_TAG_SIZE]; // prog tag
};
+struct sample_event {
+ struct perf_event_header header;
+ __u64 array[];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 091a069..dee0ee5 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -37,11 +37,6 @@
/* perf sample has 16 bits size limit */
#define PERF_SAMPLE_MAX_SIZE (1 << 16)
-struct sample_event {
- struct perf_event_header header;
- u64 array[];
-};
-
struct regs_dump {
u64 abi;
u64 mask;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index ff41568..47bc541 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -587,7 +587,7 @@ struct evsel *perf_evlist__id2evsel_strict(struct evlist *evlist,
static int perf_evlist__event2id(struct evlist *evlist,
union perf_event *event, u64 *id)
{
- const u64 *array = event->sample.array;
+ const __u64 *array = event->sample.array;
ssize_t n;
n = (event->header.size - sizeof(event->header)) >> 3;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 9fadd58..778262f 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2009,7 +2009,7 @@ static int perf_evsel__parse_id_sample(const struct evsel *evsel,
struct perf_sample *sample)
{
u64 type = evsel->core.attr.sample_type;
- const u64 *array = event->sample.array;
+ const __u64 *array = event->sample.array;
bool swapped = evsel->needs_swap;
union u64_swap u;
@@ -2099,7 +2099,7 @@ int perf_evsel__parse_sample(struct evsel *evsel, union perf_event *event,
{
u64 type = evsel->core.attr.sample_type;
bool swapped = evsel->needs_swap;
- const u64 *array;
+ const __u64 *array;
u16 max_size = event->header.size;
const void *endp = (void *)event + max_size;
u64 sz;
@@ -2378,7 +2378,7 @@ int perf_evsel__parse_sample_timestamp(struct evsel *evsel,
u64 *timestamp)
{
u64 type = evsel->core.attr.sample_type;
- const u64 *array;
+ const __u64 *array;
if (!(type & PERF_SAMPLE_TIME))
return -1;
@@ -2529,7 +2529,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
u64 read_format,
const struct perf_sample *sample)
{
- u64 *array;
+ __u64 *array;
size_t sz;
/*
* used for cross-endian analysis. See git commit 65014ab3
The following commit has been merged into the perf/core branch of tip:
Commit-ID: a2e254d84172f7eb638261a83024d849f78c89e9
Gitweb: https://git.kernel.org/tip/a2e254d84172f7eb638261a83024d849f78c89e9
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:47 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:10 -03:00
libperf: Add PERF_RECORD_LOST_SAMPLES 'struct lost_samples_event' to perf/event.h
Move the PERF_RECORD_LOST_SAMPLES event definition into libperf's
event.h header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to
ease up the reading and differentiate them from standard PRI*64 macros.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 5 +++++
tools/perf/util/event.h | 5 -----
tools/perf/util/machine.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 71045ea..86a7795 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -56,4 +56,9 @@ struct lost_event {
__u64 lost;
};
+struct lost_samples_event {
+ struct perf_event_header header;
+ __u64 lost;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 4a3f502..976a8f0 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,11 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-struct lost_samples_event {
- struct perf_event_header header;
- u64 lost;
-};
-
/*
* PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
*/
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 1ad6e98..823aaf7 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -653,7 +653,7 @@ int machine__process_lost_event(struct machine *machine __maybe_unused,
int machine__process_lost_samples_event(struct machine *machine __maybe_unused,
union perf_event *event, struct perf_sample *sample)
{
- dump_printf(": id:%" PRIu64 ": lost samples :%" PRIu64 "\n",
+ dump_printf(": id:%" PRIu64 ": lost samples :%" PRI_lu64 "\n",
sample->id, event->lost_samples.lost);
return 0;
}
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 5290ed6955ebc481d5cd62f7175e8514931058bc
Gitweb: https://git.kernel.org/tip/5290ed6955ebc481d5cd62f7175e8514931058bc
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:46 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:09 -03:00
libperf: Add PERF_RECORD_LOST 'struct lost_event' to perf/event.h
Move the lost_event event definition to libperf's event.h header
include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values as stated
in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to
ease up the reading and differentiate them from standard PRI*64 macros.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-sched.c | 2 +-
tools/perf/lib/include/perf/event.h | 6 ++++++
tools/perf/util/event.c | 2 +-
tools/perf/util/event.h | 6 ------
tools/perf/util/machine.c | 2 +-
tools/perf/util/python.c | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0d6b4c3..025151d 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2643,7 +2643,7 @@ static int process_lost(struct perf_tool *tool __maybe_unused,
timestamp__scnprintf_usec(sample->time, tstr, sizeof(tstr));
printf("%15s ", tstr);
- printf("lost %" PRIu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
+ printf("lost %" PRI_lu64 " events on cpu %d\n", event->lost.lost, sample->cpu);
return 0;
}
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index c7cae58..71045ea 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -50,4 +50,10 @@ struct fork_event {
__u64 time;
};
+struct lost_event {
+ struct perf_event_header header;
+ __u64 id;
+ __u64 lost;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 0954f98..3bd9fc2 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1480,7 +1480,7 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " lost %" PRIu64 "\n", event->lost.lost);
+ return fprintf(fp, " lost %" PRI_lu64 "\n", event->lost.lost);
}
size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp)
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 38b258c..4a3f502 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,12 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-struct lost_event {
- struct perf_event_header header;
- u64 id;
- u64 lost;
-};
-
struct lost_samples_event {
struct perf_event_header header;
u64 lost;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 47430af..1ad6e98 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -645,7 +645,7 @@ int machine__process_namespaces_event(struct machine *machine __maybe_unused,
int machine__process_lost_event(struct machine *machine __maybe_unused,
union perf_event *event, struct perf_sample *sample __maybe_unused)
{
- dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n",
+ dump_printf(": id:%" PRI_lu64 ": lost:%" PRI_lu64 "\n",
event->lost.id, event->lost.lost);
return 0;
}
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 8bdadb2..5be85f5 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -263,8 +263,8 @@ static PyObject *pyrf_lost_event__repr(struct pyrf_event *pevent)
PyObject *ret;
char *s;
- if (asprintf(&s, "{ type: lost, id: %#" PRIx64 ", "
- "lost: %#" PRIx64 " }",
+ if (asprintf(&s, "{ type: lost, id: %#" PRI_lx64 ", "
+ "lost: %#" PRI_lx64 " }",
pevent->event.lost.id, pevent->event.lost.lost) < 0) {
ret = PyErr_NoMemory();
} else {
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 002dda32a831b30d22a3620eb619a0d103e78e81
Gitweb: https://git.kernel.org/tip/002dda32a831b30d22a3620eb619a0d103e78e81
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:43 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:09 -03:00
libperf: Add PERF_RECORD_COMM 'struct comm_event' to perf/event.h
Moving comm_event event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 6 ++++++
tools/perf/util/event.h | 6 ------
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index c82e0c2..3729a7d 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -30,4 +30,10 @@ struct mmap2_event {
char filename[PATH_MAX];
};
+struct comm_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ char comm[16];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index af252be..e8973a7 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,12 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-struct comm_event {
- struct perf_event_header header;
- u32 pid, tid;
- char comm[16];
-};
-
struct namespaces_event {
struct perf_event_header header;
u32 pid, tid;
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 003c66fec28fea52825b60cad98af8cf11074d76
Gitweb: https://git.kernel.org/tip/003c66fec28fea52825b60cad98af8cf11074d76
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:49 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:10 -03:00
libperf: Add PERF_RECORD_THROTTLE 'struct throttle_event' to perf/event.h
Move the PERF_RECORD_THROTTLE event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values as stated
in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to
ease up the reading and differentiate them from standard PRI*64 macros.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 7 +++++++
tools/perf/util/event.h | 7 -------
tools/perf/util/python.c | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index f183070..ef5ec66 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -73,4 +73,11 @@ struct read_event {
__u64 id;
};
+struct throttle_event {
+ struct perf_event_header header;
+ __u64 time;
+ __u64 id;
+ __u64 stream_id;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 008a283..40020f5 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,13 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-struct throttle_event {
- struct perf_event_header header;
- u64 time;
- u64 id;
- u64 stream_id;
-};
-
#ifndef KSYM_NAME_LEN
#define KSYM_NAME_LEN 256
#endif
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 5be85f5..d21e270 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -233,8 +233,8 @@ static PyObject *pyrf_throttle_event__repr(struct pyrf_event *pevent)
{
struct throttle_event *te = (struct throttle_event *)(&pevent->event.header + 1);
- return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRIu64 ", id: %" PRIu64
- ", stream_id: %" PRIu64 " }",
+ return _PyUnicode_FromFormat("{ type: %sthrottle, time: %" PRI_lu64 ", id: %" PRI_lu64
+ ", stream_id: %" PRI_lu64 " }",
pevent->event.header.type == PERF_RECORD_THROTTLE ? "" : "un",
te->time, te->id, te->stream_id);
}
The following commit has been merged into the perf/core branch of tip:
Commit-ID: f15e3c25a1b40794a0ef2647360afe873fe34f54
Gitweb: https://git.kernel.org/tip/f15e3c25a1b40794a0ef2647360afe873fe34f54
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:50 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:10 -03:00
libperf: Add PERF_RECORD_KSYMBOL 'struct ksymbol_event' to perf/event.h
Move the PERF_RECORD_KSYMBOL event definition into libperf's event.h
header include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to
ease up the reading and differentiate them from standard PRI*64 macros.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 13 +++++++++++++
tools/perf/util/event.c | 2 +-
tools/perf/util/event.h | 13 -------------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index ef5ec66..8c36793 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -80,4 +80,17 @@ struct throttle_event {
__u64 stream_id;
};
+#ifndef KSYM_NAME_LEN
+#define KSYM_NAME_LEN 256
+#endif
+
+struct ksymbol_event {
+ struct perf_event_header header;
+ __u64 addr;
+ __u32 len;
+ __u16 ksym_type;
+ __u16 flags;
+ char name[KSYM_NAME_LEN];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 3bd9fc2..4447cd2 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1485,7 +1485,7 @@ static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp)
size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " addr %" PRIx64 " len %u type %u flags 0x%x name %s\n",
+ return fprintf(fp, " addr %" PRI_lx64 " len %u type %u flags 0x%x name %s\n",
event->ksymbol_event.addr, event->ksymbol_event.len,
event->ksymbol_event.ksym_type,
event->ksymbol_event.flags, event->ksymbol_event.name);
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 40020f5..c4eec1f 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,19 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-#ifndef KSYM_NAME_LEN
-#define KSYM_NAME_LEN 256
-#endif
-
-struct ksymbol_event {
- struct perf_event_header header;
- u64 addr;
- u32 len;
- u16 ksym_type;
- u16 flags;
- char name[KSYM_NAME_LEN];
-};
-
struct bpf_event {
struct perf_event_header header;
u16 type;
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 213a6c1d20687d44acaa1cb4f77ce5bae4f1dd8f
Gitweb: https://git.kernel.org/tip/213a6c1d20687d44acaa1cb4f77ce5bae4f1dd8f
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:48 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:10 -03:00
libperf: Add PERF_RECORD_READ 'struct read_event' to perf/event.h
Move the PERF_RECORD_READ event definition to libperf's event.h header
include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values
as stated in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_' to
ease up the reading and differentiate them from standard PRI*64 macros.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 12 ++++++++++++
tools/perf/util/event.h | 12 ------------
tools/perf/util/session.c | 8 ++++----
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 86a7795..f183070 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -61,4 +61,16 @@ struct lost_samples_event {
__u64 lost;
};
+/*
+ * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
+ */
+struct read_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 value;
+ __u64 time_enabled;
+ __u64 time_running;
+ __u64 id;
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 976a8f0..008a283 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,18 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-/*
- * PERF_FORMAT_ENABLED | PERF_FORMAT_RUNNING | PERF_FORMAT_ID
- */
-struct read_event {
- struct perf_event_header header;
- u32 pid, tid;
- u64 value;
- u64 time_enabled;
- u64 time_running;
- u64 id;
-};
-
struct throttle_event {
struct perf_event_header header;
u64 time;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 82e0438..cb1d8dc 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1260,7 +1260,7 @@ static void dump_read(struct evsel *evsel, union perf_event *event)
if (!dump_trace)
return;
- printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
+ printf(": %d %d %s %" PRI_lu64 "\n", event->read.pid, event->read.tid,
perf_evsel__name(evsel),
event->read.value);
@@ -1270,13 +1270,13 @@ static void dump_read(struct evsel *evsel, union perf_event *event)
read_format = evsel->core.attr.read_format;
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
- printf("... time enabled : %" PRIu64 "\n", read_event->time_enabled);
+ printf("... time enabled : %" PRI_lu64 "\n", read_event->time_enabled);
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
- printf("... time running : %" PRIu64 "\n", read_event->time_running);
+ printf("... time running : %" PRI_lu64 "\n", read_event->time_running);
if (read_format & PERF_FORMAT_ID)
- printf("... id : %" PRIu64 "\n", read_event->id);
+ printf("... id : %" PRI_lu64 "\n", read_event->id);
}
static struct machine *machines__find_for_cpumode(struct machines *machines,
The following commit has been merged into the perf/core branch of tip:
Commit-ID: b1b510142283c02991f48b27d399852364f7d89b
Gitweb: https://git.kernel.org/tip/b1b510142283c02991f48b27d399852364f7d89b
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:51 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:10 -03:00
libperf: Add PERF_RECORD_BPF_EVENT 'struct bpf_event' to perf/event.h
Move the PERF_RECORD_BPF_EVENT event definition to libperf's event.h.
In order to keep libperf simple, we switch 'u64/u32/u16/u8'
types used events to their generic '__u*' versions.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 11 +++++++++++
tools/perf/util/event.h | 10 ----------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 8c36793..585c9d8 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -5,6 +5,7 @@
#include <linux/perf_event.h>
#include <linux/types.h>
#include <linux/limits.h>
+#include <linux/bpf.h>
struct mmap_event {
struct perf_event_header header;
@@ -93,4 +94,14 @@ struct ksymbol_event {
char name[KSYM_NAME_LEN];
};
+struct bpf_event {
+ struct perf_event_header header;
+ __u16 type;
+ __u16 flags;
+ __u32 id;
+
+ /* for bpf_prog types */
+ __u8 tag[BPF_TAG_SIZE]; // prog tag
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index c4eec1f..091a069 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,16 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-struct bpf_event {
- struct perf_event_header header;
- u16 type;
- u16 flags;
- u32 id;
-
- /* for bpf_prog types */
- u8 tag[BPF_TAG_SIZE]; // prog tag
-};
-
#define PERF_SAMPLE_MASK \
(PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
PERF_SAMPLE_TIME | PERF_SAMPLE_ADDR | \
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 19d1765a3ed9a8f78d93909120f6d39398809f75
Gitweb: https://git.kernel.org/tip/19d1765a3ed9a8f78d93909120f6d39398809f75
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:44 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:39:09 -03:00
libperf: Add PERF_RECORD_NAMESPACES 'struct namespaces_event' to perf/event.h
Move the namespaces_event event definition into libperf's event.h header
include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 7 +++++++
tools/perf/util/event.h | 7 -------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
index 3729a7d..b90a8a2 100644
--- a/tools/perf/lib/include/perf/event.h
+++ b/tools/perf/lib/include/perf/event.h
@@ -36,4 +36,11 @@ struct comm_event {
char comm[16];
};
+struct namespaces_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 nr_namespaces;
+ struct perf_ns_link_info link_info[];
+};
+
#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index e8973a7..0d3ac4f 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -27,13 +27,6 @@
#define PRI_lx64 PRIx64
#endif
-struct namespaces_event {
- struct perf_event_header header;
- u32 pid, tid;
- u64 nr_namespaces;
- struct perf_ns_link_info link_info[];
-};
-
struct fork_event {
struct perf_event_header header;
u32 pid, ppid;
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 1345e2ee87a83c758f336f03f7fb305bc5e24490
Gitweb: https://git.kernel.org/tip/1345e2ee87a83c758f336f03f7fb305bc5e24490
Author: Jiri Olsa <[email protected]>
AuthorDate: Sun, 25 Aug 2019 20:17:41 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 26 Aug 2019 19:38:04 -03:00
libperf: Add PERF_RECORD_MMAP 'struct mmap_event' to perf/event.h
Move the mmap_event event definition to libperf's event.h header
include.
In order to keep libperf simple, we switch 'u64/u32/u16/u8' types used
events to their generic '__u*' versions.
Perf added 'u*' types mainly to ease up printing __u64 values as stated
in the linux/types.h comment:
/*
* We define u64 as uint64_t for every architecture
* so that we can print it with "%"PRIx64 without getting warnings.
*
* typedef __u64 u64;
* typedef __s64 s64;
*/
Add and use new PRI_lu64 and PRI_lx64 macros for that. Use extra '_'
to ease up reading and differentiate them from standard PRI*64 macros.
Committer notes:
Fixup the PRI_l[ux]64 macros on 32-bit arches, conditionally defining it
with that extra 'l' modifier only on arches where __u64 is long long,
leaving it aside on 32-bit arches.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/lib/include/perf/event.h | 18 ++++++++++++++++++
tools/perf/util/event.c | 2 +-
tools/perf/util/event.h | 22 ++++++++++++++--------
tools/perf/util/python.c | 4 ++--
4 files changed, 35 insertions(+), 11 deletions(-)
create mode 100644 tools/perf/lib/include/perf/event.h
diff --git a/tools/perf/lib/include/perf/event.h b/tools/perf/lib/include/perf/event.h
new file mode 100644
index 0000000..13fe15a
--- /dev/null
+++ b/tools/perf/lib/include/perf/event.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LIBPERF_EVENT_H
+#define __LIBPERF_EVENT_H
+
+#include <linux/perf_event.h>
+#include <linux/types.h>
+#include <linux/limits.h>
+
+struct mmap_event {
+ struct perf_event_header header;
+ __u32 pid, tid;
+ __u64 start;
+ __u64 len;
+ __u64 pgoff;
+ char filename[PATH_MAX];
+};
+
+#endif /* __LIBPERF_EVENT_H */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 332edef..43c8625 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1353,7 +1353,7 @@ int perf_event__process_bpf_event(struct perf_tool *tool __maybe_unused,
size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %c %s\n",
+ return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 "]: %c %s\n",
event->mmap.pid, event->mmap.tid, event->mmap.start,
event->mmap.len, event->mmap.pgoff,
(event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x',
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 0e164e8..f43eff2 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -7,19 +7,25 @@
#include <linux/kernel.h>
#include <linux/bpf.h>
#include <linux/perf_event.h>
+#include <perf/event.h>
#include "../perf.h"
#include "build-id.h"
#include "perf_regs.h"
-struct mmap_event {
- struct perf_event_header header;
- u32 pid, tid;
- u64 start;
- u64 len;
- u64 pgoff;
- char filename[PATH_MAX];
-};
+#ifdef __LP64__
+/*
+ * /usr/include/inttypes.h uses just 'lu' for PRIu64, but we end up defining
+ * __u64 as long long unsigned int, and then -Werror=format= kicks in and
+ * complains of the mismatched types, so use these two special extra PRI
+ * macros to overcome that.
+ */
+#define PRI_lu64 "l" PRIu64
+#define PRI_lx64 "l" PRIx64
+#else
+#define PRI_lu64 PRIu64
+#define PRI_lx64 PRIx64
+#endif
struct mmap2_event {
struct perf_event_header header;
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 75ecc32..55ff0c3 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -130,8 +130,8 @@ static PyObject *pyrf_mmap_event__repr(struct pyrf_event *pevent)
PyObject *ret;
char *s;
- if (asprintf(&s, "{ type: mmap, pid: %u, tid: %u, start: %#" PRIx64 ", "
- "length: %#" PRIx64 ", offset: %#" PRIx64 ", "
+ if (asprintf(&s, "{ type: mmap, pid: %u, tid: %u, start: %#" PRI_lx64 ", "
+ "length: %#" PRI_lx64 ", offset: %#" PRI_lx64 ", "
"filename: %s }",
pevent->event.mmap.pid, pevent->event.mmap.tid,
pevent->event.mmap.start, pevent->event.mmap.len,