aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/perf/util/evswitch.c
blob: c87f988d81c856e10a1d3094c336d29c26cf8112 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}