Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <traceevent/event-parse.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include "evsel.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include "tests.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include "debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) static int perf_evsel__test_field(struct evsel *evsel, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 				  int size, bool should_be_signed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	struct tep_format_field *field = evsel__field(evsel, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	int is_signed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	if (field == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 		pr_debug("%s: \"%s\" field not found!\n", evsel->name, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	if (should_be_signed && !is_signed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 			 evsel->name, name, is_signed, should_be_signed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	if (field->size != size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		pr_debug("%s: \"%s\" size (%d) should be %d!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 			 evsel->name, name, field->size, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtest __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	struct evsel *evsel = evsel__newtp("sched", "sched_switch");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	if (IS_ERR(evsel)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (perf_evsel__test_field(evsel, "prev_comm", 16, false))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	if (perf_evsel__test_field(evsel, "prev_pid", 4, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (perf_evsel__test_field(evsel, "prev_prio", 4, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	if (perf_evsel__test_field(evsel, "prev_state", sizeof(long), true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	if (perf_evsel__test_field(evsel, "next_comm", 16, false))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	if (perf_evsel__test_field(evsel, "next_pid", 4, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	if (perf_evsel__test_field(evsel, "next_prio", 4, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	evsel__delete(evsel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	evsel = evsel__newtp("sched", "sched_wakeup");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	if (IS_ERR(evsel)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 		pr_debug("evsel__newtp failed with %ld\n", PTR_ERR(evsel));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	if (perf_evsel__test_field(evsel, "comm", 16, false))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	if (perf_evsel__test_field(evsel, "pid", 4, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	if (perf_evsel__test_field(evsel, "prio", 4, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	if (perf_evsel__test_field(evsel, "target_cpu", 4, true))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 		ret = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 	evsel__delete(evsel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }