diff options
Diffstat (limited to 'tools/perf/tests')
| -rw-r--r-- | tools/perf/tests/builtin-test.c | 2 | ||||
| -rw-r--r-- | tools/perf/tests/code-reading.c | 13 | ||||
| -rw-r--r-- | tools/perf/tests/dwarf-unwind.c | 18 | ||||
| -rw-r--r-- | tools/perf/tests/hists_filter.c | 2 | ||||
| -rw-r--r-- | tools/perf/tests/mmap-thread-lookup.c | 2 | ||||
| -rw-r--r-- | tools/perf/tests/parse-events.c | 58 | ||||
| -rw-r--r-- | tools/perf/tests/sample-parsing.c | 55 | 
7 files changed, 115 insertions, 35 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 162c978f1491..4b7d9ab0f049 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -85,7 +85,7 @@ static struct test {  		.func = test__hists_link,  	},  	{ -		.desc = "Try 'use perf' in python, checking link problems", +		.desc = "Try 'import perf' in python, checking link problems",  		.func = test__python_use,  	},  	{ diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 67f2d6323558..f671ec37a7c4 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -133,8 +133,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,  }  static int read_object_code(u64 addr, size_t len, u8 cpumode, -			    struct thread *thread, struct machine *machine, -			    struct state *state) +			    struct thread *thread, struct state *state)  {  	struct addr_location al;  	unsigned char buf1[BUFSZ]; @@ -145,8 +144,7 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,  	pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr); -	thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, addr, -			      &al); +	thread__find_addr_map(thread, cpumode, MAP__FUNCTION, addr, &al);  	if (!al.map || !al.map->dso) {  		pr_debug("thread__find_addr_map failed\n");  		return -1; @@ -170,8 +168,8 @@ static int read_object_code(u64 addr, size_t len, u8 cpumode,  		len = al.map->end - addr;  	/* Read the object code using perf */ -	ret_len = dso__data_read_offset(al.map->dso, machine, al.addr, buf1, -					len); +	ret_len = dso__data_read_offset(al.map->dso, thread->mg->machine, +					al.addr, buf1, len);  	if (ret_len != len) {  		pr_debug("dso__data_read_offset failed\n");  		return -1; @@ -264,8 +262,7 @@ static int process_sample_event(struct machine *machine,  	cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; -	return read_object_code(sample.ip, READLEN, cpumode, thread, machine, -				state); +	return read_object_code(sample.ip, READLEN, cpumode, thread, state);  }  static int process_event(struct machine *machine, struct perf_evlist *evlist, diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c index fc25e57f4a5d..ab28cca2cb97 100644 --- a/tools/perf/tests/dwarf-unwind.c +++ b/tools/perf/tests/dwarf-unwind.c @@ -59,7 +59,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)  }  __attribute__ ((noinline)) -static int unwind_thread(struct thread *thread, struct machine *machine) +static int unwind_thread(struct thread *thread)  {  	struct perf_sample sample;  	unsigned long cnt = 0; @@ -72,7 +72,7 @@ static int unwind_thread(struct thread *thread, struct machine *machine)  		goto out;  	} -	err = unwind__get_entries(unwind_entry, &cnt, machine, thread, +	err = unwind__get_entries(unwind_entry, &cnt, thread,  				  &sample, MAX_STACK);  	if (err)  		pr_debug("unwind failed\n"); @@ -89,21 +89,21 @@ static int unwind_thread(struct thread *thread, struct machine *machine)  }  __attribute__ ((noinline)) -static int krava_3(struct thread *thread, struct machine *machine) +static int krava_3(struct thread *thread)  { -	return unwind_thread(thread, machine); +	return unwind_thread(thread);  }  __attribute__ ((noinline)) -static int krava_2(struct thread *thread, struct machine *machine) +static int krava_2(struct thread *thread)  { -	return krava_3(thread, machine); +	return krava_3(thread);  }  __attribute__ ((noinline)) -static int krava_1(struct thread *thread, struct machine *machine) +static int krava_1(struct thread *thread)  { -	return krava_2(thread, machine); +	return krava_2(thread);  }  int test__dwarf_unwind(void) @@ -137,7 +137,7 @@ int test__dwarf_unwind(void)  		goto out;  	} -	err = krava_1(thread, machine); +	err = krava_1(thread);   out:  	machine__delete_threads(machine); diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index 5a31787cc6b9..74f257a81265 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -43,7 +43,7 @@ static struct sample fake_samples[] = {  };  static int add_hist_entries(struct perf_evlist *evlist, -			    struct machine *machine __maybe_unused) +			    struct machine *machine)  {  	struct perf_evsel *evsel;  	struct addr_location al; diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c index 4a456fef66ca..2113f1c8611f 100644 --- a/tools/perf/tests/mmap-thread-lookup.c +++ b/tools/perf/tests/mmap-thread-lookup.c @@ -187,7 +187,7 @@ static int mmap_events(synth_cb synth)  		pr_debug("looking for map %p\n", td->map); -		thread__find_addr_map(thread, machine, +		thread__find_addr_map(thread,  				      PERF_RECORD_MISC_USER, MAP__FUNCTION,  				      (unsigned long) (td->map + 1), &al); diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 7f2f51f93619..4169f460efa1 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1145,6 +1145,49 @@ static int test__pinned_group(struct perf_evlist *evlist)  	return 0;  } +static int test__checkevent_breakpoint_len(struct perf_evlist *evlist) +{ +	struct perf_evsel *evsel = perf_evlist__first(evlist); + +	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); +	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); +	TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); +	TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == +					 evsel->attr.bp_type); +	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 == +					evsel->attr.bp_len); + +	return 0; +} + +static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist) +{ +	struct perf_evsel *evsel = perf_evlist__first(evlist); + +	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); +	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); +	TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); +	TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W == +					 evsel->attr.bp_type); +	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 == +					evsel->attr.bp_len); + +	return 0; +} + +static int +test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist) +{ +	struct perf_evsel *evsel = perf_evlist__first(evlist); + +	TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); +	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); +	TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); +	TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); + +	return test__checkevent_breakpoint_rw(evlist); +} +  static int count_tracepoints(void)  {  	char events_path[PATH_MAX]; @@ -1420,6 +1463,21 @@ static struct evlist_test test__events[] = {  		.check = test__pinned_group,  		.id    = 41,  	}, +	{ +		.name  = "mem:0/1", +		.check = test__checkevent_breakpoint_len, +		.id    = 42, +	}, +	{ +		.name  = "mem:0/2:w", +		.check = test__checkevent_breakpoint_len_w, +		.id    = 43, +	}, +	{ +		.name  = "mem:0/4:rw:u", +		.check = test__checkevent_breakpoint_len_rw_modifier, +		.id    = 44 +	},  #if defined(__s390x__)  	{  		.name  = "kvm-s390:kvm_s390_create_vm", diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index ca292f9a4ae2..4908c648a597 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c @@ -126,16 +126,28 @@ static bool samples_same(const struct perf_sample *s1,  	if (type & PERF_SAMPLE_TRANSACTION)  		COMP(transaction); +	if (type & PERF_SAMPLE_REGS_INTR) { +		size_t sz = hweight_long(s1->intr_regs.mask) * sizeof(u64); + +		COMP(intr_regs.mask); +		COMP(intr_regs.abi); +		if (s1->intr_regs.abi && +		    (!s1->intr_regs.regs || !s2->intr_regs.regs || +		     memcmp(s1->intr_regs.regs, s2->intr_regs.regs, sz))) { +			pr_debug("Samples differ at 'intr_regs'\n"); +			return false; +		} +	} +  	return true;  } -static int do_test(u64 sample_type, u64 sample_regs_user, u64 read_format) +static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)  {  	struct perf_evsel evsel = {  		.needs_swap = false,  		.attr = {  			.sample_type = sample_type, -			.sample_regs_user = sample_regs_user,  			.read_format = read_format,  		},  	}; @@ -154,7 +166,7 @@ static int do_test(u64 sample_type, u64 sample_regs_user, u64 read_format)  		/* 1 branch_entry */  		.data = {1, 211, 212, 213},  	}; -	u64 user_regs[64]; +	u64 regs[64];  	const u64 raw_data[] = {0x123456780a0b0c0dULL, 0x1102030405060708ULL};  	const u64 data[] = {0x2211443366558877ULL, 0, 0xaabbccddeeff4321ULL};  	struct perf_sample sample = { @@ -176,8 +188,8 @@ static int do_test(u64 sample_type, u64 sample_regs_user, u64 read_format)  		.branch_stack	= &branch_stack.branch_stack,  		.user_regs	= {  			.abi	= PERF_SAMPLE_REGS_ABI_64, -			.mask	= sample_regs_user, -			.regs	= user_regs, +			.mask	= sample_regs, +			.regs	= regs,  		},  		.user_stack	= {  			.size	= sizeof(data), @@ -187,14 +199,25 @@ static int do_test(u64 sample_type, u64 sample_regs_user, u64 read_format)  			.time_enabled = 0x030a59d664fca7deULL,  			.time_running = 0x011b6ae553eb98edULL,  		}, +		.intr_regs	= { +			.abi	= PERF_SAMPLE_REGS_ABI_64, +			.mask	= sample_regs, +			.regs	= regs, +		},  	};  	struct sample_read_value values[] = {{1, 5}, {9, 3}, {2, 7}, {6, 4},};  	struct perf_sample sample_out;  	size_t i, sz, bufsz;  	int err, ret = -1; -	for (i = 0; i < sizeof(user_regs); i++) -		*(i + (u8 *)user_regs) = i & 0xfe; +	if (sample_type & PERF_SAMPLE_REGS_USER) +		evsel.attr.sample_regs_user = sample_regs; + +	if (sample_type & PERF_SAMPLE_REGS_INTR) +		evsel.attr.sample_regs_intr = sample_regs; + +	for (i = 0; i < sizeof(regs); i++) +		*(i + (u8 *)regs) = i & 0xfe;  	if (read_format & PERF_FORMAT_GROUP) {  		sample.read.group.nr     = 4; @@ -271,7 +294,7 @@ int test__sample_parsing(void)  {  	const u64 rf[] = {4, 5, 6, 7, 12, 13, 14, 15};  	u64 sample_type; -	u64 sample_regs_user; +	u64 sample_regs;  	size_t i;  	int err; @@ -280,7 +303,7 @@ int test__sample_parsing(void)  	 * were added.  Please actually update the test rather than just change  	 * the condition below.  	 */ -	if (PERF_SAMPLE_MAX > PERF_SAMPLE_TRANSACTION << 1) { +	if (PERF_SAMPLE_MAX > PERF_SAMPLE_REGS_INTR << 1) {  		pr_debug("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n");  		return -1;  	} @@ -297,22 +320,24 @@ int test__sample_parsing(void)  			}  			continue;  		} +		sample_regs = 0;  		if (sample_type == PERF_SAMPLE_REGS_USER) -			sample_regs_user = 0x3fff; -		else -			sample_regs_user = 0; +			sample_regs = 0x3fff; + +		if (sample_type == PERF_SAMPLE_REGS_INTR) +			sample_regs = 0xff0fff; -		err = do_test(sample_type, sample_regs_user, 0); +		err = do_test(sample_type, sample_regs, 0);  		if (err)  			return err;  	}  	/* Test all sample format bits together */  	sample_type = PERF_SAMPLE_MAX - 1; -	sample_regs_user = 0x3fff; +	sample_regs = 0x3fff; /* shared yb intr and user regs */  	for (i = 0; i < ARRAY_SIZE(rf); i++) { -		err = do_test(sample_type, sample_regs_user, rf[i]); +		err = do_test(sample_type, sample_regs, rf[i]);  		if (err)  			return err;  	}  | 

