[tip:perf/core] perf test: Suppress libtraceevent warnings

From: tip-bot for Namhyung Kim
Date: Tue Oct 20 2015 - 03:43:35 EST


Commit-ID: 2690c730935873065175de33f59cce5bb221b9dc
Gitweb: http://git.kernel.org/tip/2690c730935873065175de33f59cce5bb221b9dc
Author: Namhyung Kim <namhyung@xxxxxxxxxx>
AuthorDate: Tue, 20 Oct 2015 00:23:49 +0900
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Mon, 19 Oct 2015 14:58:10 -0300

perf test: Suppress libtraceevent warnings

Currently libtraceevent emits warning on unsupported event formats.
However it'd be better to see them only -v option is given. To do that,
it needs to override the warning() function which is used in the
libtracevent. Thus add set_warning_routine() same as set_die_routine()
and check the verbose flag in our warning routine.

Before:
# perf test 5
5: parse events tests :
Warning: [kvmmmu:kvm_mmu_get_page] bad op token {
Warning: [kvmmmu:kvm_mmu_sync_page] bad op token {
Warning: [kvmmmu:kvm_mmu_unsync_page] bad op token {
Warning: [kvmmmu:kvm_mmu_prepare_zap_page] bad op token {
Warning: [kvmmmu:fast_page_fault] function is_writable_pte not defined
...
Ok

After:
# perf test 5
5: parse events tests : Ok

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Tested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Acked-by: David Ahern <dsahern@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Wang Nan <wangnan0@xxxxxxxxxx>
Link: http://lkml.kernel.org/r/1445268229-1601-2-git-send-email-namhyung@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/tests/parse-events.c | 14 ++++++++++++++
tools/perf/util/usage.c | 5 +++++
tools/perf/util/util.h | 1 +
3 files changed, 20 insertions(+)

diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 0648b84..636d7b4 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -5,6 +5,7 @@
#include <api/fs/fs.h>
#include "tests.h"
#include "debug.h"
+#include "util.h"
#include <linux/hw_breakpoint.h>
#include <api/fs/fs.h>

@@ -1753,6 +1754,17 @@ static int test_pmu_events(void)
return ret;
}

+static void debug_warn(const char *warn, va_list params)
+{
+ char msg[1024];
+
+ if (!verbose)
+ return;
+
+ vsnprintf(msg, sizeof(msg), warn, params);
+ fprintf(stderr, " Warning: %s\n", msg);
+}
+
int test__parse_events(void)
{
int ret1, ret2 = 0;
@@ -1764,6 +1776,8 @@ do { \
ret2 = ret1; \
} while (0)

+ set_warning_routine(debug_warn);
+
TEST_EVENTS(test__events);

if (test_pmu())
diff --git a/tools/perf/util/usage.c b/tools/perf/util/usage.c
index 4007aca..6adfa18 100644
--- a/tools/perf/util/usage.c
+++ b/tools/perf/util/usage.c
@@ -50,6 +50,11 @@ void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN)
die_routine = routine;
}

+void set_warning_routine(void (*routine)(const char *err, va_list params))
+{
+ warn_routine = routine;
+}
+
void usage(const char *err)
{
usage_routine(err);
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 3d5b01e..4cfb913 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -145,6 +145,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))


extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
+extern void set_warning_routine(void (*routine)(const char *err, va_list params));

extern int prefixcmp(const char *str, const char *prefix);
extern void set_buildid_dir(const char *dir);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/