aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evswitch.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2019-08-15 11:00:11 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-08-15 12:24:31 -0300
commit8829e56fa050998164e496d380cd69186ae9b8d0 (patch)
treec7ea46f40b3d52bd171555b6ad87d90785081081 /tools/perf/util/evswitch.c
parentperf evswitch: Move struct to a separate header to use in other tools (diff)
downloadlinux-dev-8829e56fa050998164e496d380cd69186ae9b8d0.tar.xz
linux-dev-8829e56fa050998164e496d380cd69186ae9b8d0.zip
perf evswitch: Move switch logic to use in other tools
Now other tools that want switching can use an evswitch for that, just set it up and add it to the PERF_RECORD_SAMPLE processing function. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Florian Weimer <fweimer@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: William Cohen <wcohen@redhat.com> Link: https://lkml.kernel.org/n/tip-b1trj1q97qwfv251l66q3noj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evswitch.c')
-rw-r--r--tools/perf/util/evswitch.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/perf/util/evswitch.c b/tools/perf/util/evswitch.c
new file mode 100644
index 000000000000..c87f988d81c8
--- /dev/null
+++ b/tools/perf/util/evswitch.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
+
+#include "evswitch.h"
+
+bool evswitch__discard(struct evswitch *evswitch, struct evsel *evsel)
+{
+ if (evswitch->on && evswitch->discarding) {
+ if (evswitch->on != evsel)
+ return true;
+
+ evswitch->discarding = false;
+
+ if (!evswitch->show_on_off_events)
+ return true;
+
+ return false;
+ }
+
+ if (evswitch->off && !evswitch->discarding) {
+ if (evswitch->off != evsel)
+ return false;
+
+ evswitch->discarding = true;
+
+ if (!evswitch->show_on_off_events)
+ return true;
+ }
+
+ return false;
+}