diff options
| author | Michael Ellerman <mpe@ellerman.id.au> | 2014-06-10 08:23:10 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-06-11 03:03:58 -0400 |
| commit | 3752e453f6bafd78e5586cc2b2e33ee4b6e1566d (patch) | |
| tree | 2c5d88b6d9f759844249a36ce8b729dcb5c274ad /tools | |
| parent | 33b4819f3b93bbcb934e02cbc64ff3c5e9d0149b (diff) | |
selftests/powerpc: Add tests of PMU EBBs
The Power8 Performance Monitor Unit (PMU) has a new feature called Event
Based Branches (EBB). This commit adds tests of the kernel API for using
EBBs.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'tools')
34 files changed, 3913 insertions, 4 deletions
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile index 7216f0091655..b9ff0db42c79 100644 --- a/tools/testing/selftests/powerpc/pmu/Makefile +++ b/tools/testing/selftests/powerpc/pmu/Makefile | |||
| @@ -4,7 +4,7 @@ noarg: | |||
| 4 | PROGS := count_instructions | 4 | PROGS := count_instructions |
| 5 | EXTRA_SOURCES := ../harness.c event.c | 5 | EXTRA_SOURCES := ../harness.c event.c |
| 6 | 6 | ||
| 7 | all: $(PROGS) | 7 | all: $(PROGS) sub_all |
| 8 | 8 | ||
| 9 | $(PROGS): $(EXTRA_SOURCES) | 9 | $(PROGS): $(EXTRA_SOURCES) |
| 10 | 10 | ||
| @@ -12,12 +12,30 @@ $(PROGS): $(EXTRA_SOURCES) | |||
| 12 | count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES) | 12 | count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES) |
| 13 | $(CC) $(CFLAGS) -m64 -o $@ $^ | 13 | $(CC) $(CFLAGS) -m64 -o $@ $^ |
| 14 | 14 | ||
| 15 | run_tests: all | 15 | run_tests: all sub_run_tests |
| 16 | @-for PROG in $(PROGS); do \ | 16 | @-for PROG in $(PROGS); do \ |
| 17 | ./$$PROG; \ | 17 | ./$$PROG; \ |
| 18 | done; | 18 | done; |
| 19 | 19 | ||
| 20 | clean: | 20 | clean: sub_clean |
| 21 | rm -f $(PROGS) loop.o | 21 | rm -f $(PROGS) loop.o |
| 22 | 22 | ||
| 23 | .PHONY: all run_tests clean | 23 | |
| 24 | SUB_TARGETS = ebb | ||
| 25 | |||
| 26 | sub_all: | ||
| 27 | @for TARGET in $(SUB_TARGETS); do \ | ||
| 28 | $(MAKE) -C $$TARGET all; \ | ||
| 29 | done; | ||
| 30 | |||
| 31 | sub_run_tests: all | ||
| 32 | @for TARGET in $(SUB_TARGETS); do \ | ||
| 33 | $(MAKE) -C $$TARGET run_tests; \ | ||
| 34 | done; | ||
| 35 | |||
| 36 | sub_clean: | ||
| 37 | @for TARGET in $(SUB_TARGETS); do \ | ||
| 38 | $(MAKE) -C $$TARGET clean; \ | ||
| 39 | done; | ||
| 40 | |||
| 41 | .PHONY: all run_tests clean sub_all sub_run_tests sub_clean | ||
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile new file mode 100644 index 000000000000..edbba2affc2c --- /dev/null +++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | noarg: | ||
| 2 | $(MAKE) -C ../../ | ||
| 3 | |||
| 4 | # The EBB handler is 64-bit code and everything links against it | ||
| 5 | CFLAGS += -m64 | ||
| 6 | |||
| 7 | PROGS := reg_access_test event_attributes_test cycles_test \ | ||
| 8 | cycles_with_freeze_test pmc56_overflow_test \ | ||
| 9 | ebb_vs_cpu_event_test cpu_event_vs_ebb_test \ | ||
| 10 | cpu_event_pinned_vs_ebb_test task_event_vs_ebb_test \ | ||
| 11 | task_event_pinned_vs_ebb_test multi_ebb_procs_test \ | ||
| 12 | multi_counter_test pmae_handling_test \ | ||
| 13 | close_clears_pmcc_test instruction_count_test \ | ||
| 14 | fork_cleanup_test ebb_on_child_test \ | ||
| 15 | ebb_on_willing_child_test back_to_back_ebbs_test \ | ||
| 16 | lost_exception_test no_handler_test | ||
| 17 | |||
| 18 | all: $(PROGS) | ||
| 19 | |||
| 20 | $(PROGS): ../../harness.c ../event.c ../lib.c ebb.c ebb_handler.S trace.c | ||
| 21 | |||
| 22 | instruction_count_test: ../loop.S | ||
| 23 | |||
| 24 | lost_exception_test: ../lib.c | ||
| 25 | |||
| 26 | run_tests: all | ||
| 27 | @-for PROG in $(PROGS); do \ | ||
| 28 | ./$$PROG; \ | ||
| 29 | done; | ||
| 30 | |||
| 31 | clean: | ||
| 32 | rm -f $(PROGS) | ||
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c new file mode 100644 index 000000000000..66ea765c0e72 --- /dev/null +++ b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2014, Michael Ellerman, IBM Corp. | ||
| 3 | * Licensed under GPLv2. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <stdbool.h> | ||
| 7 | #include <stdio.h> | ||
| 8 | #include <stdlib.h> | ||
| 9 | |||
| 10 | #include "ebb.h" | ||
| 11 | |||
| 12 | |||
| 13 | #define NUMBER_OF_EBBS 50 | ||
| 14 | |||
| 15 | /* | ||
| 16 | * Test that if we overflow the counter while in the EBB handler, we take | ||
| 17 | * another EBB on exiting from the handler. | ||
| 18 | * | ||
| 19 | * We do this by counting with a stupidly low sample period, causing us to | ||
| 20 | * overflow the PMU while we're still in the EBB handler, leading to another | ||
| 21 | * EBB. | ||
| 22 | * | ||
| 23 | * We get out of what would otherwise be an infinite loop by leaving the | ||
| 24 | * counter frozen once we've taken enough EBBs. | ||
| 25 | */ | ||
| 26 | |||
| 27 | static void ebb_callee(void) | ||
| 28 | { | ||
| 29 | uint64_t siar, val; | ||
| 30 | |||
| 31 | val = mfspr(SPRN_BESCR); | ||
| 32 | if (!(val & BESCR_PMEO)) { | ||
| 33 | ebb_state.stats.spurious++; | ||
| 34 | goto out; | ||
| 35 | } | ||
| 36 | |||
| 37 | ebb_state.stats.ebb_count++; | ||
| 38 | trace_log_counter(ebb_state.trace, ebb_state.stats.ebb_count); | ||
| 39 | |||
| 40 | /* Resets the PMC */ | ||
